var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: PRIMARY-KEY Vs UNIQUE+NOT-NULL
What is the difference between Primary key and Unique key + Not Null....
Which one is better to use and why.............
Their uses are different
PK are used for referential integrity (pair with FK)
UK are used for data consistency and validation
For instance: you have an ORDERS and ORDERS_DETAIL tables,
with PK you must delete ORDERS_DETAIL registers prior to delete ORDERS register
with UK+NOT NULL .... whoops! you may have an order without detail , or details without an order
Last edited by OracleDisected; 04-30-08 at 01:51.
Originally Posted by OracleDisected
Data Integrity chapter of the Oracle 10g Database Concepts book might be interesting reading.
SQL> create table master
2 (id_m number unique, --> NOT primary key!
3 name varchar2(20)
SQL> create table detail
2 (id_d number primary key,
3 id_m number constraint fk_dm
4 references master (id_m), --> referencing UNIQUE key
5 value number
Yes, that is a hole in the implementation... I wonder if any reverse engineering tool ... or even Oracle BI will be capable of reconstructing relation using PK/FK, using that practice.
The fact we can do things, does not imply they are 100% right.