Solved

sql; table relationships

Posted on 2008-06-09
5
468 Views
Last Modified: 2010-05-18
I have a table called all :
All table:

Al_id(primary key)
P_cd (foreign key relationship to table called prom) ; can be null

Prom table:
P_cd (primary key)

Now when I do a :
select * from  all
where p_cd is null
I get some records where the p_code is null. Does that not mean that the foreign key relationship is violated? There are currently no null values in the prom table& Please clarify if there is some problem with this table&
0
Comment
Question by:Sara_j_11
5 Comments
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 100 total points
ID: 21746062
According to Oracle's definitions, no there are no problems.

If you want to enforce that there must be a parent record in the PROM table for every record in the ALL table, you need to make the P_CD column NOT NULL.
0
 
LVL 29

Assisted Solution

by:MikeOM_DBA
MikeOM_DBA earned 100 total points
ID: 21746070
Whats the problem?
You designed All table to allow P_cd (foreign key relationship to table called prom) to be null.

0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 150 total points
ID: 21746267
A null value in a foreign key column does not violate Oracle's understanding (implementation) of a foreign key relationship.
0
 

Assisted Solution

by:bibhu_datta_rout
bibhu_datta_rout earned 150 total points
ID: 21748190
Hi, you have asked 3 questions
1.if foreign key is null, then its not violation of any rules as Foreign keys can be NULL accroding to oracle.
2.There must be values in the prom which are null.how are u testing it.
   select count(*) from prom where p_cd is not NULL.
  Are all PKs are valid. Please check the same.
3.And for resolution of ur problem fK should be NOT NULL.

Get back to us, in case answer not resolved.
Bibhu
0
 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 21750968
No, the data in the question *DOES NOT* imply that there are records in the "prom" table with a null value.  It only tells us there are records in the "all" table with a null value in the column that is a foreign key to the "prom" table.  And, that is OK according to Oracle's documentation of how foreign keys work in a column where null values are allowed.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
dbms_crypto.decrypt   errors out 6 41
what privileges needed for S2 for this function (Oracle 12c)? 3 29
Oracle encryption 12 59
date show only hh:mm 2 37
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question