Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Oracle Candidate Key Tips

Expert Oracle Database Tips by Donald BurlesonMarch 23, 2015

 

Question:  I have a situation where I need to apply referential integrity (RI) to specific data.  In this case, selected rows of a given column will contain the reference key to the primary key of a different table.  The problem is that the reference column is not mandatory for all rows.  When the reference column is NULL, it should not be referred by the parent table.

For example, in a telephonic appointment form, a patient may make an appointment even if they do not know their user id assigned by the hospital.  The user id field would be null, but the name is entered manually into the record; however, in the event the user id is entered, it needs to fetch the patient name from the master table.

Is there a solution for this problem?

Answer:  This can be accomplished with a candidate key.

Referential Integrity (RI) is used to enforce entity relationships between tables.

One example of such a relationship might be that a customer may place many orders, but each order only belongs to one customer.

In your situation, there is a one-to-many between patients and appointments:

  • each patient may have many appointments

  • each appointment is for one and only one patient

Obviously, this relationship cannot be enforced if you leave "orphan" appointments, which are not hooked to a patient.

Since the patients using your system may not know their user id assigned by the hospital, you need a candidate key.

The candidate key can either be made up, like an Oracle sequence, or it can be a unique combination of information you do have.

In your case, you may not know the hospital userID, but you can make a unique name from the first 5 letters of the last name concatenated with the date of birth, something like this:

Sam Jones, born 3/13/1950
key - jones3131950

I have a good book on Oracle Design that might help.

  

 
Get the Complete
Oracle SQL Tuning Information 

The landmark book "Advanced Oracle SQL Tuning  The Definitive Reference"  is filled with valuable information on Oracle SQL Tuning. This book includes scripts and tools to hypercharge Oracle 11g performance and you can buy it for 30% off directly from the publisher.

 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2016

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.


 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster