Answer the question
In order to leave comments, you need to log in
How are databases designed for such sites?
Let's say there is a site for the sale of apartments. There, each apartment has a bunch of information that needs to be stored in the database, well, the question itself, how to store it correctly, I did like this prntscr.com/e4fvbp . But I thought to store everything in a json array, also in the database, but you don’t need to create 10 fields for each characteristic.
Maybe I'm doing something wrong or learning old material?
Maybe there is a more modern approach to this task in 2017?
Answer the question
In order to leave comments, you need to log in
How are databases designed for such sites?
Nothing is clear, "Address" has several addresses for one apartment, or is it "Addres"?
If there is only one address, and it is not required to separately store each street, house, etc., then there is nothing to change here, really varchar or text, and if we allow a lot, then either you need to create another table of addresses and link it, or store it as an array JSON, the second one is easier.
But the sections should be taken out into a separate section table and linked through FOREIGN KEY, unlike many-to-many relationships, a foreign key is implemented much easier, both in the database itself and in MVC frameworks.
Also, why everywhere varchar(200)
, if you want to initially have maximum flexibility, and optimize as needed, then it’s better TEXT
then.
And a trifle: the names of the columns, if the project is only yours or you are the main developer, then this is at your discretion, but usually a full-fledged translation is used instead of transliteration.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question