Primary/Foreign Key question.

First off I would like to thanks any of those who offer any suggestions.

Here is the scenario. I have a table that has a primary key that is made up of 2 timestamps and a sequence number (numbers can be repeated that but not for the given time frame). In a second table I have reference to the the other table (or at least I want to). In the second table I need 2 timestamps and 2 sequence numbers.So here is the columns and some fake data to show what I need to do. The main question is can I make the primary in the original table out of the 2 times and the sequence number, but make the foreign key out of the timestamps and 2 sequence numbers, or should I just assign an integer (a Unique key?) to Table1 and just Reference that in table2. Only problem I will have is that as you can see the start and end times can overlap in the 2nd table (not necessarily though). The reason I ask is because I just wanted to automate the Deletes and updates, if I need to I can leave the tables un refeerenced (directly) to each other and take care of it in code. Just wondering what might be the best approach to this.

StartTime EndTime Sequence
20050101000001 20050101000010 1
20050101000201 20050101020001 2
20050101234501 20050102000005 3
20050103000001 20050104000001 1
20050104004500 20050104010000 2

StartTime StartSeq EndTime EndSeq
20050101000001 1 20050101000010 1
20050101000001 1 20050102000005 3
20050101234501 3 20050104010000 2

Thanks Again.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!