im1hunt Posted February 26, 2003 Share Posted February 26, 2003 Ok, I am using phpmyadmin to create my MySQL data base and it is all working properly. I have normalised the data in my table and have all the feilds set up but I am unsure as to how I create the relationships butween the tables in my db. I know that in microsoft access all you do is open a window with the tables and drag the mouse over the fields you want to join, but I dont know how to do it in MySQL. can anyone tell me? Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/ Share on other sites More sharing options...
deathead Posted February 26, 2003 Share Posted February 26, 2003 I might be wrong here and I am hoping I am becuase I\'ve been doing it this way for some time now... There is no way to create a relationship between tables in MySQL. The relationships must be upheld through the code. I believe they are planning to fix this as of MySQL 4 Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-525 Share on other sites More sharing options...
effigy Posted February 26, 2003 Share Posted February 26, 2003 you can specify foreign keys but it doesn\'t actually link them together - it\'s more of a textual reference when someone looks at your db structure. do you know how to join the tables in a query? Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-526 Share on other sites More sharing options...
deathead Posted February 26, 2003 Share Posted February 26, 2003 do you know how to join the tables in a query? I myself am a bit unsure of how to do this... would you mind pointing me in the right direction? Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-527 Share on other sites More sharing options...
phpmonkey Posted February 26, 2003 Share Posted February 26, 2003 You don\'t actually setup relationships, but it is instead in how you query the database. If you have a SQL book, just look at queries and this will become quite clear. You could also look at JOIN in the SQL manual. Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-529 Share on other sites More sharing options...
effigy Posted February 26, 2003 Share Posted February 26, 2003 table_name: cities id | name 1 | charlotte 2 | new york table_name: people id | name | city 1 | bob | 1 2 | bill | 2 select p.name, c.name from cities c , people p where p.city=c.id; (this is off my head - i may have something wrong but i hope you catch the general idea) would return: bob | charlotte bill | new york it returns the person\'s name and the city\'s name where the city field was equal to the cities id. Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-530 Share on other sites More sharing options...
stephtort Posted November 21, 2003 Share Posted November 21, 2003 I have been searching the internet and books trying to find an actual explanation of how to query a DB using something along the lines of relationships. I\'m also an Access & Filemaker Pro user learning MySQL, and learning new terminology and structure is killing me! Thank you Effigy for spelling it out for us converts! Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-4669 Share on other sites More sharing options...
stephtort Posted November 21, 2003 Share Posted November 21, 2003 Can someone explain what JOIN actually does? Does it combine tables? Or just reference them? Quote Link to comment https://forums.phpfreaks.com/topic/184-db-relationships/#findComment-4670 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.