Forum Moderators: open

Message Too Old, No Replies

Linking tables together

         

bodycount

3:16 pm on May 17, 2006 (gmt 0)

10+ Year Member



I cant get my head around how you link tables together.

TABLE BOXPRODUCT
BOX_id
SERIALNO
DESCRIPTION

TABLE FR06000104
FR06_id
SERIALNO
MACADDRESS
DESCRIPTION

TABLE FG000071
FG71_id
SERIALNO
IMEI
CANSERIAL
DESCRIPTION

TABLE CARRIERBOARD
CB_id
SERIALNO
DESCRIPTION

The box product contains 1 x FR06000104 1 x FG000071 and 1 x CARRIERBOARD

The FR06000104 , FG000071 and CARRIERBOARD can be sold as seperate items as well this
is why they also have there own serial numbers.

How do i link the box product to the other 3 products?

How do i pull the data back out of the database so that they are still linked together?

siMKin

1:24 pm on May 19, 2006 (gmt 0)

10+ Year Member



Before you start linking all sorts of data, first you need a good datamodel. Otherwise you might create an unsolvable puzzle for yourself.

So, what entities are we dealing with here and what are their properties? And once you've defined those entities, try to see if those entities have something in common? If so, that means that that information all goes into one table.

If you're dealing with different products, it depends a bit on the situation how you want to put that in a datamodel.
One solution is to create 1 table with all possible properties and just leave out any information that is not applicable to that specific product.
Another is to create 2 tables. The first describes the general properties of the product (product_id, price, that sort of things), the other is a table that describes specific properties where you would be dealing with 3 columns: product_id, property_name, property_value (and of course a primary key).