relational database Flashcards

1
Q

what are relations made up of

A

an instance and a relation schema

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

instance

A

a table with rows and columns

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

relation schema

A

specifies the relations name and type of each column

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

cardinality

A

number of rows

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

degree/arity

A

number of fields/attributes

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

contraints

A

logical rules that establish the integrity of data

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

integrity constraints

A

a condition that must be true for any database instance

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

legal instance

A

satisfies all specified integrity constraints

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

what are the 3 types of integrity contstriants

A

domain constraints
entity integrity constraints
referential integrity

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

domain constraints

A

the value of the attribute must be an element of the attributes domain

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

entity integrity constraint

A

a key value cannot be duplicated or left empty

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

referential integrity

A

connects tables together through a foreign key

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

foreign key

A

a peripheral attribute that creates referential integrity between entity sets

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

in which two ways can foreign keys be made

A

importing the primary key from one table to another
creating a new table that holds the primary key of both tables

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

what are some constraints for foreign keys

A

they must have the same name and domain type as the referencing relation and related entities must have the same value

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

how do we derive a foreign key for 1:1 relationships

A

import the primary key from one table to the other and declare it as a foreign key

17
Q

what is the difference between deleting a tuple using SET DEFAULT and SET NULL

A

default; removes the current foreign key and leaves a placeholder
null; completely removes the relationship

18
Q

how do you delete an entity from a referenced table

A

get the primary key value of the table
find all the tuples with the fk in the referencing table and select them
set the fk to the default value or null (if null delete all tuples in the referenced table)

19
Q

how do you derive a fk 1:1 both partial participation

A

pk from one table becomes the UNIQUE fk for the other

20
Q

how do you derive a fk 1:1 both total participation

A

can combine into a single table and include all attributes
choose which pk you want to stay as the pk and which should becomes the fk (! null and unique)

21
Q

how do you derive a fk 1:1 only one total participation

A

combine the relation with the total side and the other pk becomes the fk (! null and unique)
on delete cascade/reject

22
Q

what is the difference between on delete cascade and reject

A

cascade; when removing the fk in its table you have to remove the related entity
reject; you cannot remove the fk as there is a related entity

23
Q

how do you derive a fk 1:M both total participation

A

combine the relationship with the many entity set
the pk from the 1 side becomes the fk (! null)

24
Q

how do you derive a fk M:N both total participation

A

create a relationship set and create the schema for it
use both pk to create a composite primary key
must delete on cascade

25
Q

composite primary key

A

two pk joined together that allows for combinations

26
Q

how do you derive a fk from a weak entity set

A

combine the relation with the weak entity and use the string pk as the fk
delete on cascade