Jump to content

Primary & Foreign Keys


23.12.2012
 Share

Recommended Posts

I'm currently going through a book which teaches you both PHP and MySQL, and I'm having a hard time going through the chapter which describes the KEYs and their use. The question is how do we create a foreign key?I had a look over some pieces of code, and as far as I can say, being given a test_db database, we've got two tables: primary_table and foreign_table. The former has a primary key called "id". The latter has only got a column named "id", and that's how we define a foreign key. In other words, SQL links them by itself. Am I right, or have I got it wrong? Any input is highly appreciated. Thanks in advance!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...