Wednesday, March 7, 2012

Company with Address Question

I have a database that allows a client to have multiple addresses, could be a home, business, vacation, etc... I'm trying to deside if I should put the Company Name and Title fileds in the tblClientAddresses table or keep it with the tblClient table. We do mailings to clients and if the mail is going to a home address the company and title should be excluded. If I put them in the tblClients table I really have no way of knowing if we are mailing to a home or a company. If i put the company and title with the address it makes sence that this would solve the issue.

Looking for any thoughts or suggestions?

Thank you,Standard normalization would say if there are multiple addresses per client, put it in a separate table. The only time I would recommend against this is for performance reasons, but I'm guessing you don't have any performance problems yet.|||The Company Name and Title fields belong in tblClient.

You could do something like this to make them blank if the address is a Home address:


SELECT
CASE
WHEN A.type = 'Home' THEN ''
ELSE C.Name
END AS Name,
CASE
WHEN A.type = 'Home' THEN ''
ELSE C.Title
END AS Title,
A.Address1,
A.Address2,
A.City,
A.State,
A.ZIP
FROM
tblClient C
INNER JOIN
tblClientAddress A ON C.ClientID = A.ClientID

As the OP said, though, sometimes you give up correct normalization for performance -- especially if the data is static and the tables are extremely large.

Terri

No comments:

Post a Comment