Professional Documents
Culture Documents
uid=swg21124718
exist without the parent object. To enforce the rule, the foreign
key in the child object also becomes part of that objects primary
key, thus creating a composite aggregation.
Non-identifying relationships represent associations,
A Non-identifying relationship specifies a regular association
between objects. It uses a 1:1 or 1:n cardinality. Non-identifying
relationships can be specified as optional where a parent is not
required or mandatory where a parent is required by setting the
parent table cardinality. To specify a relationship as optional
set the parent cardinality to 0..1. To specify a relationship as
mandatory set the parent cardinality to 1.
------------------------------------------------------------------Consider the following example,
Two tables Parent and Child.
Each contains one column; Parent_ID & Child_ID,
which are their respective primary keys.
Notice that with Identifying relation, the primary
key in the child is a concatination of the two
primary keys:
//** Non-Identifying
CREATE TABLE Parent (
Parent_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Parent2 PRIMARY KEY (Parent_ID)
);
CREATE TABLE Child (
Parent_ID NUMBER ( 5 ) NOT NULL,
Child_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Child3 PRIMARY KEY (Child_ID)
);
ALTER TABLE Child ADD ( CONSTRAINT FK_T_14 FOREIGN
KEY (Parent_ID)
REFERENCES Parent (Parent_ID));
//** Identifying
CREATE TABLE Parent (
Parent_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Parent2 PRIMARY KEY (Parent_ID)
);
CREATE TABLE Child (
Child_ID NUMBER ( 5 ) NOT NULL,
Parent_ID NUMBER ( 5 ) NOT NULL,
CONSTRAINT PK_Child3 PRIMARY KEY (Parent_ID, Child_ID)
);
ALTER TABLE Child ADD ( CONSTRAINT FK_Child5
FOREIGN KEY (Parent_ID)
REFERENCES Parent (Parent_ID));