Jump to content

A bit of database theory.


RoninStretch

Recommended Posts

hey guys.

 

Im noob at php+mysql so hope someone won't mind helping with a little theory.

 

I have a database of users, each with a 'points' field..

What i want is to have is a ranking page displaying the top ten users. (the ten users with the most points).

 

So i know there must be a better way then calling all the data and messing with it in the script.

I don't know if the way to go is to re-order the rows using some sort of sorting algorithm and display the top ten.. OR

to have the server compile a list of top points users once a day or something and when the user goes to the topten page it just retrieves that info..

 

Any help and code snippets you can give will be a great aid to me..

 

Thanks!

 

- Stretch.

Link to comment
https://forums.phpfreaks.com/topic/48887-a-bit-of-database-theory/
Share on other sites

yup, it's just that simple.

 

indexes are just ways of "indexing" (bet you didn't see that coming) the values of a column so that they are retrieved more quickly...

 

SELECT statements occur much faster when they use that column but insert queries take longer and it takes up more room on the disk. If you're not going to be selecting the column a lot or if you're going to be changing the column a lot then an index may not be best...

 

(Unique) Indexes are good for things like usernames, etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.