1

Okay soo I’m not a database guy.. I’m an embedded engineer but I’m helping one of my interns make a hardware tracking database... so we are tracking assembled products (dev samples).. but also tracking the pcbs within the product.. depending on the product it might have more than one pcb or contain other components to track.

The question is how would I set up the relationship in the tables, so depending on the say “type id” of the product it would link to a table full of feilds specfic to that “type”.. say the product is of type phone and has a pcb of this and a camera of that.. blah blah blah.... but say another product is of type “washing machine”.. which has no screen, it has a different pcb, but also has other things..

There would be a type table .. washing machine, phone, tv, camera, pcb, ecu.. etc.. but those type would need their own tables...

I guess the question is how to relate a field to different tables depending on the value of the field... is this portion all done thru query results and logic rather than pure data base schemas?

What would be the question in terms of database lingo to google search the answer lol

Comments
  • 2
    We literally had a similar conversation at work today... You are actually describing a form of normalization either 2nd or 3rd.

    You're gonna want to implement foreign keys on your dependant tables to the abstracted tables for each type.
  • 0
    Not sure If i understand correctly but you might want to take a look at SQL antipatterns:

    https://de.slideshare.net/mobile/...

    (Entity Attribute Value / Polymorphic Associations)
Add Comment