Chapter 2 - Integrity Constraints Flashcards

1
Q

What are integrity constraints?

A

Rules and conditions derived from real-world requirements and specified when defining or creating database schema

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why are integrity constraints necessary?

A

They help to ensure accuracy, consistency and validity of data in the DB.

They ensure that the stored data is faithful to the real-world meaning it represents

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When are integrity constraints checked?

A

They are checked when modifications (insert, update, delete) are made to the relations in the DB.
This checking ensures that data modifications adhere to the specified constraints.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What happens when DBMS checks the database and sees that integrity constraints are violated?

A

DBMS may prevent modification or indicate an error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When do we consider a database legal?

A

When integrity constraints hold true for all data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the 3 types of integrity constraints?

A

Domain constraints,
Key constraints,
Referential constraints

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are domain constraints? How is this done?

A

Domain constraints restrict the kind of attributes or values a column can hold in the DB table.

This is done by
1. Specifying data types
2. Specifying range of values: eg. age cannot be less than zero, telephone no cannot contain digit outside 0-9.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are key constraints?

A
  1. We should only have ONE PRIMARY KEY.
  2. No two tuples should have the same value for primary key.
  3. Attribute in primary key cannot have NULL values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are relational integrity constraints? (REFERENTIAL CONSTRAINTS)

A

We must ensure that the reference from one table to another table must be valid.

  1. A foreign key must have a matching primary key.
  2. The reference key element (foreign key) must either either exist in the referenced table or be NULL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do we preserve Integrity Constraints (ICs) in a relational database and how to ensure that these constraints are maintained.

A
  1. High-level database design: ICs should be modelled and defined at high-level database design stage, such as when creating an ER diagram. This involves specifying constraints like primary keys, foreign keys, unique constraints, and not null constraints using the design phase.
  2. Continuous evaluation: ICs should be evaluated continuously, especially during data modification operations like insert, update, delete or alteration of tables.
  3. SQL support for ICs: SQL provides various constructs and constraints for defining and enforcing ICs. Some examples include NOT NULL, CHECK, UNIQUE, PRIMARY KEY and FOREIGN KEY REFERENCES
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can we infer that an IC is true by looking at an instace?

A

NO. ICs are statements about all possible instances of a database, not just a single instance.
While you can use SQL constraints to enforce ICs, you cannot infer the truth of an IC solely by looking at a single instance of the DB. ICs are constraints that apply to the ENTIRE DATASET.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What do we communicate to DBMS?

A
  1. Defining the structure of the database. This includes creating, altering, dropping, truncating, commenting on, or renaming database objects such as tables, indexes, views, and more.
  2. Manipulating data.
    You communicate with the DBMS to manipulate data within the database. Common data manipulation operations include SELECT (retrieving data), INSERT (adding new data), UPDATE (modifying existing data), DELETE (removing data), and more
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do we communicate with DBMS?

A
  1. Relational Algebra
  2. SQL
How well did you know this?
1
Not at all
2
3
4
5
Perfectly