When to use address table in database

Asked

Viewed 8,689 times

3


I’m developing a system where several entities will have address.
Example: the school has address, the student has address, the teacher has address, the suppliers have address and etc.
I’m willing to use a table to store every address used in the system. And then, every time I need an address, I will refer to it by its id in the address table.
Considering that the system is not very large, this would be a good way to work with addresses?
What was sounding bad, was all these entities having the fields: city, neighborhood, state and etc.
There is some better implementation of the entity address in this case?

  • 2

    http://answall.com/questions/22069/quando%C3%A9-interesting-denormalize-the-database/22120#22120 Are you making a system for your Manuel’s bakery or a Mega Hyper ERP? This makes all the difference.

  • It is not enough to be a HYPER ERP. But an ERP in initial state. And it will not be so giant.

  • In this case it is because it is common brothers in the same school and teachers have children studying there. Address as an entity in my opinion only when it is relevant to the application.

2 answers

5


In my opinion, the best option is to have an address-only table, which relates to a neighborhood table which relates to a city table and which ultimately relates to a state table.

Entities that have addresses would have an n-to-n relation to the address table. In the figure below you can better understand.

inserir a descrição da imagem aqui

1

You should create a table of people where each person has (in addition to their personal data such as name and personal documents) their block, lot, house number and street name or avenue. The neighborhood would be the id of another neighborhood table where within the neighborhood table would have the city id of the neighborhood and then within the city table would have the city state id. So it would be easier to not have duplicated data because it could check the block, plot, neighborhood, street name. The person could be anything within the system as supplier, customer, employee, etc.inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.