At 12:26 PM -0400 4/13/10, Gary wrote:
I had four tables. name, (fname, lname) address(street, town, state, zip),
contact(phone, fax, email), comments (comments).
It was done this way because it is strictly a learning exercise. I had
never created a DB with multiple tables, so I wanted to be able to contruct
one using foreign keys, and be able to insert and retrieve from it.
But the experiment continues. For whatever reason, scripts to query a DB
that I have used for years are not working. I am thinking it has something
to do with that I switched engines to innodb.
So the lesson continues.
One of the concepts in OOP is identifying an object in terms of it's
attributes and functions. The concept of defining tables is very
If you want to learn about foreign keys, then think of them as things
that are foreign and not things that are similar.
For example, a user has name, address, height, weight, color,
language, etc. Those things can be listed in a single table.
A item that can be purchased, like a chair has a title, description,
weight, color, cost and such. Those things can also be listed in a
If a person buys a chair and the seller wants to create a record of
the purchase, then all the seller needs to do is to record the
buyer's and the chair's attributes. Now, the seller can either write
down all the attributes for each buyer/chair sale OR reference them
using foreign keys.
id = 123
name = tedd
address = whatever
id = 456
name = chair
color = whatever
item sold = 456
buyer = 123
Get the idea?
http://sperling.com http://ancientstones.com http://earthstones.com
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php