ICA Database CREATE TABLE Assignment
ICA Database CREATE TABLE Assignment
Inserting rows into parent tables before child tables is crucial because child tables contain foreign key references that depend on the existence of corresponding primary key entries in parent tables. This order enforces referential integrity, ensuring that a child row exists in relation to a valid parent row, as dictated by foreign key constraints .
The NOT NULL constraint should be omitted for columns such as EventPlan.EmpNo, EventRequest.DateAuth, EventRequest.BudNo, and EventPlan.Notes, since certain fields do not require mandatory data entry. Additionally, primary key constraints imply a NOT NULL requirement automatically, so explicitly defining it for primary key fields is unnecessary .
In Oracle databases, the BOOLEAN data type is not available. Consequently, CHAR(1) is recommended for boolean-like fields, such as the Customer.Internal column, to represent true/false conditions using single-character values, thereby ensuring compatibility and simplicity in implementation .
The ON DELETE CASCADE clause ensures that when a row in a parent table is deleted, all corresponding rows in child tables that refer to the deleted parent row are also automatically removed. This is useful in the ICA database, specifically for the foreign key constraint of PlanNo in the EventPlanLine table, to maintain referential integrity and prevent orphaned records in child tables upon parent row deletions .
To display populated table content for submission, one can utilize client features from Oracle or PostgreSQL, such as accessing table view options. Alternatively, executing SQL statements like SELECT * FROM ResourceTbl can retrieve and display the rows and columns of a table, fulfilling the ICA assignment submission requirements by providing a visual representation of the data .
A named CHECK constraint is defined to ensure that the EventPlanLine.TimeStart value is smaller (chronologically before) than the EventPlanLine.TimeEnd. This constraint is external as it involves two columns .
The recommendation is to use the VARCHAR data type with length 8 for primary key fields such as CustNo, LocNo, EventNo, PlanNo, EmpNo, ResNo, and FacNo. For consistency, the corresponding foreign keys should also use the same data type and length .
In Oracle, the DATE data type is used universally for columns involving dates or times. However, in PostgreSQL, the DATE data type is used for date-only columns, while the TIMESTAMP data type is used for columns requiring date and time details. This distinction leverages PostgreSQL’s support for more granular time tracking .
For a composite primary key, the CONSTRAINT clause must be external due to its involvement of multiple columns. This is necessary because inline constraint definitions are suitable for single-column keys, whereas composite keys require a definition after all columns are declared to ensure proper linkage and enforcement .
Meaningful names for CONSTRAINT clauses enhance readability and maintainability of the database schema, allowing developers and database administrators to quickly identify the purpose and enforcement criteria of each constraint. This is particularly useful in large databases like the ICA, where understanding the specific business rules applied, such as the limitations on status values or cascading delete actions, ensures ongoing data integrity and clarity for future modifications .