Hudzilla.org - the homepage of Paul Hudson
Contents > Databases > Normalisation Wish List | Report Bug | About Me ]

9.8.7     Conclusion

This is NOT the latest copy of this book; click here for the latest version.

Do you see how normalisation works? I hope so! Once you have the data split, you can do much more powerful things; for example, CompanyNum could be made to use a comma-separated list of companies that person has worked for, which would mean one field of "1,2" would mean "This person has worked for company 1 and company 2" - you would not have to add four more fields to each record to allow them to have worked for two companies.

How you normalise data might not be immediately apparent to you in your own projects, but it can make a big difference if done properly. Put simply, every individual thing which uniquely has attributes of its own in your database should have its own table of data - that is, if you were shipping computers, you might have a table for monitor types, a table for CPU types, a table for graphics card types, etc, and then a master table of PCs, which contained IDs into the other tables - e.g., PC #1 might contain monitor #4 (which in the Monitors table might be a Mitsubishi Diamond Plus 200), keyboard #6, graphics card #2, etc.

Final note: Planning your data structure ("database schema") should be done before you start work, because it is not really something that is easy to change after you start work!





<< 9.8.6 Other normal forms   9.9 Table joins >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
Be the first to add a comment to this chapter!



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is zero plus seven?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow