Quote:
Originally Posted by Old Pedant
ummm...yes, you can write actual SQL with phpmyadmin. I don't use the product, but others have told me they have used actual SQL and it has worked. If you don't know how, ask.
|
I have wrote some basic SQL using phpmyadmin but never added anything like that line there...Just got on properly today so going to play about with re-creating my table using SQL this time.
Quote:
|
Originally Posted by Old Pedant
But *PROBABLY* phpmyadmin has a way to specify foreign keys in its table designer. Almost surely, in fact. Try reading the docs.
The reasons you want a foreign key:
(1) MySQL will not then allow you to add an image unless you give it a *valid* productID. So you get automatic error trapping.
(2) If you try to remove a product and there are still images associated with it, you won't be allowed to. You have to remove all the images that reference a given productid before you can remove that product.
This is all called "referential integrity" and is designed to keep you from making mistakes!
(MySQL also supports "CASCADE DELETE" which means that if you remove a given product it will automatically remove all the images that reference that product. I don't recommend using this feature when starting out, but it's a nice weapon to have in your arsenal later.)
|
Going to read the mysql docs now and see what I can find. I've heard of cascade deleting, think it may have a been a topic on this forum and remember the functionality of it.
Sounds really neat.
Kind regards,
LC.