SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    nj
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how much is too much

    I am starting off a new website and controlling most of it with mysql databases and php. The site will allow for users to register, log in, and update information such as name, website, email, info, stuff like that. How should i go about laying out the database?


    I was thinking about having a major table called users which would hold all of this stuff. but in other sites, i have had two tables, one that holds just the username and password, and the other that holds the username and everything else.

    for every site should there only be one database? lets say i want a tracking database, would that just be another table in this same database, or would i create a new database?


    sorry for the large amount of questions, i just want to get this all clear before i start going crazy

    thanks jonathan
    http://www.garagepages.com - The Garage Sale Search Engine. Locate a garage sale nearest you

  2. #2
    SitePoint Evangelist comfixit's Avatar
    Join Date
    Dec 2004
    Location
    Pasadena
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well Jonathan you should take a quick look at Database Normalization theory. It contains the answers as to the best practices for setting up most table structure efficiently.

    The basic premise is that you would ideally not like to duplicate information throughout the database. So if you can keep everything in one table without needing to duplicate data then go for it. But when you start establishing one to many relationships for example one user could have any number of websites then you would want to branch that out to its own table and refer to the user by using an ID. This way you don't end up having fields like website1, website2 etc.. that go unused.

    Do a search on Database Normalization pay special attention to Primary and Foreign keys. With that information under your belt you should be well on your way to designing efficient structures.


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
  •