Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQL Design Question Expand / Collapse
Author
Message
Posted Friday, April 25, 2014 6:38 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, May 7, 2014 7:04 AM
Points: 37, Visits: 103
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.
Post #1565055
Posted Friday, April 25, 2014 7:04 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, October 12, 2014 4:00 PM
Points: 341, Visits: 751
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".
Post #1565077
Posted Friday, April 25, 2014 8:22 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 6:00 PM
Points: 3,783, Visits: 8,485
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.
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?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1565113
Posted Friday, April 25, 2014 8:25 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, August 26, 2014 10:44 AM
Points: 48, Visits: 157
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.
Post #1565115
Posted Monday, April 28, 2014 4:34 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 6:53 AM
Points: 13,890, Visits: 28,285
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
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1565507
Posted Tuesday, April 29, 2014 7:31 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, October 22, 2014 6:33 AM
Points: 70, Visits: 254
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.
Post #1565914
Posted Wednesday, April 30, 2014 7:16 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 6:22 AM
Points: 920, Visits: 1,437
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



Post #1566379
Posted Wednesday, April 30, 2014 11:00 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:50 PM
Points: 14, Visits: 199
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).

Post #1566509
Posted Wednesday, April 30, 2014 11:09 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 6:53 AM
Points: 13,890, Visits: 28,285
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
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1566514
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse