Lecture 3: Relational Databases Flashcards

1
Q

What is a relational DB

A
  • Popular database type
  • Each relation is a table. Relational databases are organized as tables
  • Tables: Rows, Columns
  • Poweful tool for storing and accessing data
  • Simple data representation
  • Ease to customise
  • Using SQL
  • Implemented in most popular DBMS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do the columns contain?

A

Fields / attributes (field names)

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

What do the rows contain?

A

Records / tuples

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

What is an attribute domain?

A

Data type = allowed value, bijv. ’integer’, ‘string’, ‘real number’

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

Can tuples be identical?

A

No

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

Which two concepts exist on the model level of a DB?

A

Schema vs. instance

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

Explain schema

A

meta-data = column head for the data, i.e. how data has to be structured at the logic level.
Specifies name of table, attributes and the attribute domains.
Rarely changes (high costs to update!)

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

Explain instance

A

Tuple, content of the data
Changes regularly and easy, but conforms to schema

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

Define keys

A

A set of one or more attributes (columns) in the
table that have certain properties

More formally = Set or combination of attributes in table that have certain properties.

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

Define compound key

A

Key that includes two or more attributes (and can be used to look up tuples)

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

Define superkey

A

“Unique key.” Any set of attributes of columns which help to identify rows in a table uniquely. No two tuples have the same values. Can uniquely identify a specific tuple in a table (for example in enrollment database the SID and CID)

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

Define cadidate key

A

Minimum super key

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

Define primary key

A

Used to uniquely identify or find the records in a table. A table can have only one primary key.
– Every tuple in a relational database has its own
primary key
- Primary key cannot be null!

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

Define secondary key

A

Key used to lookup tuple, but may not guarantee uniqueness

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

Define foreign key

A

Key in another table. Used to locate records in another table.
Key is used a as constraint rather that to find a tuple

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

What is an index?

A

Database structure making it easier to find tuple based on the values of one or more tuples (is not a key!, but closely related).

For example: use name to find SID. “Attributes most likely needed to search” (because nobody knows their SID, but do know their name). Then you place an index on the attribute “Name”. It takes time to create, so only put indexes on those attributes most likely needed.

17
Q

What is a constraint?

A

Restriction on data allowed in database. It is not part of the database.

18
Q

Define basic constraint

A

Constraint related to particular attribute. Bijv. make attribute required (not NULL), or attribute domain (cannot put string in integer field)

19
Q

Check constraint

A

Evaluates Boolean expression to see if data is allowed in the database (true or false).
- Attribute-level check constraint validates single column (bijv. age > 0).
- Table-leve check constraint can be placed on more of tuple’s attributes to see if the data is valid

20
Q

Primary key constraint

A

No two records can have the same value for primary key attribute of a table (and not NULL)
Is called “entity integrity”

21
Q

Foreign key constraint

A

Key in another table. Used to locate records in another table. “Referential integrity constraint”

Constraint requires that a tuple’s value in one or more attributes in one table must match value in another table (i.e. reference table, often the primary key in the foreign table)

22
Q

What does the DB operation ‘projection’ mean?

A

Drops attributes from a table or selection (bijv. list only student’s names and not their ages)

23
Q

What does the DB operation ‘union’ mean?

A

Combines tables with similar columns and remove duplicates (bijv. all students enrolled in this course ever)

24
Q

What does the DB operation ‘intersection’ mean?

A

Find records that are the same in two tables

25
Q

What does the DB operation ‘difference’ mean?

A

Selects tuples in one table that that are not present in second table

26
Q

What does the DB operation ‘Cartesian product’ mean?

A

Creates new table containing all tuples in first tables combined with every tuple in second table (see slide 1,2,3 x A,B,C)

The join operation a Cartesian product only if tuples meet some conditions

27
Q

What does the DB operation ‘divide’ mean?

A

Opposite of Cartesian product. Use one table to partition tuples in another table (so go back to 1,2,3 x A,B,C)