Database help

  • Thread starter Thread starter Hayden Kirk
  • Start date Start date
H

Hayden Kirk

Hi,

Having issues designing something in a database. I'm trying to make a
customer table. Problem is I am trying to determin if they are contacts or
busineses.

Like, I want to be able to bill individual clients as well as businesses but
If I do this there will be redundant data.

The solution I came up with was a customer table having two fields.
CustomerID and BusinessID. If the contact has one or the other read from
that table to workout what type of customer they are.

Is this the best way of doing it?
 
Hello,

I agree with you. You have also the problem "what will you do if both ID are
empty". Because you have to allow null values to do so. Not good...

I would add tables to do this.

Customers
ID
Type
ForeignKey on Contact or Business (or 2 keys if you prefer, but you can
use the smae key type for both)
Other Datas

Contact
ID
Other Data

Business
ID
Other Data

If you have individuals frome business, you can also add Adress table and
point to the table with a foreign key.

Look like you should use google a little bit and search for Relational
Database.

Ornette.

Eliyahu Goldin said:
What will you do if for whatever reason both id fields will have values? I
would prefer having just one id field and a separate field "CustomerType".

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Hayden Kirk kirk mobilepc.co.nz> said:
Hi,

Having issues designing something in a database. I'm trying to make a
customer table. Problem is I am trying to determin if they are contacts
or busineses.

Like, I want to be able to bill individual clients as well as businesses
but If I do this there will be redundant data.

The solution I came up with was a customer table having two fields.
CustomerID and BusinessID. If the contact has one or the other read from
that table to workout what type of customer they are.

Is this the best way of doing it?
 
Back
Top