I have to create a database of real state for sale. Problem is the kind of properties: if I have a house, I have a kind of description, but if it is just a land, the descriptions does not need to include number of bathrooms, just the area, front range, etc.
So I did a table with generic data about the element (imoveis) with address, price etc.. Than I created categories of elements (imoveis_categs). I did 5 categories, for each category, there will be a table (e.g.: imoveis_descr2) with the specific features of the kind.
To enter data it's easy, but to list my data, I will need to perform query select to find those elements according with some filters. In PHP will be easy to solve, but I am wondering about the performance for a large amount of data and users requests. Better solve it by SQL commands, thought. But mySQL is not my area, I imagine something like this to start...
SELECT * FROM imoveis INNER JOIN imoveis_descr(imoveis.categ) ...
The "categ" field of imoveis point to the right description table. It is possible to do something like this? Is there another way more appropriate or efficient to do it?
EDIT: I tryed to clarify with an example... EDIT2: I corrected the example, the column "rooms" will be the same. The fields are not exclusives, both apartment and house categories have number of rooms.
Table imoveis
id categ title price address ...
1 2 The House $ 1000000 Somestreet 77
2 1 An Appartment $ 500000 Somewhere 11
3 4 A Land $ 250000 Nowhere 33
Table imoveis_descr1
idImovel rooms area floor ...
2 2 70 5
Table imoveis_descr2
idImovel rooms fieldArea constrArea ...
1 3 120 80
Table imoveis_descr4
idImovel area width height ...
3 2640 22 120
Result
id categ title price address rooms fieldArea constrArea area floor area width height
1 2 The House $ 1000000 Somestreet 77 3 120 80 null null null null null
2 1 An Appartment $ 500000 Somewhere 11 2 null null 70 5 null null null
3 4 A Land $ 250000 Nowhere 33 null null null null null 2640 22 120