I need to store similar products with different attributes (such as length or color) Should this product be combined with different IDs or a product with many features?
The main problem is that I am likely to see the quantity of products by virtue (4 red boots, 3 blue etc.) and need to implement the attribute selector on the product page.
If you create an ID, how to store attributes in the cart table with selected attributes, and how much quantity should be managed?
If you make many aids, then this volume is easy to manage, but how to implement attribute selection?
I think about linking product ID to attributes and attribute values about some SKU but how to link all together?
Tables
is for storing any data that you have You need to use different queries
for any particular information about those entries, for example, consider the following product
table:
< Code> + ---- + ------------- + ----- -------- + | ID | Product Number | ProductType | + ---- + ------------- + ------------- + | 1 | Product A | Type A | + ---- + ------------- + ------------- + | 2 | Product B | Type A | + ---- + ------------- + ------------- + | 3 | Product C | Type b + ---- + ------------- + ------------- +
You can get the quantity Type the product Type A
by typing the following query
(see for better understanding):
select the count (*) Calculation from the product in OffProduct where ProductType = "Type A"; In your comment, you mentioned that a product can have different types and different quantities. You can do this in a table but it looks messy. If you want that you need to do this, you have 1-many ** relationship ** between two tables named product
and type
Need to build code>. Type
table might be something like this:
| TYPE_ID | TYPE | | --------- | -------- | | 1 | Type A | | 2 | Type b | 3 | Type C
And your product
table might be something like this:
| PRODUCT_ID | PRODUCTNAME | QUANTITY | TYPE_ID | | ------------ | ------------- | ---------- | --------- | | 1 | Product A | 3 | 1 | | 2 | Product B | 2 | 1 | | 3 | Product C | 1 | 2 | | 4 | Product C | 5 | 3 |
** Keep in mind that type_id
is a foreign key that creates a connection between these two tables. And since you can have many products of the same type (such as Product C in this example), this table will be your several
tables and type table will be your a
table. Therefore, by entering foreign key
in the lot
table, you will set multiple contacts. Now, to combine these two tables (or in other words join
) you will need to type the join
query as the following: Type the product name, type, type, product name, quantity, and the result you want on
T.type_id = p.type_id
Are:
| PRODUCTNAME | QUANTITY | TYPE | | ------------- | ---------- | -------- | | Product A | 3 | Type A | | Product B | 2 | Type A | | Product C | 1 | Type b | Product C | 5 | Type C
Comments
Post a Comment