Click here to Skip to main content
16,005,222 members
Home / Discussions / Database
   

Database

 
Questionalter an identity Pin
Rupa Kalluru4-Dec-06 23:28
Rupa Kalluru4-Dec-06 23:28 
AnswerRe: alter an identity Pin
JeganB5-Dec-06 1:38
JeganB5-Dec-06 1:38 
Questionexport OLAP in SSAS 2005 to excel pivot table Pin
remex_1980_junyongwu4-Dec-06 22:14
remex_1980_junyongwu4-Dec-06 22:14 
QuestionRetrieving connection string Defined in Web-Config Pin
mohd imran abdul aziz4-Dec-06 18:07
mohd imran abdul aziz4-Dec-06 18:07 
GeneralRe: Retrieving connection string Defined in Web-Config Pin
Guffa4-Dec-06 18:32
Guffa4-Dec-06 18:32 
GeneralRe: Retrieving connection string Defined in Web-Config Pin
mohd imran abdul aziz4-Dec-06 19:02
mohd imran abdul aziz4-Dec-06 19:02 
AnswerRe: Retrieving connection string Defined in Web-Config Pin
Steven J Jowett5-Dec-06 10:42
Steven J Jowett5-Dec-06 10:42 
Questionplease help - database design [modified] Pin
michal.kreslik4-Dec-06 15:09
michal.kreslik4-Dec-06 15:09 
Hello,

I'd appreciate if someone could kindly help me with the following database design issue. I've already solved it, but my solution is not much elegant. I'm working on this SQL database for one of my friends. It will make her work more efficient since she's currently dealing with a tangled up set of excel tables.

The database will hold various data for several thousand employees. This would be a piece of cake, but we also need to track the changes of those data values in time. For example, we need to know that John Smith was in Quality Department in October, but since November, he's been in Services Department, etc.

Having a separate "historical data states" table for each employee (or, alternatively, for each data type) is not a good idea, so I designed a simple table named "TimeTableItem" that stores:
- a link to the table that holds table.column names (for instance "19" for dbo.Department.DepartmentID table) to which the current row relates ("TimeTableDataTypeID" column below)
- and an ID of the related value itself (for example, "7" for Services Department within the Department table - "TimeTableDataValueID" column below)

The actual table design:
- TimeTableItemID (PK, int, not null)
- PersonID (FK, int, not null)
- TimeTableDataTypeID (int, not null)
- TimeTableDataValueID (int, not null)
- StartTime (dateteime, null) (null is treated as "from the beginning of time" Smile | :)
- EndTime (datetime, null) (null is treated as "forever" Smile | :)
- CreatedOn (datetime, null)
- ModifiedOn (datetime, null)

Obviously, the PersonID is a link to the Person table. By the same token, StartTime and EndTime define in which time span the data for the particular person is in effect, CreatedOn and ModifiedOn denotes these self-explanatory timestamps.

The trouble with this kind of design is that we don't know beforehand to WHAT employee data (Department? Position? Salary band?) will the next row be related, so we can't set a relation between the tables here (we dont' know what will the other table be). This means that there's no way to set a foreign key constraint on a column that holds the VALUE of the related data element. This is not much consistent and might lead to a situation when my friend deletes a department from the departments table that is used somewhere else. This will result in orphaned rows.

Is there any way to solve this efficiently?

Thank you for any input,
Michal



-- modified at 21:14 Monday 4th December, 2006
AnswerRe: please help - database design Pin
Colin Angus Mackay4-Dec-06 23:33
Colin Angus Mackay4-Dec-06 23:33 
GeneralRe: please help - database design Pin
michal.kreslik5-Dec-06 3:24
michal.kreslik5-Dec-06 3:24 
QuestionSQL Select query for different combination of arguments Pin
steve_rm4-Dec-06 14:05
steve_rm4-Dec-06 14:05 
AnswerRe: SQL Select query for different combination of arguments Pin
Eric Dahlvang5-Dec-06 9:47
Eric Dahlvang5-Dec-06 9:47 
QuestionReading SQL return messages from .NET Pin
iammudman4-Dec-06 4:49
iammudman4-Dec-06 4:49 
AnswerRe: Reading SQL return messages from .NET Pin
Scott Serl4-Dec-06 6:32
Scott Serl4-Dec-06 6:32 
QuestionParsing very large file-low virtual memory error Pin
amnaahmad4-Dec-06 1:04
amnaahmad4-Dec-06 1:04 
AnswerRe: Parsing very large file-low virtual memory error Pin
Frank Kerrigan4-Dec-06 3:11
Frank Kerrigan4-Dec-06 3:11 
GeneralRe: Parsing very large file-low virtual memory error Pin
amnaahmad4-Dec-06 18:11
amnaahmad4-Dec-06 18:11 
GeneralRe: Parsing very large file-low virtual memory error Pin
amnaahmad4-Dec-06 18:34
amnaahmad4-Dec-06 18:34 
AnswerRe: Parsing very large file-low virtual memory error Pin
Scott Serl5-Dec-06 7:17
Scott Serl5-Dec-06 7:17 
QuestionODBC Connection and Excel Spread Sheet Pin
Cristoff4-Dec-06 0:56
Cristoff4-Dec-06 0:56 
AnswerRe: ODBC Connection and Excel Spread Sheet Pin
Frank Kerrigan4-Dec-06 3:13
Frank Kerrigan4-Dec-06 3:13 
GeneralRe: ODBC Connection and Excel Spread Sheet Pin
Cristoff4-Dec-06 4:04
Cristoff4-Dec-06 4:04 
GeneralRe: ODBC Connection and Excel Spread Sheet Pin
Frank Kerrigan4-Dec-06 5:52
Frank Kerrigan4-Dec-06 5:52 
GeneralRe: ODBC Connection and Excel Spread Sheet Pin
Scott Serl4-Dec-06 6:53
Scott Serl4-Dec-06 6:53 
GeneralRe: ODBC Connection and Excel Spread Sheet Pin
Cristoff5-Dec-06 1:33
Cristoff5-Dec-06 1:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.