21 users online (0 members and 21 guests)  

Thread: popular books


  Results 1 to 3 of 3

Related

  1. CSS reference books    Forum: CSS Forum
    Replies: 2
  1. #1
    sineld's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    1

    Exclamation popular books

    CREATE TABLE `populer_books` ( `id` bigint(22) NOT NULL auto_increment, `books` int(11) default NULL, `user` int(11) default NULL, `editor` int(11) default NULL, `date` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) ENGINE=MyISAM;

    this is mysql table structure

    i want to list the books which are added to this table at list 10 times. will you please help me wiht the mysql query?

    thanks...

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: populer books

    Do you mean that you want to list the last 10 books added to the database?

  3. #3
    darkdirk1's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2005
    Posts
    5

    Re: popular books

    `populer_books` ( `id` bigint(22) NOT NULL auto_increment, `books` int(11) default NULL, `user` int(11) default NULL, `editor` int(11) default NULL, `date` datetime NOT NULL default '0000-00-00 00:00:00',

    okay the problem here is w/ the initial design.
    The perfect query would be "SELECT * WHERE freq > 10"
    but you don't have a freq column...

    Because this is so far from normalized.
    So is the only description of the book an 11 digit number called books???
    Dont you think there should be another table that links that 11 digit ID to things like the book's title or the Author???

    Then a seperate table to track the books submitted by your users...That way, the table which holds the freq column only has a single instance of each book ID.
    You can simply increment the freq column during your add record function.

    The way you have it now is insanely innefficient - especially if you actually imaging you could possibly have enough records to constitute using bigint....
    I mean yikes - thats a lot of books. More specifically that is 9,223,372,036,854,775,807 possible records....
    Dont use bigint for real things....That is reseved for crunching numbers.


    Hope this helps.



Tags for this Thread