Question

I have a logic-thinking problem. How should I design following database?

A manufacturer sells cars. He sells them as they are, or with a package A, or with a package B, or with both packages.

I would create a table with the different car models, then a table with the different packages, but I don't know how to create the mapping-table, which links the cars to the different packages and prices?

The problem is the packages don't have a price (just the cars and the cars with packages included).

Was it helpful?

Solution

Add "offer" table. This table will contain price. Each offer should have at least one car and no, one, two, many, or all (if there will be more then 2 of them) packages.

enter image description here

OTHER TIPS

I would guess that a car would have a manufacturers suggested retail price (MSRP). Each package or option would have its own additional price on top of the MSRP.

I'd have a base Car table, a Package table, and another purchased Car table, one to many with a Customer table, where the Customer can associate their base Car with one or more Package instances.

If you want to do it correctly, you need to use Table Inheritance.

You sell abstract products. One type of product is a car. Another is a "combo" (aka "marketing package") which is composed of other products.

There are some good data modeling books that cover this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top