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
Post a Comment