PDA

View Full Version : Multiple Tables


Shalazar
02-03-2000, 12:27 AM
I've been reading through MySQL.com to start learning about how to take advantage of databases for websites and what not.[nbsp][nbsp]Earlier on, I had asked whether or not multiple databases were available on accounts here, and with the recent info I've run across on that site, I think my question was incorrect.

It appears that one database should be sufficient, but rather that multiple tables are required for the various amount of information to be stored.[nbsp][nbsp]Is that what one would use to say, have one table to database references to images and their info, another table to work as a searchable FAQ type knowledge base, and yet another to, say, maintain user records taken from contest entires???

Am I on the right track here in my thinking?

pier
02-03-2000, 06:00 AM
You've got it.

Pier

Justin
02-04-2000, 01:23 AM
When you get more into it, you'll find more uses for tables - table joins are great.

Say you have a database storing companies and their products. You could have a table named "companies" and a table named "products". The products table would have a field specifying the ID of the company that product belongs to. This way, the data that would be duplicated over and over again (company profile) if you were using only one table is now held in it's own table.

Then you could do something like this:
</font><font face="Courier" size="3">
mysql> select companies.name, products.name, products.price from companies, products where products.company = companies.ID and company.name = &quot;FutureQuest, Inc.&quot;;
</font><font face="Verdana, Arial" size="2">
And retrieve all product information as well as company information about FutureQuest, Inc...

See http://www.devshed.com/Server_Side/MySQL/Join/ for a great tutorial on the subject (I learned a lot from DevShed when I got started). I use table joins accross 5 or more tables at a time on a regular basis, and my DB software is very fast, efficient, and stable :)

Hope this helps.

------------------
Justin Nelson
FutureQuest Support