I am trying to create a database for a limousine company, and I am stuck on how much normalization I should do for Addresses related to clients, drivers, branches and orders.
Basically, the addresses of partners and drivers are as follows: address_line_1, address_line_2, city, state, zip code, country
My problem comes from orders and customer addresses. They should look like this: address_line_1, address_line_2, city, state, zipcode, country, address_type_1 (home, business), address_type_2 (pick-up, drop-off - this should only be turned on for orders).
Thus, between all four tables, I have similarities in the address fields, with the exception of two fields that differ in the table of customers and orders.
I need to note that each record will be identified with unique identifiers. Example:
Customer ID - 10,000 - 99,999
Order ID - 100,000 - Unlimited
Driver ID - a1 - a999 (possible)
Partner Id - 1,000 - 9,999
These are just examples, so don't spend a lot of time understanding them.
How many address tables should I use to create a good normalized database?
At this moment, I have three thoughts:
One address table with all fields included, plus additional information describing the type of address (customer, order, partner, driver). This is actually not the case.
Two address tables. One with drivers and branches, one with customers and orders. For the second table, I would have a field that will always be NULL for clients. Don't like this one either.
Three address tables. One for drivers and branches, one for customers and one for orders. No unused fields make me think this might be a better option than the other two.
Does anyone have any advice on these three options, or perhaps even a better option?
Many thanks.
UPDATE:
Do not worry about the numbering system for the table identifier. It was just an example. I have not yet managed to figure out the best numbering system. Let's go to this as soon as I find out that the address problem is fixed.
From Matt's answer, I am tempted to leave the driver and affiliate tables with addresses included and just sort the customer and order tables somehow.
For clients, I definitely need an address table, because a client can have several addresses (home, business1, business2, favorite places, etc.) that I want to save in my profile for easy access.
I forgot to mention something about the order table, which can slightly change the equation of the problem. For any order I need to have PICK-UP and DROP-OFF. But it can be an address (street address) or an airport. This means that the fields associated with the street address cannot correspond to the fields indicated at the airport. Therefore, I am sure that in order to have four objects (pu_address, pu_airpot, do_address, do_airport) inside the table (all with their specific field), I would leave unused space and programming confusion. Example: for pickups: Address_type, Address_line_1, ..., state, country, airport, airline, Flt no, ... and discard the same thing as the pickup.
Therefore, I still have a problem with the order table, for which I am not sure how to move forward. I need both addresses, as well as pick-up and drop-off points at the airport, which will be included with or without additional tables.
UPDATE Thanks again. Firstly, yes, I will keep the addresses in separate fields. The problem remains for orders. I will give an example about what type of PU and use a limousine. Address: 123 Main St, Chicago, Il, 60640; Airport: ORD, AA, 123. I need all these fields to be somehow integrated into the table.
Parameters: order table
order_id, ..., fields for receiving, which should have fields of airports and addresses, fields for drop-down fields with fields of airports and addresses.
This option still doesn't sound right.
Next, you need to have two additional tables. One of them would be for addresses (including a pickup or pickup recognition field). Another will be for the airport (with a field for pu or do too).
I also do not like this parameter, because I will need to make two requests to get information only for recording an order. First, I will receive information about the order, and after I find out the type of pick-up and drop-off (airport or address), I would make another request to get information about a specific pickup and drop-off.
So again ... what am I doing wrong? Did I miss something?
And yes, I will definitely use some verification system to make sure the addresses are correct.