For the given ER diagram, below are the steps to convert the ER diagram into the relational schema:
Each entity becomes a relation. First convert all the entities and relationship into tables with their primary keys (marked in red) and other attributes as below. So three tables are created i.e. DUDE with primary key NickName, GUEST with primary key GuestName and KNOWS with the primary keys of tables DUDE and GUEST.
In the above KNOWS table, the relationship shown is many-to-many i.e. every dude knows many guest and every guest knows many dude, and therefore it is seen that Nickname and GuestName values are repeating but the combination of both the values is unique. Therefore, the combination of both the Nickname and GuestName is the primary key for the table KNOWS. Therefore, all the three tables above have different primary keys and hence cannot be merged into one or two tables. Therefore, the above ER diagram is converted into three tables.
2) For the relationship between the DUDE and SNACK:
In the above BUYS table, the relationship shown is one-to-many i.e. one dude buys one or many snacks but one snack can be bought only by one dude, and therefore it is seen that Nickname values are not repeating but the SnackName values are repeating. Therefore, Nickname is the primary key for the table BUYS. Both the BUYS table and DUDE table have the same primary key therefore, these two tables can be merged into one table by making SnackName in the buys table as the foreign key after merging the two tables. Therefore, the above ER diagram is converted into two tables Table4 with primary key as Nickname and foreign key as SnackName and Table5 with the primary key as SnackName as below:
3) For the self relationship between the GUEST and GUEST:
In the above GUEST table, the relationship shown is one-to-many i.e. one guest as a host can invite one or more guest and many guest can visit only one host. Therefore, GuestName is the primary key for the table invites with Host as the foreign key that will have the same value as the column GuestName. Both the INVITES table and GUEST table have the same primary key therefore, these two tables can be merged into one table by making GuestName as the primary key and Host as the foreign key. Therefore, the above ER diagram is converted into one table as below:
Question 30. Convert the ER diagram below to a relational schema using the conversion algorithm from...
The following relational schema is given for a Pokemon Database: Pokemon (PID, PName) Type (TID, TName) Trainer (SSN, Name, Surname) InType (PID, TID) StrongAgainst (TID_Strong, TID_Weak) Owns (SSN, PID, Nickname, Level, Height, Weight, Catch_Date) SpecializedIn (SSN, TID) In this database, Pokemon (Imaginary creatures, short for “Pocket Monsters”) are stored in the entity set Pokemon, with a unique PID and PName. Pokemon types are stored in the entity set Type, with a unique TID and TName. Pokemon trainers are stored in...