10
1 Semi-structured data - exercises

1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

Embed Size (px)

Citation preview

Page 1: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

1

Semi-structured data-

exercises

Page 2: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

2

• Represent the relations below using the OEM data model.

Exercise 1

r_id name

r1 Hamletr2 Normandier3 McDonald's

c_id name

c1 Linkopingc2 Norkoping

r_id c_id street

r1 c1 Storgatanr2 c1 St.Larsgatanr3 c2 Kungsgatan

R es taurantsC ities

R es taurants & C ities

Page 3: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

3

Answer exercise 1 - the OEM model

K ungs gatanS t.Lars gatanS to rgatan

1

2 3 4

R es taurants R es tC ity C ities

6

1 5

D B

5 7

1 3

1 4 1 6

1 7

1 8

9

2 4

1 0

2 7

8

2 1

1 1

2 8

1 2

2 9

3 0

3 1

TT T TT T TT

r_ id

nam e

r_ id

nam e

r_ id

nam e

r1 r2 r3

H am let N o rm and ie M c D o n.

c _ id

nam e

c _ id

nam e

c 1 c 2

Linko p ing N o rko p ing

s treet s treet s treetc _ id

r_ idc _ id

r_ idc _ id

r_ id

Page 4: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

4

• Using the data model from the previous question, formulate the following queries using Lorel:

– find all the restaurants that are located in Linkoping

– find the address (city and street) of the “Hamlet” restaurant

– list the restaurants by city (equivalent of GROUP BY)

Exercise 2

Page 5: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

5

find all the restaurants that are located in Linkopingselect R.namefrom DB.Restaurants.T R, DB.RestCities.T RC, DB.Cities.T Cwhere R.r_id = RC.r_id and RC.c_id = C.c_id and C.name = “Linköping”

list the restaurants by city (equivalent of GROUP BY)select C.name, (select R.name from DB.Restaurants .T R, DB.RestCities.T RC where R.r_id = RC.r_id and RC.c_id = C.c_id) from DB.Cities.T C

Answer Exercise 2

Page 6: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

6

• Draw strong and the minimal Data Guides forthe restaurant guide data model below.

Exercise 3

1 G u id e

2 3 4

5 6 7

go urm et C hef C hu

1 6 1 7 1 8

El C am ino R eal P alo A lto 92310

9 1 0 1 18

S aigo n M enlo P ark

res taurant res taurant c afe

nearb y

c atego ry nam e ad d res s

s treet c ity zip c o d e

c o ntac t nam e ad d res s

nearb y

nearb y

1 9

m anager

2 6

p ho ne

71-72-73

c o ntac t

2 0

res ervatio n

2 7

p ho ne

11-12-13

1 2 1 3 1 4

fas t fo o d S and ra

2 1 2 2 2 3

R yd s vagen L inko p ing 58435

1 5

c atego ry nam e ad d res s

s treet c ity zip c o d e

c o ntac t

2 5

m anager

2 9

p ho ne

2 4

res ervatio n

2 8

p ho ne

31-32-33 34-35-36

Restaurantguide

Page 7: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

7

Answer Exercise 3 - Strong Data Guide

41

42 43

44 45 46

52 53 54

47

restaurant cafe

category name address

street city zipcode

contact

nearby nearby

56

manager

63

phone

48 49 50

57 58 59

51

category name address

street city zipcode

contact

61

manager

65

phone

60

reservation

64

phone

55

reservation

62

phone

66 67

Restaurantguide

Page 8: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

8

Answer Exercise 3 - Strong Data Guide - continued

66 67

48 68 69

57 58 59

70

nearby

category name address

street city zipcode

contact

nearby

61

manager

73 74 75

name address contact

56

reservation

71

reservation

72

phone

43

Page 9: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

9

41: 142: 2,343: 444: 545: 6,946: 7,1047: 8, 1148: 1249: 1350: 1451: 1552: 1653: 1754: 1855: 19

56: 2057: 2158: 2259: 2360: 2461: 2562: 2663: 2764: 2865: 2966: 3,467: 368: 9,1369: 10,1470: 11,15

71: 20,2472: 27,2873: 974: 1075: 11

Page 10: 1 Semi-structured data - exercises. 2 Represent the relations below using the OEM data model. Exercise 1

10

Answer Exercise 3 - Minimal Data Guide

80

81

82 83 84

86 87 88

85

restaurantcafe

nearby

category name address

street city zipcode

contact

manager

89

reservation

90

phone

Restaurantguide