F
F
Forever Extreme2021-02-03 15:32:05
Database design
Forever Extreme, 2021-02-03 15:32:05

How to organize a database with real estate?

Hello! Prompt as it is correct to organize a DB of the real estate. We have a building and we have a room.
For example, a skyscraper is a building, and apartments in it are premises.
A business center is a building, and the offices in it are rooms The
question is how to properly organize tables Because there can be many rooms in one building. It turns out 2 tables.
" Buildings " and " Premises ". The premises have a buildingID field .
Do I need to store multiple roomIDs in the Buildings table ?
Buildings have several properties. For example, number of storeys and year of construction. Everything is simple here. And what about the material of the walls. Brick there or panel (the list of options is strictly limited to avoid "brick", "brick", "BRICK"). Need a separate " Wall Material " table with a list of values? And in the " Buildings " table, you just need to write the materialWallID ?
And there are many similar ones.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Glebov, 2021-02-11
@GLeBaTi

Здания {
 ID: (guid или int32) PK
 МатериалСтен: byte (enum)
 Этажность: byte
 ГодПостройки: int16
}
Помещения {
 ID: (guid или int32) PK
 ЗданиеID: (guid или int32) FK
 Номер: int16 (или строка если будут буквы ещё)
}

The material of the walls can be made simply by a number (enumeration).
If you plan to add materials constantly, then you may need a separate table so as not to recompile the program every time, but to take materials from the database.
The type of columns depends on the range within which the values ​​will be. Each database has its own types.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question