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 Surrogate Key Tips

Expert Oracle Database Tips by Burleson Consulting

March 29, 2015

 

Question:  :  I have a hospital database where the patient ID does not immediately exist when a patient first calls for an appointment.   I have a person table and an appointment tables, and each appointment must be tied to a person.   How to I create a good candidate key until I can generate the correct primary key for the row?

Answer:  As you know, referential integrity (RI) is used to enforce entity relationships, such as that between parent and child tables.

For example, a customer table may place many orders, but each order only belongs to one customer.

You want a candidate key, a unique secondary key which can be used as a surrogate to the primary key . . .

When the primary key may not be available immediately, you can use a surrogate key to enforce the business relationship.

Dr. Ralph Kimball makes a compelling argument for using surrogate keys, primarily to improve database performance:  

?Replacing big, ugly natural keys and composite keys with beautiful, tight integer surrogate keys is bound to improve join performance.

The storage requirements are reduced, and the index lookups would seem to be simpler.  

I would be interested in hearing from anyone who has harvested a performance boost by replacing big ugly fat keys with anonymous integer keys.?

Your case is a perfect example, where a patient ID may not exist when the first appointment is made.

A surrogate key can be a system generated sequence number or a combination of parts of a column that serve to make the row unique.

For example, there may be surrogate keys:

  •  The first five letters of the last name concatenated with the date of birth: burle121248
  •  The persons initials concatenated with the first 4 digits of their social security number: dkb4645

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, you cannot enforce this if you leave orphan appointments, which are not hooked to a parent row . . . so you need a surrogate key!

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

For example, 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