php - How to store Foreign Keys via PhpMyAdmin? -
in relational database best way store foriegn key, or relate key, not sure how best phrase it.
for example if had tables:
user
- id
- name
email:
- id
this not table creating simple enough idea across.
in user table if create key id when select user table id of email value in email field. can reference actual email field, fixes issue, not wasteful?
i using phpmyadmin setup databases , keys.
any advice best way this?
phpmyadmin provides graphical user interface (gui) mysql operations.
the best way databases, presume have created, run quick query!
mysql looks pretty scary, simple, once grasp concept of it!
by looking @ example, you'll looking run query one. (this rough pseudo , may not run in itself)
alter table user add foreign key (id) references email(id); easy peasy! :)
the best resource finding out more syntax required on over w3 schools! this article you'll want at!
edit
as general database rule, i'd recommend making column names (fields) unique! avoids confusion. example, use
userid,emailid.
Comments
Post a Comment