CodeIgniter Forums
DB design help - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: DB design help (/showthread.php?tid=73800)



DB design help - neuron - 06-07-2019

Hi,

I am building a web project for a leasing company.
Leasing company's customer can be both a person or a company.
if customer is a company then it has Authorized representers (can be more than one representer) which.

I can't find a proper DB table structure to meet this needs.

Any help is appreciated...
Thanks


RE: DB design help - kilishan - 06-07-2019

You could have a customer table that has nullable user_id and [b]company_id[/id] columns. Fill in the one that's relevant and leave the other blank and build logic out from there.


RE: DB design help - albertleao - 06-07-2019

I would create a users table and companies table. That gives you the flexibility of handling multiple users per company if that ever arises.


RE: DB design help - neuron - 06-07-2019

(06-07-2019, 07:18 AM)kilishan Wrote: You could have a customer table that has nullable user_id and [b]company_id[/id] columns. Fill in the one that's relevant and leave the other blank and build logic out from there.

Thank you for you advice. This is the solution I came up with, but was not sure about it. Now you confirmed it, I can go on with it.
thanks Smile


RE: DB design help - badger - 06-07-2019

this might help. our customers are a mixture of companies and people. A company usually has more than one contact. Our customer table is a list of names with a linked list of contacts each with a statusID of mainContact, accountsContact or otherContact. The statusID is very useful because in many companies, the people who order are not those who handle payments so monthly statements go automatically to the email of the accountsContact. You might find it odd but the address field is in the contacts table alongside the name, email, phone, mobile fields because some companies have multiple delivery addresses. when the mainContact is updated, it updates the corresponding entry in the customers table
Bill


RE: DB design help - InsiteFX - 06-09-2019

Here are a couple of web sites that may be of help.

Database Answers - Database Models

MySQL Sample Databases