Hi Friends,
I am trying to get my hands on SQLSERVER - am a newbie- and wanted some direction on how to properly setup my three tables:
Table1 : Employee Records
EmployeeID auto Identity,
First_name char,
Last_name char,
DateOfHire datetime (and many more fields)
Table2 : Unprocessed salary records (accepts raw data which is processed and stored in a history table)
(EmployeeID,PayItem) compined must be unique.
EmployeeID, (necessary on this one or I introduce a surrogate PK?)
StaffNumber char, (this takes different formats and can change)
PayItem char,
ReferenceID char,
amount float, (and some other fields)
Table3 : Processed data - Historical
(EmployeeID,PayItem,Period) compined must be unique.
EmployeeID, (necessary on this one or I introduce a surrogate PK?)
PayItem char,
Period char, (eg 2013-01, 2013-02 etc)
Amount float (and some other fields)
For the purposes of reference, would I need a separate primary key on Table2 & Table3?
Or can I use composite (EmployeeID,PayItem)?
If composite is 'expensive', (data will really grow), how do I structure Table3?
Table2 & Table3 will refer to Table1 for staff details but will no be refered to for anything.
My questions may not well structured but I hope someone understands what I need.
Kindly assist as I am new and just making some effort to establish good practices. (ORM is fully in mind.)
Thanks alot.
Benson
I am trying to get my hands on SQLSERVER - am a newbie- and wanted some direction on how to properly setup my three tables:
Table1 : Employee Records
EmployeeID auto Identity,
First_name char,
Last_name char,
DateOfHire datetime (and many more fields)
Table2 : Unprocessed salary records (accepts raw data which is processed and stored in a history table)
(EmployeeID,PayItem) compined must be unique.
EmployeeID, (necessary on this one or I introduce a surrogate PK?)
StaffNumber char, (this takes different formats and can change)
PayItem char,
ReferenceID char,
amount float, (and some other fields)
Table3 : Processed data - Historical
(EmployeeID,PayItem,Period) compined must be unique.
EmployeeID, (necessary on this one or I introduce a surrogate PK?)
PayItem char,
Period char, (eg 2013-01, 2013-02 etc)
Amount float (and some other fields)
For the purposes of reference, would I need a separate primary key on Table2 & Table3?
Or can I use composite (EmployeeID,PayItem)?
If composite is 'expensive', (data will really grow), how do I structure Table3?
Table2 & Table3 will refer to Table1 for staff details but will no be refered to for anything.
My questions may not well structured but I hope someone understands what I need.
Kindly assist as I am new and just making some effort to establish good practices. (ORM is fully in mind.)
Thanks alot.
Benson