Relational model

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/66

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

67 Terms

1
New cards

definition: relational model

a relational db is a collection of related tables

2
New cards

purposes of a function

Maps sets of inputs to sets of outputs.

Associates an input value with a specific output value.

Ensures each input is related to exactly one output.

3
New cards

what is a relation/table

Represents data logically.
Physically implemented as a table.
Enables precise explanation of database operations.

4
New cards

types of relational model

logical
formal
data

5
New cards

logical model

independent of physical implementation

6
New cards

formal model

uses set theory and predicate logic

7
New cards

data model

Concepts used to describe the database, i.e., the contain information

Simple but powerful; still the foundation for databases

8
New cards

three aspects of data

data structure
data integrity
data manipulation

9
New cards

data structure

table, column, domain, row

entities and their relations

10
New cards

data integrity

null, entity Integrity, referential integrity, general constraints

(rules that ensure the data is accurate, consistent and valid)

11
New cards

data manipulation

relational algebra

(using relational algebra to retrieve, edit and add data to our database)

12
New cards

what does a relational model consist of

data structure
data constraints
relational operators

13
New cards

data constraints

Restrictions on data, relations, …

14
New cards

relational operators

Restrict, project, cartesian product, union, difference, …

15
New cards

What are the objectives of a relational model in databases?

Achieve high data independence (allow changes without affecting applications).
Control redundancy (data not stored in multiple locations).
Maintain consistency (copies are accurate and up-to-date).
Enable set-oriented manipulation languages (e.g., relational algebra).

16
New cards

row

records or tuple
Represents an individual instance of an entity.

Uniquely identified by one or more attributes (primary key).

Primary key must not contain null values (entity integrity rule).

17
New cards

column

field or attribute
Each column heading in a table has a distinct name

Its value must be atomic, i.e. a single value drawn from the domain of the column

18
New cards

table

relation
has rows and columns
represents a kind of entity or class
each table is has a unique name for id


Key properties:
No duplicate rows.
Row/column order doesn't matter.
Columns have unique names.

19
New cards

What is a domain in databases?

A domain is the set of possible values that a column can take.

20
New cards

How are columns in a table defined in relation to domains?

Every column in a table is defined on a domain.

21
New cards

Why are domains unrelated in databases?

Unrelated domains restrict column comparisons and prevent meaningless operations.

22
New cards

Can multiple columns share the same domain?

Yes, columns like SID and CID may have the same domain.

23
New cards

Can domains be infinite?

Domains may be potentially infinite but are constrained in the real world.

24
New cards

Key

one or more columns that determine (imply) other columns

Or: one or more columns to uniquely identify a row

25
New cards

types of keys:

candidate
primary
alternate
foreign
composite

26
New cards

candidate key

A minimal set of columns which uniquely identifies each row

27
New cards

alternate key

The remaining candidate keys after one is chosen as the primary key.
Alternate keys are potential unique identifiers for table rows.

28
New cards

primary key

The chosen candidate key to uniquely identify each row

29
New cards

foreign key

Columns (or a set of columns) that matches the candidate key of the associated table

Used to represent relationship between tables

30
New cards

composite key

Refers to a key consisting of two or more columns

31
New cards

null values

A NULL value is required to deal with missing information: value unknown, inserted later..
not the same as “ “ (blank) or 0

32
New cards

db constraints

Integrity constraints ensure the database doesn't have invalid values or configurations.

They ensure the data is accurate and reliable.

33
New cards

What are the types of database constraints?

Application/DB-Specific Constraints: Align with enterprise or business rules.

Integrity Constraints:
Entity Integrity: Each row is unique and identifiable.
Referential Integrity: Ensures accuracy and consistency between tables.

Multiplicity Constraints:
Required Data: Primary key cannot be null
Domain Constraints: Enforces valid values for a column.

34
New cards

integrity constraints

Entity integrity rule:
constraint on primary keys
Value of a primary key must be unique and
not null

Referential integrity rule:
constraint on foreign keys
Value of a foreign key must either match the candidate key it refers to
or be null

35
New cards

what does a relational model comprise of

structural definition
integrity rules
data manipulation

36
New cards

main languages used to deal with data manipulation

relational algebra
relational calculus

37
New cards

What is relational algebra in databases?

Theoretical language for manipulating relations
Provides operations to define new tables without modifying original ones.
Forms the basis for SQL query execution.
Supports nesting expressions and closure.
Operands and results are tables, enabling chaining of operations.

38
New cards

visual summary of operations

knowt flashcard image
39
New cards

natural join

knowt flashcard image
40
New cards

restrict operation

defines horizontal subset table
called a unary operator as it works on a single tables

41
New cards

project operation ⫪

defines vertical partitioning of a table

42
New cards

intersection operation

set intersection on tables:
only rows contained in both

43
New cards

natural join operation  ⋈

cartesian product, removing common duplicated columns

44
New cards

relational algebra is a procedural language

query is evaluated in the order specified

45
New cards

complex queries are evaluated by:

Nesting operations to create a relational expression

or applying operations one at a time and creating temporary tables

46
New cards

processing complex queries

most efficient one is preferable

47
New cards

relational algebra Vs Relational calculus - similarities

they are formal, theoretical - based on maths principals, non user friendly
used as a basis for data manipulation
lang for relational db
used to define operations to manipulate tables
equivalent in terms of expressive power

48
New cards

relation algebra Vs relational calculus - differences

relational algebra - is procedural , specifies how to achieve
relational calc - is declarative , specifies what to achieve

49
New cards

closure

property where operations produce only tables based on elements of the input tables

50
New cards

relational algebra operations 5+2

5 basic operations:
restrict (unary)
projection(unary)
cartesian product
union
set difference

2 operations expressed in terms of basic operations:
join
intresections

51
New cards

relational algebra symbols

knowt flashcard image
52
New cards

visual interpretation summary

knowt flashcard image
53
New cards

comparison operators

<, >, <=, >=, =, ≠

54
New cards

boolean operators

∧ - and ∨- or ∾- not

55
New cards

set operations

∪ = union
∩= intersection
- = difference

56
New cards

∪ union

combines two tables
removes all duplicate rows

57
New cards

∩ intersection

returns rows that appear in both tables

58
New cards

- = difference

returns rows that are in on and not the other table
T ← R - S
output all the rows that are in R but not in S

59
New cards

cartesian product (X)

multiplies two tables
PQ ← P x Q

<p>multiplies two tables <br>PQ ← P x Q</p>
60
New cards

types of join operations

equi-join
natrual join
outer join : left outer join, right outer join, full outer join

61
New cards

join ⋈

combines 2 tables to form a new one
derivative of the cartesian product where all elements satisfy p
col involves in ajoin condition p must have the same domain

62
New cards

equi - join

condition of equi- join contains only equality comparisons

63
New cards

outer join

used when displaying rows in the result that don’t have matching values in the join col

avoids info loss and includes unmatched rows in the result table

64
New cards

problems with natural join

rows not included when:
join cols are null or dont have matching rows in another tables

can cause loss of data

65
New cards

left outer join

includes all rows from R1 even unmatched ones
missing values of rows from R2 are set to null

66
New cards

right outer join

includes all rows from R2 even the unmatched ones
missing values of froms from R1 are set to null

67
New cards

full outer join

inludes all rows from R1 and R2, even unmatched ones
missing val set to null