110 likes | 228 Views
This document contains a series of exercises related to semi-structured data modeling and querying using the OEM (Object Entity Model) and Lorel query language. It covers representing restaurant relations, querying for specific restaurant information in Linköping, and constructing strong and minimal data guides for a restaurant guide data model. The exercises emphasize practical skills in data modeling and query formulation, providing a hands-on approach for understanding data representation and retrieval techniques in relational databases.
E N D
Exercise 1 • Represent the relations below using the OEM data model.
Exercise 2 • 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)
Answer Exercise 2 find all the restaurants that are located in Linkoping select R.name from DB.Restaurants.T R, DB.RestCities.T RC, DB.Cities.T C where 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
Exercise 3 Restaurantguide • Draw strong and the minimal Data Guides forthe restaurant guide data model below.
Answer Exercise 3 - Strong Data Guide Restaurantguide 41 restaurant cafe 66 67 42 43 nearby nearby category name address contact category name address contact 46 47 44 45 48 49 50 51 street zipcode reservation manager city street city zipcode reservation manager 52 53 54 55 56 57 58 59 60 61 phone phone phone phone 62 63 64 65
Answer Exercise 3 - Strong Data Guide - continued nearby nearby 43 66 67 category name address contact name address contact 69 70 48 68 73 74 75 street zipcode reservation manager city reservation 57 58 59 71 61 56 phone 72
41: 1 42: 2,3 43: 4 44: 5 45: 6,9 46: 7,10 47: 8, 11 48: 12 49: 13 50: 14 51: 15 52: 16 53: 17 54: 18 55: 19 56: 20 57: 21 58: 22 59: 23 60: 24 61: 25 62: 26 63: 27 64: 28 65: 29 66: 3,4 67: 3 68: 9,13 69: 10,14 70: 11,15 71: 20,24 72: 27,28 73: 9 74: 10 75: 11
Answer Exercise 3 - Minimal Data Guide Restaurantguide 80 restaurant cafe nearby 81 category name address contact 84 85 82 83 reservation manager street zipcode city 86 87 88 89 phone 90