Re: Solution
| From: | tedd | Date: | Tue, 13 Apr 2010 18:50:27 +0000 |
| Subject: | Re: Solution | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304058@lists.php.net to get a copy of this message | ||
At 12:26 PM -0400 4/13/10, Gary wrote:
Tedd 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. GaryGary: 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 similar. 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 single table. 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. User Table id = 123 name = tedd address = whatever Item Table id = 456 name = chair color = whatever Sales Table item sold = 456 buyer = 123 Done! Get the idea? Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com