Conclusion

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!

 

Next chapter: Table joins >>

Previous chapter: Other normal forms

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar