I have some doubts about how to propose the structure of a database, the dilema is if I have to store serialized data or it's better to make a table with relational fields.
An example of that is to supose that application:
I am currently proposing a structure in which we have:
Well, inside the table "course_has_inscriptions", we have the fields:
The array looks like this:
$quotas = [];
$quotas ['2022-01'] ['value'] = 200
$quotas ['2022-02'] ['value'] = 200
$quotas ['2022-03'] ['value'] = 200
Are there any advantages if instead of doing so I do it inside another relational table of the type "quotes" where I store:
Thank you
Always choose the easier option, which is another table. This is easier because the data is easier to access. If you serialize the data you would have to retrieve it and unserialize before you can use it, if you use another table you can simply retrieve and use it. You can actually use the power of MySQL queries.
Think about it. For instance, later you will make a table containing the payments and you want to check whether people paid what they needed to pay. If you serialize the data you cannot do that with MySQL, you are forced to do it in PHP, which is not what you want.
People, who have encountered this problem many times, have summarized their experience in a couple of rules. They call this data normalization .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.