This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have 3 tables : Purchases, Payments and Sellers. And these are the constraints: - A purchase has 1 seller - A payment has 1 seller - A payement can have 1 or many purchases (purchases that have the Same Seller) - A purchase can have 0 or many payments (Partial payments)
I've tried 2 solutions but both of them could have tuples in the database that do not respect the previous constraints.
What is the right and correct relational schema for this case? Thanks in advance !
Edit : I will try to elaborate my problem more : There is a many-to-many relationship between Purchases and Payments, this will give us another Intermediate table we will name Purchase_Payment. in this case it's possible to have tuples in this table in which the Seller of the Payment is different than the Seller of the Purchase (Even though it would be practically impossible to happen as in the UI of my app, I will force the user to choose a Seller before making a payment. But in theory it's possible to have such an inacceptable tuple in my intermediate table which made me think that maybe I have a wrong relational schema). I hope that the problem is more understandable now
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/SQL/comment...