dani33l_87 Posted February 8, 2013 Share Posted February 8, 2013 I have this questions Is there a connection between SQL multi table query and PK and FK? and this answer SELECT country.Name, countrylanguage.Language FROM country, countrylanguage WHERE country.Code = countrylanguage.CountryCode But I need to explain it and I don t understand very good databse. Someone know an answer/explanation easy to remember? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 9, 2013 Share Posted February 9, 2013 Sorry, I don't understand the question.... Quote Link to comment Share on other sites More sharing options...
dani33l_87 Posted February 9, 2013 Author Share Posted February 9, 2013 I have some questions like what is Primary Key, Foreign key. What are the disadvantages and advantages to use these. I know all this questions instead of this: Is there a connection between SQL multi table query and Primary Key and Foreign Key? I have an idea what is the relation but I will need a clear answer for someone that really understand this. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 12, 2013 Share Posted February 12, 2013 A primary key is just a special unique index, at its core. A foreign key is way to ensure that cross-referenced values between tables stay consistent (i.e. when the parent gets updated, the child tables do as well). It is often true that the index required in the referencing table is often the PK, but there's no requirement for it to be. Every InnoDB table requires a PK -- and it's a good idea to pick one yourself, or InnoDB will make a poor choice for you. MyISAM can omit the PK, but it's rarely a good idea for most tables. In terms of multi-table queries, once again, indexes are required for these to perform well -- so a PK can often be used. Quote Link to comment Share on other sites More sharing options...
alena1347 Posted February 13, 2013 Share Posted February 13, 2013 1)primary key comes into picture mostly in INSERT and UPDATE queries rather than select primary key basically means that if a column in database has a primary key attribute then no duplicate values can be inserted in that column 2)Foreign key means if a column in a table suppose column id of table marks has a foreign key on column id of student then column id of marks can only contain values that are in id column of student hope this helps! Quote Link to comment 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.