![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am rather new to databases and do not have much idea about application specific sql functionality. I have to implement a ranking system for which the details are as follows: Each tuple in a table has an attribute whose value is modified at frequent intervals. After a certain span of time, the tuples in the table are to be arranged in the order of the attribute. However after sorting the tuples, a rank must be assigned to each tuple depending upon the position in the sorted table. This rank is stored in a separate attribute in the same table. Can someone guide me on implementing this model in a MySql database. Also if it is easier, in the Oracle database. |
|
... an attribute whose value is modified at frequent intervals. |
|
... After a certain span of time, the tuples in the table are to be arranged in the order of the attribute. However after sorting the tuples, a rank must be assigned to each tuple depending upon the position in the sorted table. This rank is stored in a separate attribute in the same table. |
#3
| |||
| |||
|
|
Each tuple in a table has an attribute whose value is modified at frequent intervals. After a certain span of time, the tuples in the table are to be arranged in the order of the attribute. However after sorting the tuples, a rank must be assigned to each tuple depending upon the position in the sorted table. This rank is stored in a separate attribute in the same table. |
#4
| |||
| |||
|
|
On Aug 30, 2:10 pm, Sameer <sameervijay... (AT) gmail (DOT) com> wrote: I am rather new to databases and do not have much idea about application specific sql functionality. I have to implement a ranking system for which the details are as follows: Each tuple in a table has an attribute whose value is modified at frequent intervals. After a certain span of time, the tuples in the table are to be arranged in the order of the attribute. However after sorting the tuples, a rank must be assigned to each tuple depending upon the position in the sorted table. This rank is stored in a separate attribute in the same table. Can someone guide me on implementing this model in a MySql database. Also if it is easier, in the Oracle database. First off, TABLES ARE NOT SORTED. Table repesent Sets of data. Sets are UNORDERED collections. Separately from that issue, such ranking is really an attribute of a reporting application. I think it is a poor idea to store the rank in the table, especially as it depends on ... an attribute whose value is modified at frequent intervals. lets assume this interval is one minute. Then your second requirement: ... After a certain span of time, the tuples in the table are to be arranged in the order of the attribute. However after sorting the tuples, a rank must be assigned to each tuple depending upon the position in the sorted table. This rank is stored in a separate attribute in the same table. Lets assume this "span of time" is 5minutes. That means for the minute after the rank is assigned it is correct. Then the attribute is updated on one or more rows and likely at least two of the rows have the wrong rank. So for the other 4minutes the ranking is wrong. That means 80% of the time your table has the wrong ranking! So two things: 1. consider creating a view, which computes the rank when needed (ie when queried) 2. in Oracle the view can use the RANK operation (see Analytic Functions). I have no idea if MySQL supports this feature. |
![]() |
| Thread Tools | |
| Display Modes | |
| |