-1

I need to make the ER diagram and the relational schema of the Ski rentals. I have an Customer, Rental and Ski as a entities as well as their attributes. Customers and Rentals should have the one-to-many relationship and the relationship between Rentals and Ski should be many-to-many (one rental can have many skis and one ski can be rented to many customers). As I did some research on how to make the relational schema, I found out that it is mandatory to make the junction table Rentals_skis that include foreign keys from the Rentals and Ski. Is it necessary to add primary key to the junction table? Also, should I add new entity Rentals_skis in my ER diagram?

This is the links to my diagrams that I made using Dia.

Relational schema: https://i.stack.imgur.com/0LJH0.jpg

ER diagram: https://i.stack.imgur.com/Hv4b7.jpg

cinnamond
  • 79
  • 6
  • [Why should I not upload images of code/data/errors when asking a question?](https://meta.stackoverflow.com/q/285551/3404097) An ERD is an image of DDL. – philipxy May 03 '23 at 13:32
  • I think that the same ski should not be rented to more than 1 person at any given time - even though it can be rented to multiple persons throughout the day. So you will have rows in your RENTALS table with time periods - plus the corresponding foreign keys for the ski unique item ID and for the corresponding person. – IVO GELOV May 03 '23 at 14:27

1 Answers1

0

Yes, for a m:n relationship you need to create the junction table that holds the primary key from each of the entities, e.g. {rental_id, ski_id}, and yes, it should be in your ER diagram. It might not be in a conceptual model, but it should definitely be in your logical model.

Whether or not you make those two foreign keys together into a composite primary key, or you add a surrogate key (e.g. rental_ski_id) is a design choice and up to you, but the table should have a primary key.

IMO your table names should all be singular nouns (rental, ski, rental_ski) rather than plural nouns (rentals, skis, rentals_skis).

Kurt
  • 1,708
  • 1
  • 3
  • 11