relational database - mysql: what data model I use for making combination of salts -


i have salts table given below have long list of salts:

**salts**: ------------------------ | id | name             | ------------------------- | 1  | paracetamol      | ------------------------- | 2  | aceclofenac      | ------------------------- | 3  | serratiopeptidase| ------------------------- | 4  | tizanidine       | ------------------------- 

also have table of unit

units:

-------------- | id | name  | -------------- | 1  | mg    | ------------- | 2  | gm    | ------------- | 3  | mcg   | ------------- 

now want create combination of these salts using unit , quantity, every combination should unique, example of combinations are:

paracetamol [300 mg] paracetamol [200 mg] 

(in above example paracetamol -> salt name, 200 -> quantity of salt , mg -> unit of salt), other example of combination:

paracetamol [200 mcg] aceclofenac [50 mcg] + paracetamol [250 mg] aceclofenac [50 mcg] + paracetamol [250 mcg] aceclofenac [100 mg] + paracetamol [500 mg] + serratiopeptidase [15 mg] + tizanidine [2 mg] 

in above list combination unique , can't repeated. question should best data model(schema) store combinations unique , database remain normalized.

you can create table having column

salt_name varchar(100), quantity int, unit varchar(20) 

for table can combile these 3 columns unique key


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -