This document contains the solution to an assignment involving entity relationship diagrams (ERDs). It models the entities and relationships described in a scenario involving different types of animals and zookeepers at a zoo. The solution includes the ERD diagram and discusses various modeling assumptions made. It also contains solutions to other exercises involving translating ERDs to relational schemas and comparing different types of database management systems.
This document contains the solution to an assignment involving entity relationship diagrams (ERDs). It models the entities and relationships described in a scenario involving different types of animals and zookeepers at a zoo. The solution includes the ERD diagram and discusses various modeling assumptions made. It also contains solutions to other exercises involving translating ERDs to relational schemas and comparing different types of database management systems.
September 26, 2008 Entity Relationship Diagrams 1. Model the entities and relationships (including attributes and proper- ties of relationships) described below in an ER-diagram. 1 Write down any assumptions you make. Zoo The LMF Zoo has many types of animals. Every type has a unique name. Every animal of the same type has a unique animal ID. Animals in two types may have the same animal ID. Animals also have age and gender. Animals may have diseases. The beginning time and the duration of a disease need to be recorded. A disease has a unique name. A type keeper takes care of only one type of animals. Every type may have many type keepers. A type keeper may or may not be familiar with diseases. But every disease must be handled by at least one type keeper. Type keepers have name, employee ID, ssn, address and phone number. All animals are in cages. Some cage may be empty. Every cage has a cage ID, space and height. A cage keeper may take care of many cages. Every non-empty cage must have at least one cage keeper. Empty cages dont need any cage keepers. Cage keepers have name, employee ID, ssn, address and phone number. Solution: check points: (a) Animal is a weak entity. 1 Note that there are several tools for drawing ER-diagrams, for example dia: http://www.gnome.org/projects/dia/. 1 (b) Use ISA (c) Type keepers take care of only one type. It is a function and total participate. (d) All non-empty cages must have at least one cage keeper. It is a total participate. 2 2. Exercise 2.2 in the text book. Solution: Assume that semesterID is unique for every semester. Oth- erwise you need another entity called semester and make the teach a ternary relation. If you assume that each course can only have one professor, you need add an arrow from course to teach. 3 Professor course teach semesterID SSN CID 1. Professor course teach SSN CID 2 Professor course teach SSN CID 3 Professor course teach SSN CID Professor course teach SSN CID 4 5 Professor course teach SSN CID Group belong Groupteach 6 4 3. Exercise 2.7 in the text book. Solution: 2.If the drug is to be sold at a xed price we can add the price attribute to the Drug entity set and eliminate the price from the Sell relationship set. 3. The date information can no longer be modeled as an attribute of Prescription. We have to create a new entity set called Prescription date and make Prescription a 4-way relationship set that involves this additional entity set. 5 4. Excercise 3.3 in the text book. The user of SQL has no idea how the data is physically represented in the machine. He or she relies entirely on the relation abstraction for querying. Physical data independence is therefore assured. Since a user can dene views, logical data independence can also be achieved by using view denitions to hide changes in the conceptual schema. 5. Given the following ER diagram, try to answer following questions. Write down any assumptions you make. employee departments children work manage parent (a) Translate the ER diagram into a relational schema. Solution: Create Table Employee( employeeID char(20), primary key (employeeID) ) Create Table Dept-Mgr( did char(20), manager char(20) NOT NULL, primary key (did), foreign key (manager) references Employee on delete no action ) Create Table Work-in( did char(20), employeeID char(20), Primary key (did, employeeID), 6 foreign key (employeeID) references Employee on delete cascade, foreign key (did) references Dept-Mgr on delete cascade ) Create Table children( name char(50), parentID char(20), primary key(name, parentID), foreign key (parentID) references Employee on delete cascade ) It is unable to capture the constraints that all employees partic- ipate in the work relation and all departments participate in the work relation at the same time. In the case that we dont create Work-in table, in the Employee table we declare that department did is a foreign key of Depart- ment table. This will ensure that all empoyees participate in the relationship but the total participation of departments cannot be captured. In the case that a Work-in table is used, to ensure that every did in department table shows up in the Work-in table, we can declare department did in Department table as a foreign key re- ferring to Work-in table. But the did is not a candidate key for Work-in table. Refer to 3.5.4 of textbook for more details. (b) If a manager can manage only one department, try to change the ER model and the relational schema to reect the constraint. If you are unable to capture the constraint, explain why. Solution: (It is also right if you use the manager entity with ISA. ) 7 employee departments children parent work manage Create Table Dept-Mgr( did char(20), manager char(20) NOT NULL, primary key (did), foreign key (manager) references Employee on delete no action, UNIQUE(manager) ) 8 6. Translate the following ER diagram into a relational schema. House House address space value Room HasR floorspace RoomID Door Window HasD HasW DoorID WinID Landlord HasH Tenant HasT rent People ISA SSN name age income Solution: Create Table People( ssn char(20), name char(50), age INTEGER, income INTEGER, primary key(ssn) 9 ) Create Table House( address char(50), value INTEGER, space INTEGER, primary key(address) ) Create Table Tenant-HasT( ssn char(20), rent INTEGER, address char(50) NOT NULL, primary key(ssn, address), foreign key(ssn) reference People on delete cascade, foreign key(address) reference House on delete cascade ) Create Table Landlord-HasH( ssn char(20), address char(50) NOT NULL, primary key(ssn, address), foreign key(ssn) reference People on delete cascade, foreign key(address) reference House on delete cascade ) Create Table Room( roomID char(20), oor INTEGER, address char(50), primary key (address, roomID), foreign key(address) reference House on delete cascade ) 10 Create Table Door( DoorID char(20), roomID char(20), oor INTEGER, address char(50), primary key (address, roomID, DoorID), foreign key(roomID) reference Room on delete cascade, foreign key(address) reference House on delete cascade ) Create Table Window( WindowID char(20), roomID char(20), oor INTEGER, address char(50), primary key (address, roomID, WindowID), foreign key(roomID) reference Room on delete cascade, foreign key(address) reference House on delete cascade ) 7. Survey: Choose three dierent types of DBMS, briey compare them. (For example, Filesystem-based, Hierarchical, Network, RDBMS, Object- oriented, XML DBMS...) 11
Where can buy (Ebook) The Reception of British Aesthetics in Germany: Seven Significant Translations, 1745-1776 (7-volume-set) by Heiner F. Klemme, Manfred Kuehn ISBN 9781855068995, 1855068990 ebook with cheap price
Where can buy (Ebook) The Reception of British Aesthetics in Germany: Seven Significant Translations, 1745-1776 (7-volume-set) by Heiner F. Klemme, Manfred Kuehn ISBN 9781855068995, 1855068990 ebook with cheap price