Chapter 1 - Relational Data Model Flashcards

1
Q

What is the relational data model?

A

It is a framework for organising and managing data in a database system.
It is based on the concept of relational DB, which is a collection of tables called relations, each with a unique name.

basically its fking table framework

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

What is relation, tuple and attributes?

A

relation->table
tuple-> row
attribute->column

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

What advantages does relational db provide?

A

provides
1. simple data representation and
2. simple querying

BECAUSE OF TABLE USAGE

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

Are relations ordered or unordered? Why is that good

A

Unordered. This means that the order of rows or columns in a table is not significant.

This allows for optimised storage and efficient querying since data can be stored and retrieved without relying on a specific order.

SQL usage to retrieve easily

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

What is a relational schema?

A

Every relation has a schema

It specifies the type of information for relations. For example, attribute name and domain.

Different relations can share the same schema.

Tables:

STUDENT

Attributes:
student_id (Primary Key)
first_name
last_name
date_of_birth
email
Description: Stores information about students.
COURSE

Attributes:
course_id (Primary Key)
course_name
department
Description: Stores information about courses offered.

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

what is the notation to represent the schema of r? give an example if r is STUDENT
what is the notation to represent the schema of n?

Are domains stated explicitly in the notation?

A

The notation is r(R)
and
n(N)

if r is student then R would be (sid, name, addr)

Domains are not explicitly stated in the notation

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

What does the special value NULL indicate?

A

It indicates that a value is unknown or unspecified.
This value causes complications in many operations and we should avoid using NULL if possible.

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

What should we write instead of specifying NULL?

A

We should specify a value 0
cannot find a page? Give error 404.

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

What are keys?

A

A key is a minimal subset of attributes within a relation that uniquely identifies a tuple. in other words, it is the smallest combination of attributes that can be used to distinguish one tuple from another

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

What are keys used to do?

A

They are used to distinguish individual tuples.
Keys define the meaning of the relation.

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

Can two distinct tuples have the same value in all key attributes?

A

NO

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

What is a superkey?

A

A superkey is a set of attributes(columns) within a table that can uniquely identify each record. EMPHASIS ON RECORD.
Example:
A single column, such as “sid” (student ID), can be considered a superkey because it uniquely identifies each student’s ID within the STUDENT table.

Not all superkeys are equally useful for identifying records uniquely.

Examples of superkeys for a STUDENT table could include “sid” (student ID), “sname” (student name), “sphone” (student phone number), and “saddress” (student address). However, not all of these are the most minimal or appropriate keys.

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

What is a candidate key?

A

A candidate key is the minimal set of fields (attributes) that can uniquely identify each record in a table.

A table can have more than one candidate key.

“sid” (student ID) and “sphone” (student phone number) are both candidate keys because they can uniquely identify students.

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

What is a primary key?

A

Primary key is a specific candidate key chosen to become the main key for the table.

It’s the key that is most appropriate to serve as the primary means of uniquely identifying records in the table.

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

How do we indicate primary keys?

A

We underline them in the table schema

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

What is the difference between superkey, candidate key and primary key?

A

Superkeys are sets of attributes that can uniquely identify records, candidate keys are minimal and unique, and the primary key is the chosen candidate key that becomes the main means of identifying records in a table. In the example, “sid” is the primary key for the STUDENT table.

17
Q

What are foreign keys?

A

Foreign keys are used to establish relationships between relations in a relational database.

18
Q

How is a foreign key used?

A

A foreign key in one table references the PRIMARY KEY of another table, creating a logical link between them

19
Q

What is a referencing relation or the CHILD TABLE? + referenced relation or PARENT TABLE

A

The table containing the foreign key is referred to as the referencing relation or the child table.