If I had an online shopping site that sold apples and monitors, and they were stored in different tables, because the distinguishing feature of apples is color, and the color of monitors is permission, how would I add this data to the table of accounts while maintaining link integrity and without combining these tables?
Invoices(InvoiceId) | InvoiceItems(ItemId, ProductId) | Products(ProductId) | | Apples(AppleId, ProductId, Colour) Monitors(MonitorId, ProductId, Resolution)
First, I would save them in one Products table, and not in two different tables.
Secondly, (if only each account was intended for only one product), I would not add them to one table of accounts, instead I would set the Invoice_Products table to link between the tables.
.
. , ? SKU?
, SKU. . SKU . - :
product {sku} key {sku};
invoice_item {invoice_id, sku} key {invoice_id, sku};
apple {color, sku} key {color} key {sku};
monitor {size, sku} key {size} key {sku};
... , apple {sku} monitor {sku} == product {sku}.
Invoice ProductID FK, ProductID AppleID ( PK), MonitorID ( PK)?
, ProductTypeID , 0 = apple, 1 = monitor isProductTypeApple boolean, - 2 , ProductID PK.
ProductTypeID Apple Monitor PK.
... , , "", " "... , , . ( ).
... "product_type", , ( ), "product_id", apple/ . sql... , , ( , , )
, ... db , , .
Source: https://habr.com/ru/post/1768439/More articles:J2ME: Получить только год/месяц/день с DateField - java-meZend Structure, URL Browsing Assistant and Layout - url-routingHow can I get rid of “Release 1” in the Sphinx output latex page header? - documentationStart template animation as soon as the control is loaded - templatesидентификатор ячейки Android - androidHow can I change Android SeekBar Thumb after using onCreate method? - androidВстроенные Google Docs. Программа просмотра PDF отображает страницу входа, а не PDF. - google-docsUsing .NET memory modulo - c #Getting javascript libraries from Google / Microsoft CDN via SSL - javascriptSubmit Android intent with POJO as an add-on? - javaAll Articles