02 - Relational Databases Flashcards

1
Q

What are:

Attributes?

A

Columns. Allowed data (e.g. INT, STRING, etc) in an attribute is called attribute domain.

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

What are:

Tuples?

A

records. A record in a table is a row, with the same number of attributes (columns). Important: Each tuple within a table needs to be unique as required by the relational model.

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

What are: Schema?

A

(meta-data) - Specification of how data is to be structured logically, defined at setup, rarely change. E.g. Student (SID int, name string, age int, gpa real)

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

What are: Instance?

A

Content of a table, changes rapidly, but always conforms to the schema.

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

What is a key?

A

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

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

Explain: Compound key?

A

Including two or more attributes

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

Explain: Superkey?

A

No two tuples have the same values. Key attributes that can uniquely identify a row. Several super keys can present in a table.

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

Explain: Candidate key?

A

It’s a minimum super key. A super key reduced to the least amount of attributes needed to uniquely identify a row.

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

Explain: Primary key?

A

Used to uniquely identify of find the tuples in a table, every tuple in a relational database has its own primary key. Normally it will be chosen from one of the primary keys.

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

Explain: Secondary Key?

A

Used to look up tuples, not uniqueness

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

Explain: Foreign Key?

A

used as constraint

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

What is an index?

A

database structure, quicker and easier to find tuples based on values in one or more attributes. Not the same as key.

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

What are: Constraints?

A

Related to a particular attribute in a table. Constraints are the rules enforced on the data columns of a table. These are used to limit the type of data that can go into a table.

Attribute required. Special value null represents an empty value.

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

Explain: Primary Key Constraints?

A

Entity integrity. No two records can have identical values for the primary key attribute of a table. All of the attributes that make up the primary key have non-null values.

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

Explain: Foreign Key Constraints?

A

Foreign key: refer to a key in another table. Referential integrity constraint. A tuples’ value in one or more attributes in one table must match the values in another table.

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

DB Operations: Selection?

A

Select some or all of the tuples in a table. Ex. Select only the students tuples where their gpa is greater than 2.5.

17
Q

DB Operations: Projection?

A

Drops attributes from a table. Ex. list only students name and not their ages.

18
Q

DB Operations: Union?

A

Combines tables with similar columns and removes duplicates.

19
Q

DB Operations: Intersection?

A

Finds the records that are the same in two tables.

20
Q

DB Operations: Difference?

A

Selects the tuples in one table that are not in a second table

21
Q

DB Operations: Cartesian Product?

A

Creates a new table containing every tuples in a first table combined with every tuples in a second table.

22
Q

DB Operations: Join?

A

Tuples in one table are paired only with those in the second table if they meet some conditions. Similar to cartesian product.

Ex: Student <-> Enroll = {(Rian, COMP40110), (Rian,COMP40120), (Alfie,COMP40120), (Alfie,COMP41430),…}

23
Q

DB Operations: Divide?

A

Opposite of the Cartesian product. Uses one table to partition the tuples in another table.

24
Q

How can you make DB retrevial faster?

A

keys & indexing

25
Q

What are the three main vital things in DB design?

A
  • Inclusion of all information
  • Selection of correct data types
  • Creation of keys / indexes
26
Q

What is Database Normalisation?

A

Normalisation is the process of efficiently organising data in a database. There are two goals of the normalisation process:

  • Eliminating redundant data (storing the same data in multiple tables)
  • Ensuring data dependencies make sense (only storing related data in a table)
27
Q

What are the Normal Forms (NFs)?

A

Strictly speaking there are seven normal forms (0NF through 5NF and BCNF). We will only look at 1NF to 3NF. As a rule databases are designed using 3NF. Very occasionally a database will be designed to 4NF.

28
Q

Explain: First Normal Form (1NF)?

A

1NF gives the most basic rules for organising information in a DB.

  1. Eliminate duplicate fields from the same table
  2. Create separate tables for each group of related data
  3. Identify each row with a unique value (primary key)
29
Q

Explain: Second Normal Form (2NF)?

A

Second Normal form removes more duplicate information:

  • There must not be any partial dependency of any column on primary key

The guidelines are:

  • Meet 1NF requirements
  • Remove subsets of data that apply to multiple rows of a table and place them in separate tables.
  • Create relationships between these new tables and their predecessors (foreign keys)
30
Q

Explain: Third Normal Form (3NF)?

A

3NF has the following requirements:

  • Meet all 2NF requirements
  • Remove fields that are not dependent upon the primary key
  • In third normal form every field should be dependent on the key.
31
Q

What is the general naming of common database operations?

A
  • Selection
  • Projection
  • Union
  • Intersection
  • Difference
  • Cartesian Product
  • Join
  • Divide