Solved

sql; table relationships

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

Suggested Solutions

Title # Comments Views Activity
sql for Oracle views 8 46
System.InvalidCastException: Specified cast is not valid 10 67
VB.Net - CSV to Oracle table 4 52
help on oracle query 5 30
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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now