B
B
bernex2015-07-09 16:06:52
MySQL
bernex, 2015-07-09 16:06:52

How to make a dependency in the string table and they are without dependencies?

The task is this:
We have goods, they can be nested, i.e. one product can include other products (and this is easy to implement using Nested Sets or Closure Table).
But is it possible to do something cunningly: So that the product exists as a separate, not nested one.
And like investing in another product, but without cloning the record?
Those. you can do something like links in the file system...
I want to be able to:
- select a product and be able to get its contents (sub-products) that are given and unique as its children.
- I select a product and I can get its contents, which (virtual links) to other products.
I would like everything to work through a request or a library (to the edge),
What are the typical solutions?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Therapyx, 2015-07-09
@Therapyx

there is such a thing as foreign keys. Usually, in this case, they do this: You have a main product with "Product_ID" and there is another table where "subproduct_ID". Well, this ProductID is also created in the subproducts table and linked as a foreign key.
After that, you can make queries based on the product ID, which is located in two tables at once.
www.w3schools.com/sql/sql_foreignkey.asp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question