Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Improving table structure

Author  Topic 

swethapal5k
Starting Member

1 Post

Posted - 2010-01-13 : 17:20:32
I have following SQL tables. All employee_id fields are foreign keys to employee.employee_id



employee

Firstname varchar(20)

Lastname varchar(20)

Employee_id int



Salary

Employee_id int

Pay float



Person

Employee_id int

Person_id int


In this Can the table structure above be improved? If so, how and what benefits would this bring? Would i lose any functionality by doing this? (give a new table listing if you do change it)

queenofcode
Starting Member

6 Posts

Posted - 2010-01-13 : 18:08:39
If the relationship between employee and salary is one-to-one, there is no need to hold it in a seperate table. You can add the pay rate to the employee table. No functionality should be lost. This will incres performance becase you wouldn't have to join tables together to get the data.
Modified structure:
employee
Firstname varchar(20)
Lastname varchar(20)
Employee_id int
Pay float

Person
Employee_id int
Person_id int

Any modification of the structure regarding the Person table would be dependent on the purpose of said table. Does John Doe have an employee and a person record and this table stores the two? Or does person_id relate to a completely different person than John Doe?

<geek> The Self-Proclaimed Queen of Code :) </geek>
Go to Top of Page
   

- Advertisement -