SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How many columns are allowed in a table?

    I've searched this and several other sites to find out if there is a max number of columns that a table can have. No dice.

    Does anyone know for sure?

    Also, I plan on making a table consisting of a single row with 40+ columns...is this just bad practice?

    Any thoughts, be you a guru or not, are appreciated.

    Thank you.

    Cranjled

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    Montreal
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.mysql.com/information/features.html

    Latest version should handle up to 3400 columns

  3. #3
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What kind of database are you using?

    Here are the limitations of SQL Server 2000:
    http://msdn.microsoft.com/library/de...ar_ts_8dbn.asp

    I know Access is MUCH smaller than that.

    Notice this:
    File size (data)32 TB32 TB

    Can you imagine a 32 Terabyte database? Wow!

  4. #4
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the links... And here I was concerned about having a measily 40 columns!! I'm using a mySQL database.

    32 Terrabytes huh?? That is simply inconceivable (to me!)

    Thanks again you two...

    Cranjled

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    40 columns strongly suggests you haven't normalised your database in any way what so ever!! I suggest you read up carefully on how to split up your data into multiple tables and how to use an entity relationship diagram to plan how the tables should be created. It sounds very much as if you are designing a flatfile style database, with no regard for the entities you are using.

    You are likely to have lots of redundant repeating data with a single table containing 40 columns. This can lead to all sorts of errors, apart from lots of needless typing.

  6. #6
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No normalization whatsoever. To clarify...I need this to all be in a single table... Redundant data is impossible (I think) as there will be only one single row. The table will hold config info for another script.

    At this point, the admin GUI writes the settings to a config.php file...but since the rest of the site uses a database for config settings, I thought it would only be prudent to do the same with my script.

    As far as databases, I have no idea what I'm doing...other than reading up... I'll probably end up sticking with my flat config file in the end as doing so avoids SQL injection woes (since none of the script uses the db)... as well as another learning curve with databases.

    Thanks for the info.

  7. #7
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should always store config tables like this:

    Property Key, Value

    ie...

    title, "test"
    username, "user123"
    password, "secret"
    Compwizard
    "There are 10 kinds of people in this world -- those who know binary, and those who don't."

  8. #8
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh... So then, I'd have two colums and forty rows, right? Still, the process eludes me, so I'm probably doomed to the config.php file. Luckily there's no "important" info in there...

  9. #9
    SitePoint Evangelist compwizard's Avatar
    Join Date
    May 2002
    Location
    United States
    Posts
    457
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    basically, you can just run a query something like this:

    SELECT * FROM tablename WHERE propkey = "username";

    read that into a string variable and compare that to the value entered into a form.

    Or you can just run through the whole query and create PHP vars with the table data!
    Compwizard
    "There are 10 kinds of people in this world -- those who know binary, and those who don't."


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
  •