anonymous
2012-08-24 12:01:58 UTC
it shows you query code when you add new records to a table and allows you to select a foreign key for the new value youre adding (in my case, table 'drinks' has a foreign key which references the primary key of the table 'drink_types' )
so basicaly ive got 129 different drinks in a table called ' Drinks '.
i.e
Drink_ID (PK)--------Name--------Drink_Type (FK)
1 Stella Artois 3
2 Jack Daniels 5
(where '3' is the PK for drink type 'Beer' in the table 'drink types' , and '5' is the PK for drink type 'Whiskey' in the same table 'drink types').
table drink types looks like this
Type_ID--------Type
1 Wine
2 Ale
3 Beer
4 Rum
5 Whiskey
6 Champagne
7 Vodka
8 Bitter
9 Scotch
etc etc
PhPMyAdmin allows you to use 'relation view' or something, where you can create an index for a column value that behaves as a Foreign Key to a Primary Key in another table.
much the way ive done here in the example i just showed you.
As much as you'd like to have a glass of JD on the rocks, or a cold frosty beer - Please try not to day dream about beer and whiskey now - and focus on my question ^_^
lol
i want to see the SQL query CODE that shows the RELATIONSHIP that i set up between the two tables 'Drinks' and 'Drink Types'.
whats the best way to do that ?
anyone know ??
Also the constraints are that - in the table 'Drinks' a drink itself may not even be assigned to a type, so its value under the foreign key column can be nothing (Null is allowed).
oh and if i DELETE a drink_type from the 'drink type' table, i.e if i deleted the type 'whiskey' - then the record 'Jack Daniels' in the 'drinks' table REMAINS - but its type id gets set to null - so dont worry ! my whole thing is fine ! ^_^
just help ? where can i find the SQL query code for the relation i set up ?
while you're all answering my question - i'll just pop downstairs and pour myself a glass of Jack Daniels :-D
lol