SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Storing large ammounts of tiny data

    Hi,

    I was wondering what would be a good technique for storing large numbers of tiny data.

    Example:
    Say there is a picture site with thousands of foto's (like flickr) where all the users can choose whether or not they like the picture.

    I'm assuming it would be too much to make a mysql table that keeps track of all pictures/users and the choice.

    Same for remembering poll-votes, or read forum posts.

    There's no specific reason as to why I am asking this, I've just always wondered.

    Thanks,
    Ed

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    They do make a table (user_id, vote). There's nothing wrong with having narrow tables. They're the best thing you can work with since small tables are easier to fit into memory, and easier to have covering indexes for.

  3. #3
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Really? I always thought it would be silly to make such a table.

    Thank you, Dan.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by edwinvanolst View Post
    Really? I always thought it would be silly to make such a table.
    what's silly about making a table to store what you need to store?

    what would you do, write the results to an external flat file?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, no. I never had to do such a thing.

    I figured, if you have a table with lots and lots of rows it would become slow because it has to search harder to find 1 specific row. So I thought it would be silly to do this when you're only storing the fact whether or not someone has voted for a poll.

    Same with forums. I wondered, how does the website remember which posts everyone has read.

    I didn't think it would be stored in a database. I figured some system with cookies or something was used.


    I'm glad to know it's not such a complicated technique at all.

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by edwinvanolst View Post
    I figured, if you have a table with lots and lots of rows it would become slow because it has to search harder to find 1 specific row.
    that makes sense, and it accurately describes what happens in a table scan -- the query gets slower and slower the more rows there are

    however, if the table is properly indexed, then the query will take pretty much the same time -- blazingly fast -- no matter how many rows it has

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I see.
    I guess I've got some reading on indexing to do.

    Thanks

  8. #8
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    How many rows of data are you talking about? A lot of people seem to get confused as to how much data is considered large in connection with databases. Few web sites would be handling more than a small amount of data in their database (say under 10 million records) and few would be handling large volumes of data (billions of records).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •