Method for loading rows into a database table while enforcing constraints
First Claim
1. A method for loading data into a database, comprising:
- prior to loading the data into the table, receiving data to be loaded into a table;
identifying a constraint to be applied to the data;
allocating dataspace outside the address space initially allocated by a load function;
storing a value of the constraint;
comparing the value of the constraint and a value of the data; and
determining whether to load the data into the table as a function of the comparison.
5 Assignments
0 Petitions
Accused Products
Abstract
Data to be loaded into a table of a database is read from an input file by a LOAD utility including a CHECK subutility that performs constraint checking on each row prior to loading the row into the table. During initialization of the CHECK subutility, the DB2 catalog is read to identify any constraints that apply to the data to be loaded. If any check constraints apply, check constraint routines are built and compiled by the CHECK subutility. If any referential integrity constraints apply, the key values for the parent index of each referential integrity constraint are read and stored in an additional dataspace allocated by the CHECK subutility so that the foreign key values from each row to be loaded can be located by the CHECK subutility and compared against the parent index values prior to loading the data into the table. When the constraint checking for the loading of data is complete, the additional dataspace allocated by the CHECK subutility is released.
-
Citations
21 Claims
-
1. A method for loading data into a database, comprising:
-
prior to loading the data into the table, receiving data to be loaded into a table;
identifying a constraint to be applied to the data;
allocating dataspace outside the address space initially allocated by a load function;
storing a value of the constraint;
comparing the value of the constraint and a value of the data; and
determining whether to load the data into the table as a function of the comparison.
-
-
2. A method for loading a record into a database, comprising:
-
initializing a load function;
initializing a check function;
reading a record in an input file;
allocating dataspace outside the address space initially allocated by a load function;
determining, prior to loading the record, if a constraint violation exists for the record via the check function; and
if no constraint violation exists, loading the record into the database via the load function and passing an index key for the record to a sort function. - View Dependent Claims (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
if the check constraint is defined for the input file, compiling a check constraint routine as a function of the check constraint; and
if the referential integrity constraint is defined for the input file, identifying a parent index for the referential integrity constraint.
-
-
8. The method according to claim 7, further comprising the steps of, when the referential integrity constraint is defined:
-
allocating a dataspace for the referential integrity constraint; and
attaching a reader subtask to the parent index to identify the parent key values to be stored in the allocated dataspace.
-
-
9. The method according to claim 8, wherein the step of allocating the dataspace includes allocating dataspace in addition to address space utilized by the load function.
-
10. The method according to claim 8, wherein the step of allocating the dataspace is performed via a service of an operating system of a computer system including a database management system.
-
11. The method according to claim 10, wherein the service includes an IBM MVS service, the allocated dataspace providing supplemental memory for constraint enforcement by the check function prior to loading the record into the database, a size of the allocated dataspace being determined as a function of a relative byte address of the parent index.
-
12. The method according to claim 6, wherein the step of determining at least one of the check constraint and the referential integrity constraint are defined for the input file is performed via reading a catalog of a database system, the database system including the database to be loaded.
-
13. The method according to claim 12, wherein the catalog includes a DB2 catalog of a DB2 database management system.
-
14. The method according to claim 2, wherein the step of reading the record includes reading the record from the input file and providing an address of the record to the check function.
-
15. The method according to claim 14, wherein the step of determining if the constraint violation exists includes:
-
determining if a check constraint is defined for the input file;
if a check constraint is defined, executing a compiled check constraint routine on the record;
determining if a referential integrity constraint is defined for the input file; and
if a referential integrity constraint is defined, locating a foreign key for the record, and performing, using a dataspace allocated in addition to address space utilized by the load function, a compare operation using the foreign key to determine one of a pass condition and a fail condition for the record.
-
-
16. A memory for storing data for access by an application program being executed on a data processing system for loading a record of an input file into a database, comprising:
-
a load function stored in the memory;
a check function stored in the memory;
a sort function stored in the memory; and
a dataspace allocated in the memory for constraint enforcement, the dataspace being outside the address space initially allocated by the load function;
wherein, utilizing the dataspace, the check function performs constraint enforcement, prior to loading, to determine if the record of the input file violates a constraint, and if no constraint violation exists, the load function loads the record into the database and passes an index key for the record to the sort function. - View Dependent Claims (17, 18, 19, 20)
-
-
21. A method for loading a record into a database, comprising:
-
prior to loading a record into a database, identifying a parent index for integrity constraint check;
determining a size of the parent index;
allocating a dataspace in memory to temporarily store one or more parent key values associated with the parent index, the dataspace being outside the address space initially allocated;
storing the one or more parent key values in the dataspace;
reading a record to load;
if referential integrity check is defined, extracting a foreign key value in the record; and
comparing the foreign key value against the parent key value in the dataspace;
if the foreign key value corresponds to the parent key value, loading the record into a tablespace;
building a key for a tablespace index; and
if the foreign key value does not correspond to the parent key value, discarding the record.
-
Specification