Keep a record the 'latest' or 'live'

Alien777
10-22-2004, 03:08 AM
My database has 2 tables namely: STANDARDSET_HEADER and STANDARDSET_DETAIL.
STANDARDSET_HEADER consists of the following fields:
ID Autonumber
FishSize int
Skinning int
CuttingPattern int
CutSet int
Created DateTime

STANDARDSET_DETAIL consists of the following fields:
Id Autonumber
Header int
Material int
Percentage decimal(10,2)
Manhours decimal(10,2)

STANDARDSET_HEADER links to STANDARDSET_DETAIL via id and header.
Now I need to indicate which 'StandardSet' is the latest or the 'available' one. The standardsets are updated every few days so that when the data is captured it can use the latest standard without any explicit user intervention. There are a maximum of 12 different fish sizes. There will be at most 2 live standardsets per fishsize at any time (1 for day shift and 1 for night shift). I need to make a few changes to STANDARDSET_HEADER to help me achieve this. Any help or suggestions will be appreciated.

phunkydude
10-22-2004, 05:42 AM
Yoh Alien777 (Namibia calling Cape Town)...

I don't know what you mean by There will be at most 2 live standardsets per fishsize at any time (1 for day shift and 1 for night shift), but the easiest would be to use a TIMESTAMP field that is updated to the datetime of the latest edit.

I also think that an autonumber field is a bit of an overkill for a max of 12 records, but that is another discussion :cool:

Alien777
10-22-2004, 06:42 AM
Yo phunkydude, How is 'nam today?
What I mean by
There will be at most 2 live standardsets per fishsize at any time (1 for day shift and 1 for night shift).
Is that if a fishsize 1 is the live standardset for that fishsize, and another size 1 has to be added they will both be the live standardset for that size. But if another standardset gets added for size 1 then it will be the latest and one of the other standardsets will not longer be the latest. The thing is if a standardset changes the values will not be updated, a new record will simply be added to the table. This table will grow as time goes on.

phunkydude
10-22-2004, 06:56 AM
Well, then you've already got the solution with the Created_DateTime field.

Enjoy your weekend in Cape Town, Windhoek sucks on the social scene! :D

MKoslof
10-23-2004, 09:15 AM
I am somewhat confused by the question. In order to track records, you have two viable options given your current table structure. Your autonumber fields and your date stamps. To return the last record entered, you can return the MAX() date or the Max() autonumber field..this would indicate (not taking into account any records that have been deleted..that would take some more digging) the last record entered into the database based on the current data validation methods you have.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum