I want to create a small invoicing application. My first step is creating a database with two tables where each client can have multiple addresses and phone numbers.
I think its safe to assume here that I am dealing with a one to many relationship. But how should I design the tables and fields so they can store multiple addresses and phone numbers per user? By multiple I also mean indeterminate since so I can’t just have x no of columns in my table. Off Hand, here is what I was thinking:
Clients
- Id
- Notes
CONTACTS
- id
- client_id
- address
- phone number
Now I am trying to avoid a third join table like this:
Clients_Contacts
- id
- client_id
- contact id
because I still want a one to many and not many to many relationship between contacts and clients. Is there something wrong with the way I am thinking about this? Can someone please help me design this database and show me what a sample query querying multiple addresses would look like.
Why would you nead a join table?
I would have
Then just set the ID of the client to be the value of client_id within the contact information.
This way, multiple Contact records can have the same client_id.