Table relation

T

TC

I am hoping someone can shed some light on this. Say we
have 3 brands of computers, each brand has their own type,
and the customer may order 2 brands with 3 types of each
brand. How do I set up the relationship of this?

Computer
BrandID
Brand

BrandType
TypeID
Type

Customer
CustomerID
Name
Address

Thanks for any help.
 
J

John Vinson

I am hoping someone can shed some light on this. Say we
have 3 brands of computers, each brand has their own type,
and the customer may order 2 brands with 3 types of each
brand. How do I set up the relationship of this?

Computer
BrandID
Brand

BrandType
TypeID
Type

Customer
CustomerID
Name
Address

The customer isn't ordering a type - the customer is ordering an
object, a physical computer box. You need a Table to represent this
entity, with one record for each physical computer which a customer
can order. Also, since each BrandID can have multiple Types, you need
a foreign key - BrandID should be a (nonunique, indexed) field in the
BrandType table.

Finally, since each customer can buy multiple boxes, and each type of
box can be bought by several customers, you have a many to many
relationship which needs another table (let's call it Purchases).

Try:

Computer
BrandID
Brand

BrandType
TypeID
BrandID <link to Computer>
Type

Customer
CustomerID
Name
Address

Purchases
CustomerID <who bought something>
TypeID <what did they buy>
DateSold
<other information about this purchase>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top