Re: Sorting functionality




"Ed Prochak" <edprochak@xxxxxxxxx> wrote in message
news:1188587824.812183.139010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 30, 2:10 pm, Sameer <sameervijay...@xxxxxxxxx> 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.


What Ed said. Simplified, this means that it's better under most
circumstances, to order (sort) data at the time of retrieval, and not at the
time of insertion. The "order by" clause of a "select" does exactly this.

However, many times it's advantageous to bear the COST of sorting at
insertion time, because the delay is just too long at retrieval time.
Appropriate index design will accomplish this goal, for the most part. If
there is an index on the table that maintains the data in the order it will
be retrieved, then updating this index will usually incur some cost at
insertion time, but retrieval in the same order as the index will generally
be pretty fast.

It gets more complicated than this, but I wanted to give you an overview.



.



Relevant Pages

  • RE: How EXACTLY does Indexing Service determine rank
    ... the point that they are adjacent becoming a phrase and raising the rank ... The ranking mechanism is weighted so that the more highly inflected ... the linguistic engine and ranking algorithm ... Indexing Service is based on ranking formulas that are used everywhere from ...
    (microsoft.public.inetserver.indexserver)
  • Re: Increasing your PAGE RANK
    ... >> Participating in link schemes is a way to increase page rank, ... so the site 'spam ranking' will ... I have a "useful links" page on one site for people who want ... > to do a link exchange. ...
    (alt.internet.search-engines)
  • Re: Integrating results from different pages? (No luck w/ INDEX &
    ... ranking for every player that has a ranking. ... Most of my source come in the format "Rank. ... Lastname" match a cell that is a formula that gives the same result? ... > Now you have all the names in sheet3 ...
    (microsoft.public.excel.misc)
  • Re: League Table position assignments
    ... This will allocate the 1st to 10th Ranking. ... I have assumed you want to always show the rank, ... or a separate table to calculate points for each ...
    (microsoft.public.excel.misc)
  • Re: Sorting functionality
    ... application specific sql functionality. ... I have to implement a ranking ... a rank must be assigned to each tuple depending ... separate attribute in the same table. ...
    (comp.databases)