Hi folks,
Need advice on relating a child table to a parent table after populating the child table with data. Below are the two table structures and a brief description of the problem.
Parent Table (Networks)
CREATE TABLE NETWORKS(
network_id NUMBER(4),
name VARCHAR2(50),
description VARCHAR2(512),
contract_id NUMBER(4),
drawing_url VARCHAR2(256),
CONSTRAINT network_id_pk PRIMARY KEY (network_id));
Note: Primary key network_id is a sequence
Child Table (Sites)
CREATE TABLE SITES(
site_id NUMBER(4),
name VARCHAR2(128) NOT NULL,
type VARCHAR2(50) NOT NULL,
address_1 VARCHAR2(128),
address_2 VARCHAR2(128),
city VARCHAR2(20),
province VARCHAR2(20),
country VARCHAR2(20),
postal_code VARCHAR2(20),
office_phone1 VARCHAR2(20),
office_phone2 VARCHAR2(20),
fax VARCHAR2(20),
description VARCHAR2(26),
The parent table (networks) is already populated with data, I will be using SQL*Loader to populate the sites table from a CSV file. Once I load the sites data into the sites table, how will I establish referential integrity between the Networks and the Sites table? In other words, how can I insert the network_id from the Networks table into the network_id of the sites table?
I’m thinking about creating a Stored Procedure to relate the two tables, is this correct, or should I truncate the networks table and load the data into the tables at the same time using SQL*Loader?
I have disabled all referential integrity constraints for the bulk load.
Any help on this subject is appreciated.
Stickybit
Need advice on relating a child table to a parent table after populating the child table with data. Below are the two table structures and a brief description of the problem.
Parent Table (Networks)
CREATE TABLE NETWORKS(
network_id NUMBER(4),
name VARCHAR2(50),
description VARCHAR2(512),
contract_id NUMBER(4),
drawing_url VARCHAR2(256),
CONSTRAINT network_id_pk PRIMARY KEY (network_id));
Note: Primary key network_id is a sequence
Child Table (Sites)
CREATE TABLE SITES(
site_id NUMBER(4),
name VARCHAR2(128) NOT NULL,
type VARCHAR2(50) NOT NULL,
address_1 VARCHAR2(128),
address_2 VARCHAR2(128),
city VARCHAR2(20),
province VARCHAR2(20),
country VARCHAR2(20),
postal_code VARCHAR2(20),
office_phone1 VARCHAR2(20),
office_phone2 VARCHAR2(20),
fax VARCHAR2(20),
description VARCHAR2(26),
The parent table (networks) is already populated with data, I will be using SQL*Loader to populate the sites table from a CSV file. Once I load the sites data into the sites table, how will I establish referential integrity between the Networks and the Sites table? In other words, how can I insert the network_id from the Networks table into the network_id of the sites table?
I’m thinking about creating a Stored Procedure to relate the two tables, is this correct, or should I truncate the networks table and load the data into the tables at the same time using SQL*Loader?
I have disabled all referential integrity constraints for the bulk load.
Any help on this subject is appreciated.
Stickybit