When to use address table in the database

3


I'm developing a system where multiple entities will have address.
Example: the school has an address, the student has an address, the teacher has an address, the providers have an address, etc.
I am trying to use a table to store every address used in the system. And then, every time I need an address, I'll refer to it by its id in the address table. Since the system is not very large, would this be a good way to work with addresses? What was sounding bad, it was all these entities having the fields: city, neighborhood, state and etc.
Is there any better implementation of the entity address in this case?

    
asked by anonymous 07.10.2014 / 17:47

2 answers

5

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

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

    
07.10.2014 / 18:21
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 the name of the street or avenue. The neighborhood would be the id of another table neighborhoods where inside the table neighborhoods would have the id of the city of the neighborhood and then inside the table city would have the id of the state of the city. So it would be easier to not have duplicate data because you could check the block, lot, neighborhood, street name. The person could be anything within the system as a supplier, customer, employee, etc.

    
09.08.2017 / 16:12