jeudi 23 juillet 2015

sqlite one to one relation

I'm using sqlite to store some data.

What I have is a product is binned into different classes.

product id is unique. but for a given product id, there may be multiple segments. and for each (product id and segment) there will be multiple binnings. I decided it is best to use one-to-one relation between product id, segment <-> binning

product_table
product_id  segment  foreign key
  A123          2         153
  A123          4         154
  B342          1         200

binning_table
primary_key   bin_id    amount
   153          1         1343
   153          8          343
   200          4         ...
   200          1         ...
   200         10         ...
   200        ...         ...

I'd appreciate improvement to above data modeling.

Aucun commentaire:

Enregistrer un commentaire