sql - Table Design For Multiple Different Products On One Order -


if have online shopping website sold apples , monitors , these stored in different tables because distinguishing property of apples colour , of monitors resolution how add these both invoice table whilst still retaining referential integrity , not unioning these tables?

                        invoices(invoiceid)                                  |                   invoiceitems(itemid, productid)                                  |                        products(productid)               |                                            | apples(appleid, productid, colour)   monitors(monitorid, productid, resolution) 

in first place, store them in single products table, not in 2 different tables.

in second place, (unless each invoice 1 product) not add them single invoice table - instead, set invoice_products table, link between tables.

i suggest database normalisation.


Comments

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -