Answer the question
In order to leave comments, you need to log in
Database architecture how to do better?
Now I am writing an application that uses MySQL.
There are tables:
Table: ad_table
Field: ad_id
Field: image
Table: options
Field: opt_id
Field: opt_name
Field: opt_value
Hashed image names separated by commas are added to the ad_table table in the image field:
5711c0e7a3c6b0de576cc8077e2f3e0e.png,
f1b3ec0cc3e96f05721b3d5f565d8fc0.png
red, blue, green
Answer the question
In order to leave comments, you need to log in
In general, the 1st option is suitable.
Just add options: ad_id to the table (if I understand correctly, these are ad block options, right?)
Read about normal forms, look for examples, ask the teacher to explain to you on the fingers
.
ad:
id - PK
...
ad_image:
id - PK
ad - FK(ad)
image_name - TEXT
option:
id - PK
name - TEXT
ad_option_value
id -PK
ad_id - FK(ad)
option_id - FK(option)
option_value - TEXT
or you can use MongoDB and store all parameters with properties in one document (string). without JOINs and normalization (almost). Of course, with its pitfalls.
storing values in the fields separated by commas and parsing them on the fly is the essence of raking the floor. Add such lines a couple of million and try to make a selection. You won’t even need to explain anything, the rake will fly in and explain everything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question