Solved

sql; table relationships

Posted on 2008-06-09
5
466 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 34

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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 explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

770 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