4) Relational Model Flashcards

(50 cards)

1
Q

What is the key idea of the relational model in database systems?

A

Everything in the database is represented as relations (tables)

Relations can be thought of as tables where rows represent entities and columns represent attributes.

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

What does a relation represent in a database?

A

A relation is essentially an entity type, represented as a table

Rows in a relation represent individual entities, while columns represent their attributes.

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

What is a row in a relation also known as?

A

A tuple

A tuple represents one record, such as an employee or person.

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

What are the core parts of a relation (table)?

A
  • Row
  • Header
  • Domain

Each part has its specific role in defining the structure of the relation.

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

What is the role of the header in a relation?

A

The header consists of attribute names (column names)

Each attribute has a type for the values under it, such as int or string.

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

Define ‘domain’ in the context of a relation.

A

The domain is the set of allowed values for an attribute

It includes both data type and valid values.

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

What does it mean for a domain to be atomic?

A

It must represent just one single value, not a list or structure

Examples of atomic values include 25, ‘Alice’, and ‘Economics’.

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

What is an example of a non-atomic value?

A

[‘Reading’, ’Swimming’]

Non-atomic values cannot be used in the domain of an attribute.

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

What is the relationship between an attribute and its domain?

A

Each attribute has a domain equal to the set of valid values for that attribute

For example, the domain for the Age attribute might be integers between 16 and 80.

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

Provide an example of a relation schema.

A

HOBBY(PersonName, Age, HobbyName)

Here, dom(PersonName) = Names shows the domain for the PersonName attribute.

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

What does dom(SSN) represent in the STUDENT relation?

A

Social-security-numbers

This indicates the domain of the SSN attribute in the STUDENT relation.

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

What is the structure of the STUDENT table?

A

Intension - STUDENT(Name, SSN, Age)

The table captures student information with attributes such as Name, SSN, and Age.

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

What does the Extension of the STUDENT table represent?

A

Extension - {<“Alice”, “123-45-6789”, 22>, <“Bob”, “987-65-4321”, null>}

This represents the real data stored in the table at a given moment.

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

Define the relation schema for HOBBY.

A

HOBBY(PersonName: FamilyName, Age: integer, HobbyName: Hobbies)

FamilyName and Hobbies are sets of possible options.

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

What is the shorter version of the HOBBY relation schema?

A

HOBBY(PersonName, Age, HobbyName)

This version includes just the attributes for simplicity.

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

What does a relation consist of?

A

A relation is a set of tuples

Each row in the relation corresponds to a tuple, and all tuples must be unique.

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

What is a super key?

A

A super key is any set of attributes in a table that can uniquely identify each row (tuple)

No two tuples can have the same values for the super key.

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

Give an example of a super key in the STUDENT table.

A

{SSN}, {Name, SSN}, {Name, SSN, Age}

All of these can uniquely identify each student.

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

What is a candidate key?

A

A candidate key is a minimal super key

It uniquely identifies each tuple and cannot have any unnecessary attributes.

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

What is the candidate key for the STUDENT table?

A

{SSN}

This is the minimal super key that maintains uniqueness.

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

What does the term ‘key’ refer to in this context?

A

Key = candidate key

A candidate key can be chosen as the primary key.

22
Q

What is a primary key?

A

The primary key is the candidate key that is selected to identify tuples (rows) in the relation (table)

It serves as the main identifier for records in a table.

23
Q

What is a foreign key?

A

An attribute (or set of attributes) in one relation that references the primary key of another relation

It establishes a link between two tables.

24
Q

What are the conditions for a foreign key?

A
  • Same Domain
  • Matching Values

Foreign key attributes must have the same data type as the primary key and must either match or be NULL.

25
What does a relational database schema define?
The structure of the database, including the set of relations and integrity constraints ## Footnote It outlines how data is organized and how relationships are maintained.
26
What is the representation of a schema S?
Schema S: {R1, R2, …, Rm} ## Footnote Each Ri represents a table with attributes in the database.
27
What defines the structure of a relational database?
Relational database schema defines the structure of the db, including the set of relations and integrity constraints.
28
What does Schema S represent?
Schema S: {R1, R2, …, Rm} is a set of relation schemas, where each Ri represents a table with attributes.
29
What are integrity constraints in a relational database?
Integrity constraints are rules that ensure the accuracy and consistency of the data in a relational database.
30
What is the purpose of integrity constraints?
These constraints govern the validity of the data and maintain the relationships between tables (relations).
31
What do integrity constraints enforce?
IC are rules applied to the schema that enforce the integrity of the data.
32
What is a data type constraint?
Data type constraint: each attribute must have a value that belongs to a defined domain (data type, ie integer or string).
33
What is a key constraint?
Key constraints: primary key must uniquely identify each tuple in a relation.
34
What is a domain constraint?
Domain constraints: if an attribute’s value must be within a range of values (ie age between 18-70).
35
What does a relational database instance represent?
A relational database instance represents a snapshot of data stored in a relational database at a given point in time.
36
What does a relational database instance consist of?
It consists of a set of relation instances, each corresponding to a relation schema defined in the database schema DB = {r1, r2, …, rm}.
37
What does the Entity-Relationship model use to represent the structure of data?
In the Entity-Relationship model, we use entities and relationships to represent the structure of the data.
38
How do we transition from the Entity-Relationship model to the relational model?
We map entities and relationships to relation schemas.
39
What happens to entity types in the transition to relation schemas?
For each entity type E with attributes A1, A2, etc, the entity type becomes a relation schema RE.
40
Provide an example of an entity type mapping to a relation schema.
Example: HOBBY(PersonName: FamilyName, Age: integer, HobbyName: Hobbies).
41
What happens to relationship types in the transition to relation schemas?
For each relationship type R between entity types E1, E2, etc we create a relation schema RR that includes the primary keys of all participating entity types as well as attributes.
42
Provide an example of a relationship type mapping to a relation schema.
Example: WORKS-FOR(EmployeeID, DeptID).
43
What are relations in a relational database?
Sets of tuples (no duplicates) ## Footnote Each tuple represents a single record in the database.
44
How are types identified in a relational model?
Through the value of attributes ## Footnote The relational model is value-oriented.
45
Is there a notion of order in a relation?
No order of tuples/rows ## Footnote Relations are unordered sets.
46
What is the nature of attribute values in a relation?
Atomic (single values) ## Footnote This means that attribute values cannot be further subdivided.
47
What does DDL stand for, and what is its purpose?
Data Definition Language; for the creation/deletion of a relation-schema (table)/database or the adding/deleting of an attribute ## Footnote DDL commands include CREATE, ALTER, and DROP.
48
What does DML stand for, and what operations does it include?
Data Manipulation Language; includes insert, update, delete, query, and retrieve data from the relations (tables) ## Footnote Common DML commands include INSERT, UPDATE, DELETE, and SELECT.
49
What is the role of Transaction Management in a relational database?
Ensures reliability and consistency during operations that involve multiple steps (begin, commit, rollback, savepoint, locking) ## Footnote This is essential for maintaining data integrity.
50
What is View Management in a relational database?
Creating and managing views in a relational database (doesn't change data but just displays it) ## Footnote Views can simplify complex queries and enhance security.