Welcome Guest, Not a member yet? Register   Sign In
Help with db table structure

I am planning db structure for my new project. And i would like to ask your advise to following problem.
Firstly i have table companies. It is basicaly the main table to which others will be linked to. It will store company name, registration number, description and other fields describing it.
Then i have table company_branches which stores company_id and it's name. I created new new table for them (instead of just making parent_id column in companies) because their all share parent companies regsitration nr., VAT nr, juridical address and other data. They just have their own contact information, such as, emails,phone numbers, addresses. So now i need to create table contact_information which will store it, but companies(branch parent) also has same contact information.. How to link contact_information with both tables? Or should i create diferent structure for this ? Hope i made myself clear and you understood my problem Smile

It sounds like you have merged two items: (legal) business and offices.

I would have a businesses table, with registered name, VAT number etc and then a separate offices table, which lists only address information.

Then you have one business entry, and several offices entries including your head office linked to that business. If required, you could mark one as the head office with a flag. Perhaps instead of head office, you would flag registered office, so that you know that address is the one where the business is legally registered.

It's not far off what you suggested, but tries to clearly define and normalise the relationship.

Thanks, such structure i also had in mind. Implemented it, works fine for now.

Theme © iAndrew 2016 - Forum software by © MyBB