Relational Algebra

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/40

flashcard set

Earn XP

Description and Tags

Need to finish the outer joins

41 Terms

1
New cards

What does a relational database represent?

data as a collection of related relations

<p>data as a collection of related relations</p>
2
New cards

What is meant by the domain?

permitted values for an attribute

3
New cards

What is meant by degree?

the number of attributes

4
New cards

What is meant by cardinality in terms of tuples?

the number of tuples

5
New cards

How is a function mapped?

each input is related to exactly one output

6
New cards

What is a relation?

a set of ordered pairs (one input can relate to several outputs)

7
New cards

What is the definition for a relation/table?

a logical representation of data based on set theory and predicate logic

8
New cards

What are the 3 rules of a relation?

  1. single valued cells

  2. unique rows

  3. row + column order don’t matter


9
New cards

What are the 3 aspects of data that the relational model covers?

  1. Data Structure - table,column,row,domain

  2. Data Integrity - rules to ensure data is valid

  3. Data Manipulation - use relational algebra to retrieve + change data


10
New cards

What does the relational model consist of?

  • data structures

    • entities + their relations

  • data constraints

    • restrication on data, relations… etc.

  • relational operators

    • restrict, project, cartesian product, union, difference


11
New cards

What are the 4 objectives of the relational model?

  1. Data Indepence - allow changes w/o affecting applications that use it

  2. Control Redundancy - data not stored in multiple places

  3. Maintain Consistency - copies are accurate and up to date

  4. Enable Set-Oriented Languages (e.g. relational algebra)


12
New cards

What is a relational schema?

a textual representation for a data model

<p>a textual representation for a data model</p>
13
New cards

Relational Vocab: RELATION

the whole table

14
New cards

Relational Vocab: TUPLE

1 row

15
New cards

Relational Vocab: ATTRIBUTE

1 named column

16
New cards

What is an alternate key?

a candidate key that was not chosen as the primary key

17
New cards

What is a foreign key?

attribute(s) that refer to a candidate key in another relation

18
New cards

What do NULL values represent?

missing information (e.g. unknown value, value inserted later)

19
New cards

What are the types of database constraints?

  • entity integrity - each row is unique + identifiable

  • referential integrity - accuracy + consistency of data between tables

  • multiplicity

  • required data (primary key not null)

  • domain constraints


20
New cards

What is the difference between entity and referential integrity?

ENTITY INTEGRITY

  • constraint on PK

  • unique values + not null

REFERENTIAL INTEGRITY

  • constrain on FK

  • values match candidate key referred to/ be null


21
New cards

What is relational agebra?

a procedural language (an expression specifies operations to perform on relations)

22
New cards

What does the “natural join” operation do?

combines 2 tables based on common attribute names

<p>combines 2 tables based on common attribute names </p>
23
New cards

What does the “restrict” operation do?

filters rows based on conditions

<p>filters rows based on conditions </p>
24
New cards

What does the “project” operation do?

selects specific columns

<p>selects specific columns</p>
25
New cards

What does the “intersection” operation do?

returns only common tuples (rows)

<p>returns only common tuples (rows)</p>
26
New cards

What should you consider when choosing between different expressions that give the same result?

  • the efficiency of the operation

    • efficiency dependent on the no. tuples & indexes used

(different expressions may have the same result but are not equally efficient)


27
New cards

What do query languages allows us to do to a database?

allows manipulation & retrieval of data from database

28
New cards

What happens when a query is being responded to?

several operations are used (e.g. restrict, project etc.)

29
New cards

How are complex queries evaluated?

  • nesting operations = create relational expression

  • create temporary tables while applying operations one at a time

(most efficient method is chosen)


30
New cards

What are the 7 basic relational algebra operations?

  • restrict

  • project

  • cartesian product

  • union

  • set difference

  • join

  • intersection


31
New cards

What are the 3 types of standard set operations?

  • union

  • intersection

  • difference


32
New cards

What can the 3 types of standard set operations only be applied to?

union compatible tables - same amount of colums + same domain

33
New cards
<p>What does the “union” operation do?</p>

What does the “union” operation do?

removes all duplicate rows

<p>removes all duplicate rows</p>
34
New cards
<p>What does the “intersection” operation do?</p>

What does the “intersection” operation do?

returns rows that appear in both table

<p>returns rows that appear in both table</p>
35
New cards
<p>What does the “difference” operation do?</p>

What does the “difference” operation do?

returns the rows that are in one and not in the other table

<p>returns the rows that are in one and not in the other table</p>
36
New cards

What does the “cartesian product” operation do?

multiplies 2 tables

<p>multiplies 2 tables</p>
37
New cards

What happens during a “cartesian product” operation if columns have the same name?

  • columns w/ same name must be prefixed w/ table name

    • maintains unique column names


<ul><li><p>columns w/ same name must be prefixed w/ table name</p><ul><li><p>maintains unique column names</p></li></ul></li></ul><p></p>
38
New cards

What does the “join” operation do?

  • combines 2 tables to form a new one

    • columns involved must have the same domain

    • derivative of cartesian product


39
New cards

What are the 3 types of joins?

  • equijoins

  • natural join = auto matches attributes

  • outer joins = returns matching rows + preserve certain rows that dont have a match

    • left outer join

    • right outer join

    • full outer join


40
New cards

What can JOIN operatins be written in terms of?

restrict & cartesian product operations


<p>restrict &amp; cartesian product operations</p><p></p>
41
New cards

What is the condition of the “equi-join” operation?

contains only equality comparisons

<p>contains only equality comparisons</p>