If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Personal and Company Customers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-13-11, 14:36
infini infini is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
Personal and Company Customers

Hi,

I'm currently working on a project with Mysql and PHP in order to provide basic time entry, invoicing and payroll support for a small company. I'm not very experienced with databse design so i'm strugling with finding the best solution.
So i'm going to define what I think is important about this system. Our small company has customers. These customers can either be a person, or a company. When a tech enters a time entry for work, we associate it with a customer. I have come up a few solutions that in my view is not really optimal but here they are.

Table User
userID
companyID
other fields...

Company
companyID
Name
other fields

Customer
customerID
type[either Business or Personal]
userID[If type is Personal then it looks in this field for the user info]
companyID[If type is business then it looks here for companyID in the company table]

Time Entry
emplyeeID[another table]
customerID[foreign key to customer table]

Now I really don't like having a type field in the customer table, but I can't see any other way to know which table too look into either the user or company without a boolean type telling me which one it should be

The other option was to have a foreign key in the user table and company table linking to the customer table. but that allows a user and company to have the same customer ID. Of course I can restrict that with php or even sql triggers but I'd rather avoid such thing.

As I said I'm really new to database designs so if anyone has past experience with this kind of situation please any input will be appreciated...

Thank you
Reply With Quote
  #2 (permalink)  
Old 07-13-11, 17:51
dportas dportas is offline
Registered User
 
Join Date: Dec 2007
Location: London, UK
Posts: 732
Reply With Quote
  #3 (permalink)  
Old 07-13-11, 20:50
infini infini is offline
Registered User
 
Join Date: Jul 2011
Posts: 2
Still have a question

Thanks that was something I hadn't seen before, but I still dont understand something.

How to actually implement the Party with Person and Organization. I would profit from seeing a actual implementation I think.

but if you can conceptualy go over how it would be implemented that would help as well

Thank you.
Reply With Quote
Reply

Tags
client, company, customer, personal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On