473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Table relationship

Good Day everyone!

I need urgent help on this.

I have to tables with both having 8 primary keys. Both having more than 25,000 records above. I need a script that will determine which record in one of those two tables doesnt exist in the other table(meaning has no related data using the 8 primary keys). The established relationship using the 8 primary keys is always 1:1.

Need your assistance, everyone.

Regards
Jul 30 '07 #1
1 1374
Dave44
153 100+
Good Day everyone!

I need urgent help on this.

I have to tables with both having 8 primary keys. Both having more than 25,000 records above. I need a script that will determine which record in one of those two tables doesnt exist in the other table(meaning has no related data using the 8 primary keys). The established relationship using the 8 primary keys is always 1:1.

Need your assistance, everyone.

Regards
First... 8 fields yikes!! you should consider using a surrogate key (sequence field) as the primary key and just use a unique index on the 8 fields making up the primary key.

as to your question you could do a minus between the two tables, remember to do it both ways because you want to know which rows in either table doesnt have a like row in the other. Minus only finds it one way, so for example
Expand|Select|Wrap|Line Numbers
  1. Connected to:
  2. Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
  3. With the Partitioning, OLAP and Data Mining options
  4.  
  5. [144]dave@ORADB> create table t1 (col1  number);
  6.  
  7. Table created.
  8.  
  9. Elapsed: 00:00:00.42
  10. [144]dave@ORADB> create table t2 (col1  number);
  11.  
  12. Table created.
  13.  
  14. Elapsed: 00:00:00.04
  15. [144]dave@ORADB> insert into t1 values (1);
  16.  
  17. 1 row created.
  18.  
  19. Elapsed: 00:00:00.00
  20. [144]dave@ORADB> insert into t2 values (2);
  21.  
  22. 1 row created.
  23.  
  24. Elapsed: 00:00:00.00
  25. [144]dave@ORADB> select col1 from t1 minus select col1 from t2;
  26.  
  27.       COL1
  28. ----------
  29.          1
  30.  
  31. Elapsed: 00:00:00.01
  32. [144]dave@ORADB> select col1 from t2 minus select col1 from t1;
  33.  
  34.       COL1
  35. ----------
  36.          2
  37.  
  38. Elapsed: 00:00:00.00
  39. [144]dave@ORADB> SELECT col1, 'T1' tab FROM t1 minus SELECT col1, NULL FROM t2
  40.   2  UNION SELECT col1, 'T2' tab FROM t2 minus SELECT col1, NULL FROM t1;
  41.  
  42.       COL1 TA
  43. ---------- --
  44.          1 T1
  45.          2 T2
  46. Elapsed: 00:00:00.00
  47.  
with 25K rows in each table this should be fine, but i wouldnt use it on tables with many millions, it could get really slow.
Aug 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

36
by: toedipper | last post by:
Hello, I am designing a table of vehicle types, nothing special, just a list of unique vehicle types such as truck, lorry, bike, motor bike, plane, tractor etc etc For the table design I am...
2
by: John | last post by:
I'm trying to normalize my database the best I can this time around and I'm running into some trouble. I've been avoid normalizing for a long time now because while I know how to normalize, I'm...
2
by: Larry R Harrison Jr | last post by:
I have an Access 97 database with 2 tables that have a one-many relationship. I have a SQL statement in the "one" table which I want to execute and insert 7 records into the "many" table, and I...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
20
by: Ed | last post by:
I am running Access 2002 and just ran the built in Access wizard for splitting a database into a back end (with tables) and front end (with queries, forms, modules, etc.). After running the...
3
by: Mason | last post by:
I have a table consisting of people and their attributes. I would like to create a relationship matrix table that records the relationships between the people. So the two tables would look...
5
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
76
MMcCarthy
by: MMcCarthy | last post by:
Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal...
6
by: BD | last post by:
Hi, all. I need to enforce a one-to-many relationship on 2 tables, with a join table. Say the join table contains account information. It has cust_no and acct_no. Both cust_no and acct_no are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.