N
N
Nikita Savinykh2017-12-03 02:24:26
MySQL
Nikita Savinykh, 2017-12-03 02:24:26

How to come up with such an object, which will have many properties?

Good day to all.
There is a small problem, the task is to develop an application for Qt.
Essence - there is a certain category (for example, products).
In this category there is a certain element of this set - water. (In the context of the wording of the question, it is water that will be the object).
But!
Water can be carbonated, or say non-carbonated.
However, carbonated water can be both medicinal and drinking, and just carbonated.
Also, if we are talking about water in a bottle, it can have a different volume (0.5, 1, 1.5, 5 liters).
I have an idea to implement this business (storing categories, as well as objects of these categories, as well as all kinds of properties and properties of properties) in MySQL tables.
But, unfortunately, I do not quite imagine a neat and beautiful solution to this problem.
Is it worth breaking it into a huge number of tables, where there will be object ID and property relationships? What if we point to a property property? Separate table? But the nesting level will be infinite (within reason, of course), I can't create an infinite number of tables. This does not fit with my idea of ​​​​correct development. I was thinking about implementing it through a tree, but how do I implement it within MySQL tables?
Many thanks to everyone who can suggest the right direction of thought.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
entermix, 2017-12-03
@Ukio_G

Something like this:

products:
id,
name

properties:
id,
name

values:
id,
property_id,
value,

products_values:
product_id
value_id

If it's easier, you can do this:
products:
id
name

product_properties:
id, name, value

https://stackoverflow.com/questions/6911297/mysql-...

O
oh, 2017-12-03
well @AnneSmith

if you translate the OWCS (Oracle) documentation with Google and try to make out what is written there, then such a model is just implemented there; before their database tables for some reason could not store more than 6 fields, or something like that, not the point
https://docs.oracle.com/cd/E29542_01/doc.1111/e296...
as they got around this: they created one single Flex Asset object that has 6 fields, i.e. both your product and your properties become objects of the same asset class, and each of them has a parent
i.e. you create an asset of type "product" and asset of type "property", and in the "property" you specify the parent - asset of type "product", you get a regular tree and you link the properties to the product through the "parent" field
in the database, this looks like one table, in which objects of different types are written, but of the same class; in OWCS itself, this is even implemented via drag and drop, it’s very convenient
if you still don’t understand, then ask what exactly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question