I have a order
table and each order in that table belongs to either a device
or part
(these two have no specific intersection in fields).
So I need to store the did
or pid
as FK in order
table.
"device"
+----+....
| id |<---------+
+----+.... :
: : : : . :
:
:
"part" :
+----+.... :
| id |<-------+ :
+----+.... : :
: : : : . : :
: :
: :
"order" @ @
+-----+-------+....
| id | for |....
+-----+-------+....
: : : : : : : : .
Now How should I do this?
- Add a
type
field toorder
table and store bothpid
ordid
on one column(e.g.for
) - Create an intermediate view with
type
,pid
,did
columns - Create a higher level table (e.g.
goods
) and make its PK to be FK onorder
,part
,device
Which one is the best method? or some other method?