SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SQL Design Question


SQL Design Question

Author
Message
TJT
TJT
SSC-Enthusiastic
SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)SSC-Enthusiastic (174 reputation)

Group: General Forum Members
Points: 174 Visits: 254
Hi,

I am designing a database and would appreciate some thoughts. I am thinking about creating a Telephone table to handle (Tel, Cell, extension, fax) instead of putting it in the employee table.

Any input is appreciated. I am looking for the PROs and CONs of each.
gbritton1
gbritton1
SSChasing Mays
SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)SSChasing Mays (651 reputation)

Group: General Forum Members
Points: 651 Visits: 864
It's likely that there will be a 1x1 mapping between Employee and voice Telephone numbers. So, keeping them in one simple table could be OK. Fax numbers may be another thing. Also, telephone numbers can usually be kept as integers which only take up 4 bytes, though you'll need an algorithm to split them up for display into country code, NPA, NXX etc.

OTOH is there any other info you'd likely keep along with the telephone numbers? e.g. when the number is valid (start and end dates), when time of day or days of the week you can call someone at that number, etc. When things get a little more complicated, it's might be cleaner to have a telephone number table with a FK to the employee id, a number type (landline, mobile, fax, etc), and other things.

Basically, the wider a table gets, the more you should look for opportunities to normalize into two or more tables. It doesn't mean you have to do that. It's just an indication that you should look at it.

The exception would be a Data Warehouse, were denormalized tables are the norm, for faster reporting.

There's not one "correct" answer to your question. Like so many things in the DB world, "it depends".
Luis Cazares
Luis Cazares
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16573 Visits: 19098
I would suggest that you normalize your tables and have an additional table for the telephone numbers.
What would happen if an employee has more than one cell phone? Or several extensions?
If you put them on the employee table as additional columns, you'll have to add enough columns to handle them. If a new type of phone comes up, you'll need to add a new column.
With a normalized table, there's no need to do changes to the schema, just add the needed rows to it.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
SQL is delicious
SQL is delicious
Valued Member
Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)

Group: General Forum Members
Points: 73 Visits: 174
Luis Cazares (4/25/2014)
I would suggest that you normalize your tables and have an additional table for the telephone numbers.
What would happen if an employee has more than one cell phone? Or several extensions?
If you put them on the employee table as additional columns, you'll have to add enough columns to handle them. If a new type of phone comes up, you'll need to add a new column.
With a normalized table, there's no need to do changes to the schema, just add the needed rows to it.


I agree. That's what I'd look at doing in the OP's situation.
Grant Fritchey
Grant Fritchey
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39934 Visits: 32653
I'd have a separate telephone table. That way you can have more than one phone number for any given person AND you can assign a phone number to more than one person. But, in order to support that second idea, you'd have to use an interim table to map between the Person table and the Phone table.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Chris Wooding
Chris Wooding
Mr or Mrs. 500
Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)Mr or Mrs. 500 (550 reputation)

Group: General Forum Members
Points: 550 Visits: 992
I agree with Luis, but it does depend on how your data may expand in the future. We have a CRM application where there are several 'standard' phone numbers for contacts (fax, mobile, home, work direct, work switchboard, etc.) but we have to allow additional number types such as 'Secretary', '2nd home', 'mum' (I kid you not, that is an actual example) which are defined by the user on entry.
Steve-3_5_7_9
Steve-3_5_7_9
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1456 Visits: 1599
gbritton1 (4/25/2014)
It's likely that there will be a 1x1 mapping between Employee and voice Telephone numbers. So, keeping them in one simple table could be OK. Fax numbers may be another thing. Also, telephone numbers can usually be kept as integers which only take up 4 bytes, though you'll need an algorithm to split them up for display into country code, NPA, NXX etc.


Your answer conflicts with itself, as soon as you mentioned "numbers" it became a 1 to many relationship. 1 to 1 doesn't fit. If the business requirement was to only keep one telephone number per customer, then I would agree with keeping the phone # in the main table.


Steve



ErikMN
ErikMN
Valued Member
Valued Member (53 reputation)Valued Member (53 reputation)Valued Member (53 reputation)Valued Member (53 reputation)Valued Member (53 reputation)Valued Member (53 reputation)Valued Member (53 reputation)Valued Member (53 reputation)

Group: General Forum Members
Points: 53 Visits: 429
So to summarize:

Separate (normalized) tables:
PROS:
- Much more flexibility in assigning phone numbers to employees.

CONS:
- Slightly more complicated and slightly more costly to query

One table (denormalized):
PROS:
- Simpler queries
- Slightly faster queries

CONS:
- Little flexibility to add new numbers (requires schema change).
Grant Fritchey
Grant Fritchey
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39934 Visits: 32653
ErikMN (4/30/2014)
So to summarize:

CONS:
- Slightly more complicated and slightly more costly to query

One table (denormalized):
PROS:
- Slightly faster queries



Careful. It's at least partly a myth that denormalized storage is faster. It is easier to write queries against. And if the normalized storage is not enforced through checked referential constraints and/or has improper or missing indexes, it can be slower. But, normalization radically reduces the storage foot print when done correctly and this can increase performance over denormalized storage. It all comes down to how you're querying the data.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search