Module 2 Flashcards

Relational Data Model

1
Q

4 basic concepts of the relational model?

A
  • relations
  • attributes
  • domains
  • tuples
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

relation?

A

the main construct for representing data. Informally, it is a set of records and similar to a table with columns and rows

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

is every table a relation?

A

no, every relation is a table but not every table is a relation

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

what are the key components of a relation?

A
  • relation name
  • attribute names
  • tuples (rows)
  • attribute values from the same domain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

domain types?

A

the data type or format that a certain attribute will accept.

E.g. only accepting positive integers

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

attributes?

A

attribute is the name of a role played by some domain in the relation

E.g. the attribute salary must belong to the domain of salary

The number of attributes in a relation R is called the degree of R

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

domain/attribute restrictions?

A

same attribute name does not necessarily imply same domain

E.g. attribute ID exists for two entities but the format/range is different (1int vs. 4ints)

vice versa

different attribute name does not necessarily imply different domain

E.g. ID vs managerID (different attribute names but both are 4ints)

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

tuples?

A

tuple (t) is an ordered list of n values

where each value is an element of the corresponding attribute or the special NULL value

E.g. (1234, Ephraim, 23, NULL) is a 4-tuple

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

relation schema?

A

denoted by R[A1, A2, A3, …, A(n)] includes a relation name (R) and list of attributes A1, A2, A3, …, A(n)

E.g. A relation schema of degree 5
Employee [id, name, sex, salary, department]

integer n is “degree of relation” (how many attributes)

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

relation instance?

A

relation instance (r) of the relation schema (R), denoted by r(R), is a set of n-tuples r = {t1, t2, …, t(m)}

in normal English, a set (instance) of tuples of relational type R

E.g. a table of the same type of tuple (employee table)

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

ordering of tuples?

A

mathematically, no implied order

semantically, order irrelevant

physically, reside in blocks of storage with partial ordering therefore TUPLES HAVE AN ORDERING

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

ordering of values within a tuple?

A

syntactically, all tuples in a relation have same order

semantically, order chosen is irrelevant as long as the values are matched with the correct attribute

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

database integrity constraints?

A

rules, that every instance, of the schema must hold (as well as the transitions of the schema)

  • domain
  • key
  • entity integrity
  • referential integrity
  • semantic integrity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

domain constraints?

A

using incorrect data type

E.g. using string when attribute is type integer

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

key contraint?

A

keys must remain unique at all times

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

entity integrity constraint?

A

no primary key can be NULL

for primary keys with multiple attributes, no part of the primary key may be NULL

17
Q

referential integrity constraint?

A

one relation references something that doesn’t exist in another relation

E.g. student goes to school called ACIT but ACIT doesn’t exist in the school table/relation

18
Q

semantic integrity constraint?

A

known as business rules

cannot be directly expressed in the schema of data model

E.g. “salary of employee should not exceed supervisor’s salary”

19
Q

uniqueness constraint?

A

all tuples in a relation must be distinct

20
Q

superkey?

A

subset of attributes that make the tuple unique

every relation has AT LEAST ONE SUPERKEY

E.g. combination of attributes that can uniquely identify a tuple aka set of all attributes (assuming uniqueness constraint isn’t broken)

21
Q

key?

A

also known as minimal superkey

smallest set of attributes that uniquely identify a tuple

schema may have more than one key, these are known as CANDIDATE KEYS

ONE candidate key is selected as the primary key

22
Q

foreign key?

A

FK in R1 is a foreign key referencing PK in R2

FK and PK have same domain

23
Q

self referential relations?

A

possible for table to reference itself

E.g. employee relation has attribute ID and attribute ManagerID, some employees will have NULL ManagerID’s since they are a manager

24
Q

relations with composite keys?

A

FK’s to relations with multi-attribute PK’s is possible

E.g. different parts of a multi-attribute PK reference different relations

25
Q

constraints effect of operations?

A

constraints ensure database remains consistent

if a suggested change violates any constraints it must be rejected

DBMS enforces constraints

26
Q

potential effect of deletion on constraints?

A

referential integrity may potentially be broken

tuple being deleted is referenced in another relation

27
Q

transaction concept

A

an executing program that includes some type of database interaction

E.g. insert, delete, update, etc…

END of transaction must leave database in valid or consistent state

E.g. between two valid + consistent states some constraints may be broken in between but the FINAL state must be valid + consistent

transactions allow execution of a suite of queries where constraint violation in INTERMEDIATE STEPS are allowed

28
Q

7 + 1 steps for mapping?

A
  1. entity mapping
  2. weak entity mapping
  3. binary relationship 1: 1 mapping
  4. binary relationship 1:M mapping
  5. binary relationship N:M mapping
  6. mulit-valued attribute mapping
  7. n-ary relationship mapping
  8. super & subclasses

1 - 7 mapping of ER
8 mapping of EER

29
Q

entity mapping?

A

non-weak entity with simple attributes

DON’T include multi-valued and derived attributes

CHOOSE ONE primary key attribute

30
Q

weak entity mapping?

A

create relation for weak entity and their corresponding owner entity

include FK attributes as weak entity PK with dotted underline

PK of weak entity is combination of owner entity + weak entity PK’s

rules do not change when multiple owners exist

DON’T FORGET WEAK ENTITIES AND THEIR RELATIONS ARE REPRESENTED WITH DOUBLE LINES

31
Q
A