0% found this document useful (0 votes)
50 views

Tables and Integrity Constraints TYPE A: Very Short Answer Questions

1. A constraint is a rule that limits or restricts the data that can be placed in a table column to ensure data integrity. Common constraints include primary keys, not null constraints, and default constraints. 2. A primary key uniquely identifies each record in a table and ensures each record is unique. A foreign key links two tables together based on a common column and ensures referential integrity between the tables. 3. Foreign keys must reference the primary key of another table to link the tables together and ensure a child record cannot be created or updated without a matching parent record. This maintains referential integrity between related data in different tables.

Uploaded by

Vinit Agrawal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

Tables and Integrity Constraints TYPE A: Very Short Answer Questions

1. A constraint is a rule that limits or restricts the data that can be placed in a table column to ensure data integrity. Common constraints include primary keys, not null constraints, and default constraints. 2. A primary key uniquely identifies each record in a table and ensures each record is unique. A foreign key links two tables together based on a common column and ensures referential integrity between the tables. 3. Foreign keys must reference the primary key of another table to link the tables together and ensure a child record cannot be created or updated without a matching parent record. This maintains referential integrity between related data in different tables.

Uploaded by

Vinit Agrawal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

TABLES AND INTEGRITY CONSTRAINTS

TYPE A: Very Short Answer Questions


1 What is a constraint? Name some constraints that you can apply to enhance database integrity.
Ans. A constraint is a property assigned to column or the set of columns in a table that prevents certain types of
inconsistent data values from being placed in the column(s).
1. Primary key constraint
2. Not null constraint
3. Default constraint
2 What is primary key? What is PRIMARY KEY constraint?
Ans. A primary key is a unique identifier for a database record. When a table is created, one of the fields is typically
assigned as the primary key. While the primary key is often a number, it may also be a text field or other data type.
The PRIMARY KEY constraint uniquely identifies each record in a database table.
3 What is NOT NULL constraint? What is DEFAULT constraint?
Ans. The not-null constraint is a restriction placed on a column in a relational database table. It enforces the condition
that, in that column, every row of data must contain a value - it cannot be left blank during insert or update
operations. If this column is left blank, this will produce an error message and the entire insert or update operation
will fail.
The DEFAULT constraint is used to insert a default value into a column.

TYPE B: Short Answer Questions


1 What is foreign key? How do you define a foreign key in your table?
Ans. A foreign key is a field that points to the primary key of another table. The purpose of foreign key is to ensure
referential integrity of the data.

Whenever two tables are related by a common column (or set of columns), then the related column(s) in the parent
table (or primary table) should be either declared a PRIMARY KEY or UNIQUE key and the related column(s) in the
child table (or related table) should have FOREIGN KEY constraint.
For example, if there are two tables:
Items (Itemno, Description, Price, QOH)
Orders (Orderno, Orderdate, itemno, Qty)
Both the tables are related through common column Itemno.
The column Itemno is primary key in parent table Items and it should be declared as foreign key in the child table
Orders to enforce referential integrity.

2 How are FOREIGN KEY commands related to the PRIMARY KEY?

You might also like