Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Help on Data Integrity Constraints
Suppose I have a table "Master" with 3 fields
Table Name: "Master"
Columns:
Type Varchar2(10) Code Varchar2(5) Desc Varchar2(20)
Combination of Type & Code is the Primary key.
Let's say this table acts like master/setup data to different constants that will be used in the system.
Sample Data:
Type Code Desc
AISTATUS A Active AISTATUS I InActive ROLE MGR Manager ROLE DIR Director ROLE SRMGR Senior Manager SEX M Male SEX F Female
Values of the "Code" are used to store in other tables like below
Ex:
TableName: TableA
columns:
EmpId Varchar2(5) EmpName varchar2(10)
Which one of the below approachs is the best way to maintain
referential(data integrity) constraint between these two tables?
1. Use triggers to validate the data.
2. Add 3 more columns in this case to the table and add 3 foreign key
reference constraints to Master Table.
Updated TableA definition:
EmpId Varchar2(5) EmpName varchar2(10) StatusType varchar2(10) Status Varchar2(5) Foreign key on StatusType,Status referencing Master(Type,Code) GenderType varchar2(10) Gender Varchar2(5) Foreign key on GenderType,Gender referencing Master(Type,Code) Des_type Varchar2(10) Designation Varchar2(5) Foreign key on Des_type,Designation referencing Master(Type,Code)
Any ideas/help on this highly appreciated.
Thanks Received on Tue May 03 2005 - 14:07:44 CDT
![]() |
![]() |