Home » SQL & PL/SQL » SQL & PL/SQL » key-preserved table
key-preserved table [message #23283] Tue, 26 November 2002 22:54 Go to next message
Raju
Messages: 74
Registered: March 1999
Member
Hi,
I am new to oracle
What is key-preserved table?I want to know it clearly.I read somewhere, emp is a key-preserved table and dept table is not a key-preserved.How do we know that?
thanx a lot in advance
regards,
Raju
Re: key-preserved table [message #23285 is a reply to message #23283] Tue, 26 November 2002 23:53 Go to previous message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
quoting the docs
Key-Preserved Tables
The concept of a key-preserved table is fundamental to understanding the restrictions on modifying join 
views. A table is key preserved if every key of the table can also be a key of the result of the join. So, 
a key-preserved table has its keys preserved through a join. 

--------------------------------------------------------------------------------
Note: 
It is not necessary that the key or keys of a table be selected for it to be key preserved. It is sufficient 
that if the key or keys were selected, then they would also be key(s) of the result of the join.  

--------------------------------------------------------------------------------
 
 

The key-preserving property of a table does not depend on the actual data in the table. It is, rather, a 
property of its schema. For example, if in the EMP table there was at most one employee in each 
department, then DEPTNO would be unique in the result of a join of EMP and DEPT, but DEPT would still not be 
a key-preserved table. 

If you SELECT all rows from EMP_DEPT, the results are: 

EMPNO      ENAME      DEPTNO  DNAME          LOC 
---------- ---------- ------- -------------- ----------

      7782 CLARK           10 ACCOUNTING     NEW YORK
      7839 KING            10 ACCOUNTING     NEW YORK
      7934 MILLER          10 ACCOUNTING     NEW YORK
      7369 SMITH           20 RESEARCH       DALLAS
      7876 ADAMS           20 RESEARCH       DALLAS
      7902 FORD            20 RESEARCH       DALLAS
      7788 SCOTT           20 RESEARCH       DALLAS
      7566 JONES           20 RESEARCH       DALLAS
8 rows selected.

In this view, EMP is a key-preserved table, because EMPNO is a key of the EMP table, and also a key of the 
result of the join. DEPT is not a key-preserved table, because although DEPTNO is a key of the DEPT table, it 
is not a key of the join. 

Previous Topic: A problem with infinite loop in trigger.....Pliz solve my problem
Next Topic: updatable views
Goto Forum:
  


Current Time: Mon Apr 29 14:40:49 CDT 2024