Entry
Database: Relational: Key: Foreign: What is a foreign key?
Feb 3rd, 2007 17:32
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 10 March 2005 - 07:46 pm ----------------------
Database: Relational: Key: Foreign: What is a foreign key?
---
A foreign key is a column (or set of columns) in a table
that uniquely identifies a row in another table.
A foreign key is a column that references the primary key of another
table (in order to maintain relationship).
To create this link between the two tables you add a column
that holds the primary key values of the other table.
(both columns should have the same datatype, e.g. both should be of
type integer)
---
Then this foreign key column should be filled by you (e.g. by
running the corresponding 'INSERT INTO' SQL query) with values
of that primary key column in that other table.
===
Book: see also:
---
[book: author: Greenspan, Jay / Bulger, Brad - title: MySql/PHP
Database Applications - ISBN: 0-7645-3537-4 - p. 17 'Referential
Integrity']
[book: author: Hibbs, Curt / Tate, Bruce A. - title: Ruby on Rails: Up
and Running - publisher: O'Reilly - year: 2006 - ISBN 978-0-59-610132-
9 - 'Relational Database Relationships']
===
Internet: see also:
---
[Internet: http://www.google.com search for 'how to create a foreign
key in MySQL?': http://www.weberdev.com/ViewArticle.php3?ArticleID=352]
---
Database: Language: SQL: Overview: Can you give an overview of links
about SQL?
http://www.faqts.com/knowledge_base/view.phtml/aid/32811/fid/54
----------------------------------------------------------------------