How to name a column in a database table that contains a version number

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, .

+3
6

, " = 1" - , , . , , . , , , , .

version_id, . , , order by version_id desc .

: datawarehousing, iandisme. , , , . , Record, RecordVersion . , , , , .

+3

, , , , , TimeStamp .

, , , .

, id + 1 :

  • ,
    • ,
+2

, RecordCreated ?

- :

select top 1 columna, columnb, etc. from table order by RecordCreated desc

, .

( , ..).

: http://msdn.microsoft.com/en-us/library/aa213033(SQL.80).aspx

: http://blogs.digineer.com/blogs/jasons/archive/2009/02/25/monitoring-index-contention-with-dmfs.aspx

, - , ( ..). , , , , view/snapshot/etc. .

+1

, , , , RecordAge. , , , , , .

/. , , .

, .

, , . ( , , ), , , , .

, , , , , .

0

, , , , . , , recordOrder , , , , . , , , , , .

, ( ). , , id desc , ? , , .

0

Raj . , .
: ( ) , , .
NewRecord = 1, = NUll. , , ?
.

0

Source: https://habr.com/ru/post/1727805/


All Articles