Closed Psyf closed 5 years ago
Prof replied. Here is the discussion for reference:
Dear Profs,
Can weak entities be part of more relations than just one? Can weak entities have foreign keys that are not part of its primary key?
Example 1:
- BOOKS HAS CHAPTERS. Chapters is a weak entity. Primary key of Chapters Table looks like (book_id, chapter_number)
- ** USERS LIKES CHAPTERS. Here we assume USERS is a table with (user_id) and LIKES will hold (user_id, book_id, chapter_number). Notice here, USERS has a relationship with CHAPTERS (the weak entity). Question: Is this valid?
Example 2 (New and Separate Schema):
- BOOKS HAS CHAPTERS. Chapters is a weak entity. Primary key of Chapters Table looks like (book_id, chapter_number).
- Each Chapter is written by different authors.
- AUTHORS WROTE CHAPTERS.
- Instead of making the table WROTE in the implementaion, the DB designer decides a FOREIGN_KEY in CHAPTER called author_id that references AUTHORS is enough. Question: Is this valid?
Thanks.
Reply was the following:
Comment on Question 1: An entity set (whether or not it is a weak one) can participate in relationship sets. May I refer you to the discussions in Tutorial 2 where we have the weak entity set, Drugs, that is in involved in Prescribes and Sells relationships.
Comment on Question 2: If the assumption is that each chapter is written by exactly one author (i.e., there is a key constraint constraint on CHAPTERS w.r.t. WROTE as well as a total participation constraint on CHAPTERS w.r.t. WROTE, then it is possible to adopt the Second Approach (Slide 34 of Lecture 3) to derive the relational schema.
Done in #24
Take the feedback from the alpha demo and fix the DB. Also, fix the ER.