Foreign Key Constraint

Whenever two tables contain one or more common columns, you can enforce the relationship between the tables through a referential integrity constraint with a foreign key. A foreign key requires that all column values in the child table exist in the parent table. The table that includes the foreign key is called the dependent or child table. The table that is referenced is called the parent table. An example of a foreign key constraint is when the department column of the employees table (child) must contain a department ID that exists in the departments table (parent).

Foreign keys can be made up of multiple columns. Such a composite foreign key must reference a composite primary or unique key of the exact same structure, with the same number of columns and the same datatypes. Because composite primary and unique keys are limited to 32 columns, a composite foreign key is also limited to 32

columns. You must use the same datatype for corresponding columns in the parent and child tables. The column names do not need to match. For performance purposes, you might want to add an index to the columns you define

in a child table when adding a foreign key constraint. Oracle Database XE does not do this for you automatically.

When you create a foreign key constraint on a table, you can specify the action to take when rows are deleted in the referenced (parent) table. These actions include:

Disallow Delete - Blocks the delete of rows from the referenced table when there are dependent rows in the table.

Cascade Delete - Deletes the dependent rows from the table when the corresponding parent table row is deleted from the referenced table.

Null on Delete - Sets the foreign key column values in the table to null values when the corresponding table row is deleted from the referenced table.

No comments:

ONLINE TRAINING

Dear friends we are happy to announce that we entered in corporate training. For the past two years we trained many students, Employees as per industrial requirements. Now we are started online training session for who dont have enough time and who dont want to waste time to come to institutes for learning. We are offering online sessions for Windows server 2003, windows server 2008, MCSE, .NET, Java. MS SQL Server and many more. For more details about course and fee structure please



Followers

Google Pagerank Powered by  MyPagerank.Net