Structural Tips Needed

Discussion in 'MySQL' started by Arson, Dec 26, 2007.

  1. #1
    I am creating a new website. I have made some other sites in the past, and I have come to realize that my database creating skills suck..Horribly..and I need help..

    Are there any tips that you can give me that will help me in creating a database that wont lag horribly after a lot of data is in it, and a lot of users are accessing the site?


    Would it be better to have as many tables as possible for different data things? Or would it be better to have as few tables as possible?

    Thanks for your help!
     
    Arson, Dec 26, 2007 IP
  2. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It is best to normalize the data and to make use of indexes to join tables together. For example:

    table users
    user_id
    username
    ...

    table messages
    message_id
    user_id
    message



    You then index user_id so that if you're doing searches on it that it's much faster. It's obviously slightly slower than putting the user info right into the messages and not doing any join at all for example. But it's a heck of a lot easier to maintain as an application grows.
     
    InFloW, Dec 26, 2007 IP
  3. Arson

    Arson Well-Known Member

    Messages:
    622
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Thats what I usually do, but I am not sure if that is the most efficient way.
    My partner and I did that with advercash.net, and now with over 100k users, it gets kinda slow at times.
     
    Arson, Dec 26, 2007 IP
  4. InFloW

    InFloW Peon

    Messages:
    1,488
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well at some point the application may need it's own mysql server or better hardware. At a certain point you cannot make things more efficient. The most common ways besides mysql optimization is to start caching pages that don't change often into static content. This way you avoid the mysql server all together.
     
    InFloW, Dec 27, 2007 IP
  5. kendo1979

    kendo1979 Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    maybe it's time to get a new server? or cluster servers?
     
    kendo1979, Dec 30, 2007 IP