Reputation: 79
For a university course, I have to set up an SQL database.
We are supposed to set up a database containing information about house sales. For this, I have created 3 tables: 1 containing info about the houses, 1 containing info about offerings, and 1 containing info about closed sales.
This I have already committed to, and may not be changed.
This leaves me with a question. The table Offer contains as a primary key OfferID. The table Sales refers to the table using the OfferID. For me, it would be most logical to also use OfferID as a primary key in Sales, since a Sale can only take place 1 on 1 with an Offer.
Does this sound logical? Or should I be doing it different?
Upvotes: 0
Views: 56
Reputation: 464
Because the closed sales table is really an extension of the offer table it makes sense. The offer becomes closed and the closed sales table contains addition data not needed in other offers. This seems an elegant solution.
Upvotes: 2
Reputation: 101
If you are sure it is a 1 to 1 relation why not. But you have to have clear that it is a constraint you add, that may be problematic for future to change if the model changes. (more sales with same offer). Considering it is a university course, not sure what is the best solution.
Upvotes: 1