I am trying to figure out how to call a column in my database table that contains an INT for a particular “record”. I am currently using " RecordOrder ", but I do not like it because people think higher = newer, but as I use it, lower = newer (with "1" is the current record, "2" is the second largest, "3" is older and so on). I read " RecordVersion ", but I'm afraid this problem will have the same problem. Any other suggestions? " RecordAge "?
I do this because when I insert into the table, instead of finding out which version is next, then risk getting the number stolen from me before I write, I just insert the insert using "RecordOrder" "of 0. There there is a trigger in the AFTER INSERT table that increases all the “RecordOrder” numbers for this key by 1, so the record I just inserted becomes “1” and all the others increase by 1. Thus, you can get the current person record optionally RecordOrder = 1, instead of getting MAX (RecordOrder), and then selecting this.
PS - I can also criticize why this is a terrible idea, and I should increase this figure. It just showed that the search is much easier, but if this is a bad idea, please enlighten me!
Some data information is provided as an example:
I have the following database table:
CREATE TABLE AmountDue (
CustomerNumber INT,
AmountDue DECIMAL(14,2),
RecordOrder SMALLINT,
RecordCreated DATETIME
)
A subset of my data is as follows:
CustomerNumber Amountdue RecordOrder RecordCreated
100 0 1 2009-12-19 05:10:10.123
100 10.05 2 2009-12-15 06:12:10.123
100 100.00 3 2009-12-14 14:19:10.123
101 5.00 1 2009-11-14 05:16:10.123
In this example, for client 100, there are three lines — they owe 100 dollars and then 10.05 dollars, and now they owe nothing. Let me know if I need to clarify this yet.
UPDATE:
"RecordOrder" "RecordCreated" - , . , , . , "Record Version" RecordCreated, , , RecordOrder = 1 , MAX MIN DateTime, .