Database Systems Flash cards

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/75

flashcard set

Earn XP

Description and Tags

Revision cards for data base systems theory and SQL

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No study sessions yet.

76 Terms

1
New cards

What are the 3 types of database models?

High level - conceptual, user level

Representational level - Logical
Low level - physical, physical data storage

2
New cards

what is relational modelling?

a logical representation of data represented as a table

3
New cards

what 3 aspects of data is relational modelling concerned with?

Data structure
Data integrity - RI, constraints

Data manipulation - Relational Algebra

4
New cards

what is a relation?

An entity/table

5
New cards

what is a tuple?

a Row / Record

6
New cards

What is an Attribute?

A Column

7
New cards

what is a relationship?

A connection between entities

8
New cards

what is a relational Schema?

A textual representation of a data model

9
New cards

what is a Domain?

a set of values an attribute can take

10
New cards

what is a key?

one or more attributes to uniquely identify a tuple

11
New cards

what is a Candidate Key?

minimum set of keys which uniquely identify each Tuple

12
New cards

what is a primary key?

the chosen candidate key used ot uniquely identify each tuple in an entity

13
New cards

what is an Alternate key?

the remaining candidate keys

14
New cards

what is a Foreign key?

key that matches the candidate key in a relation - used to represent the relationships in tables

15
New cards

what is a Composite key?

key consisting of two or more attributes

16
New cards

what is the Entity integrity rule?

Constraint on primary keys, must be unique and not be null

17
New cards

what is the referential integrity rule?

constraint on foreign keys - must match candidate keys or be null

18
New cards

what does intersection do?

gets tuples from both entities, only lists the specific attribute

19
New cards

what does select do?

it gives only a horizontal subset

20
New cards

what does project do?

it gives only a vertical subset

21
New cards

what must two tables have to be union compatible?

they must have the same number of attributes and each pair of corresponding attributes must have the same domain

22
New cards

what does join do?

combination of cartisian product and select

23
New cards

what does Equi Join do?

keep both join columns

24
New cards

what does natural join do?

gets rid of duplicate columns - Tuples not included when join attribute is null or when they dont have matching types in other relation

25
New cards

what does Left outer Join do?

all tuples from R1, even unmatched ones, missing values for R2 corresponding tuples are set to NULL

26
New cards

what are the 3 types of attributes?

single valued - attribute contains a single value for tuple (eg. date of birth, can only have one DOB)

multi-valued - attribute contains multiple values for a tuple (eg. hobby, can have multiple hobbies)

Derived - attribtue derived from another attribute (eg. age from date of birth)

27
New cards

what is Multiplicity?

the type of relationship (eg. one to many, one to one, etc)

participation - min number, cardinality - max number

28
New cards

what is a degree?

number of entities - binary, ternary, etc.

29
New cards

what are the 3 types of abstraction?

classification - is instance of

aggregation - is part of / has part of

specialisation - is a subclass / superclass

30
New cards

what are the two participation types for specialisation?

mandatory participation - each instance of superclass must be a member of subclass (total)

optional participation - instance of superclass doesnt need to be a member of subclass (partial)

31
New cards

what is a ternary relationship?

a relationship with 3 entities

32
New cards

what is a strong entity?

an entity that doesnt rely on another entity’s existence (has a minimum of zero)

33
New cards

what is a weak entity?

depends on the existence of another entity partially or wholly. cannot be uniquely identified by itself

34
New cards

how to we take a conceptual model to a logical model?

  • resolve many-to-many relations

  • resolve non-binary relations

  • resolve hierarchal relationships

  • map to relational schema

  • add constraints

35
New cards

why dont we have many-to-many relations?

because of the atomicity of attribute values

36
New cards

how do we resolve to or hierarchy?

  • add new relation with new pk thats used for all the relations

  • flatten the table. add is_undergrad attribute, use Null where needed

37
New cards

what is meant by Fan Trap?

Rearrange the 3 tables

38
New cards

what is meant by Chasm Trap?

add another relation, done if you cant rearrange the relations.

39
New cards

what is Functional Dependency?

attribute depends on one another. A →B, B is FD on A

40
New cards

what is partial dependency?

only exists if PK is composite, full dependency

41
New cards

what does Normalisation do?

it eliminates undesired update anomalies and data redundancies

42
New cards

what is 3NF?

no transitive dependencies.

43
New cards

list the types of constraints.

  • CHECK

  • DEFAULT

  • UNIQUE

  • NOT NULL

44
New cards

in SQL, what does LIMIT mean?

it limits the amount of records returned

45
New cards

list the aggregation functions in SQL

  • COUNT

  • SUM

  • AVG

  • MAX

  • MIN

46
New cards

what does COUNT do in SQL?

can be used to count rows - COUNT(*)

47
New cards

what does GROUP BY do?

can be used to group records by a record.

all other attributes in the query not being used in an aggregation function must be grouped by…

group by also excludes records with 0 count.

48
New cards

what does EXISTS do?

checks if there is at least one row in a subquery

49
New cards

what does the WITH keyword do?

allows the reuse of a query in many places.

50
New cards

what does the UNION keywork do?

same as the union used in relational algebra.

51
New cards

what does the INTERSECT keyword do?

52
New cards

what does the EXCEPT keyword do?

only things from the first table, not the second.

53
New cards

what does the CREATE_VIEW function do?

it creates an immediate view of the virtual tables. it reflects the most recent changes.

it can also be used to restrict certain rows and columns from users.

54
New cards

what are DB integrity constraints?

Entity + ref integrity

55
New cards

what are App Constraints?

based on App logic.

56
New cards

what is a Transaction?

a unit of work that is carried out by a user or program, which accesses or changes the contents of a database.

57
New cards

what is ACID?

  • Atomicity - a transaction is either completed or aborted.

  • Consistency - if a database is in a consistent state before a transaction it should still be in one after. aka only valid data.

  • Isolation - partial effects of incomplete transactions should not be visible to other transactions. aka concurrent transactions do not affect eachother.

  • Durability - Once a transaction is committed, it must be permanent.

58
New cards

what is meant by Schedule?

its a sequence of ops by set of concurrent transactions.

59
New cards

what is meant by serial scheduling?

there is no concurrency in transactions.

60
New cards

what are the two types of concurrency control?

  • locking

  • timestamping

61
New cards

Define Locking

locking is when you need to acquire a lock on a data item to access it. multiple people can have read locks, where as only one can have write locks.

62
New cards

what are the phases for locking?

  • Growing phase - you keep getting locks incrementally. you cannot release locks.

  • Shrinking phase - all locks release on commit or rollback. Cannot get new locks.

63
New cards

Define Timestamping

Timestamping - each transaction gets a timestamp when it starts, transactions are ordered by these time stamps. DBMS keep a list of these timestamps with the latest being allowed to access the data.

R(x) - timestamp of transaction with latest read on x.

W(x) - timestamp of transaction with latest write on x

64
New cards

Define optimistic methods.

check for serializability violation before commit. Efficient when conflicts are rare. Read validation Write.

65
New cards

define Query processing

transform high level SQL to correct execution strategy in lower level language.

66
New cards

what are the 6 types of failure?

  • system crash

  • hardware failure

  • natural disaster

  • Human error

  • Transaction failure - deadlock

  • Media failure - disk failure

67
New cards

what is primary reliability?

avoiding single point of failure, back up power, UPS

68
New cards

give some examples of secondary reliability.

operating procedures, access control, backups.

69
New cards

what are the three types of log based recovery?

  • Normal - After normal shutdown, start from last log record.

  • Warm - After system failure (such as an undo or redo) revert to last checkpoint, apply last committed transactions, undo effects of uncommitted transactions.

  • Cold - After media failure (unexpected), restore from backup, apply log records.

70
New cards

what are the three types of file organisation?

  • Head unordered - records placed on disk in insertion order

  • sequential order - recorded placed on a disk in order of value of specified field.

  • Hash files - based on hash function.

71
New cards

what are the pros and cons of using head unordered?

-pros_

  • quick insertion

  • good for bulk loading data

-cons-

  • slow retrieval

  • slow for selective retrieval, not good for tables with frequent changes.

72
New cards

what are the pros and cons of using sequential ordered?

-pros-

  • efficient retrieval (on binary search)

-cons-

  • bad insertion and deletion

73
New cards

what are the pros and cons of using hash files?

-pros-

  • good for exact matches

-cons-

  • bad for range retrieval, pattern matches, and searches on fields other than key.

74
New cards

define an index file.

each record contains search key values and address of the record in the data file containing search key value. this makes finding a row quicker. use indexes for columns often in the where clause.

75
New cards

what is meant by the operator NEW

store copies of values of new row

76
New cards

what is meant by the operator OLD

store copy of old row before update / deletion