Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Junior Member spasm attack's Avatar
    Join Date
    Aug 2006
    Location
    Colorado
    Posts
    15
    Member #
    13735
    Hey, so I am (attempting) to write a pretty involved website and I have a pretty basic question about MySQL. How many tables can you have per database? Should I try to squeeze everything into only a few tables, or can I go crazy and make a ton of tables (which would definately make my life easier)? And also, you can put arrays into a database, correct?
    "There is no spoone" -The Matricks

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Well, historically speaking, a database should hold tables that are all relevant to each other (relational).

    Seeing as they will all serve your website, I would say that makes them relevant.

    However, having x tables just for the sake of having x tables is bad practice.

    You should try and design your tables in such a way that they can hold various, different data.

    Such as having a column that states what type, or what the content is.

  4. #3
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    If you need to ask yourself the question, then you're not thinking of organizing your data properly. You can have thousands of columns per table, or a couple per table with hundreds of tables. Neither approach is right.

    What data are you trying to store?

    You can store arrays in databases if you serialize them, or if the DB natively supports arrays. However, it is not a good idea; instead, store array values in a separate table referenced by a foreign key in another.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  5. #4
    Junior Member spasm attack's Avatar
    Join Date
    Aug 2006
    Location
    Colorado
    Posts
    15
    Member #
    13735
    Ha, I wouldn't make tables just for the sake of having them... This definitely makes my life easier. What I was planning on doing before was putting multi dimensional arrays in a table, put now that I know I don't have any restrictions on tables (and I don't know what serializing is :cross-eyed I don't have to do that any more. I assure you I won't create any excess tales .
    "There is no spoone" -The Matricks

  6. #5
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Serializing converts any arbitrary object into a string while losing little to no information about it: [phpfunction]serialize[/phpfunction]. It's also the devil because it ties your database information to PHP instead of just a generic format.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  7. #6
    Senior Member mixu's Avatar
    Join Date
    Aug 2003
    Posts
    217
    Member #
    2815
    More commonly known as "database normalization", carefully planning your database layout improves the performance and maintainability of your code. As filburt1 said, serialization is the devil. Having worked on several projects where older versions (ex. version 1.0 when the current version was 3.0) of the database had to be reused in a improved application I can tell you there is a real benefit gained here if you or someone else ever needs to support the code written now.

    Perhaps someone's asked you "Is that database normalized?" or "Is that in BCNF?" All too often, the reply is "Uh, yeah." Normalization is often brushed aside as a luxury that only academics have time for. However, knowing the principles of normalization and applying them to your daily database design tasks really isn't all that complicated and it could drastically improve the performance of your DBMS.
    (From about.com)

    Two articles that you might find useful:
    http://databases.about.com/od/specif...malization.htm
    http://dev.mysql.com/tech-resources/...alization.html

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Quote Originally Posted by filburt1
    Serializing converts any arbitrary object into a string while losing little to no information about it: [phpfunction]serialize[/phpfunction]. It's also the devil because it ties your database information to PHP instead of just a generic format.
    *facepalm*. About a month and a half ago, actually digging through and finding the serialize function would have helped me in doing something an easier way. I did a manual eval-string serialization of an Array instead. w00t :-D

    And yes, I know a better design would have been better, but I had to implement it in about two days and I knew I'd be discarding it at the end of the year :-P

    On a side note, some (not all) of the evils of serialization can be avoided via serializing in a more-or-less cross-platform language like YAML.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:15 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com