Relational Data Model Flashcards

1
Q

What is a Database Schema?

A

Database Schemas
• A database schema is a set of relation
schemas
• A relation schema has a name, and a set
of attributes (+ types):

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

Explain difference between Schema vs Instance

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

Explain how you go from Schema to Database.

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

Why should we have relations in databases?

A

Why relations?
• Relations often match our intuition
regarding data
• Very simple model
• Has a good theoretical foundation from
mathematics (set theory)
• The abstract model underlying SQL, the
most important database language today

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

Explain Keys

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

What are composite keys?

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

What are the things to avoid when construction databases?

A

Things to avoid!
• Redundancy
• Unconnected relations
• Too much decomposition

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

Describe a database schema

A

A database schema is a blueprint
- Consists of a set of relations e.g. Courses(code, name, teacher)
where “Courses” is the relation name and code, name and teacher are
attributes.

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

What are tuples?

A

A database instance holds actual data

  • Tuples are instances of a relation.
  • E.g. (‘TDA357’, ‘Databases’, ‘Mickey’)

In a DBMS, a table holds relations where:

  • Each row holds a tuple
  • Each column stores a different attribute
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a DBMS?

A

Data Base Management System

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

What are keys?

A

Keys uniquely identify the other values of a tuple in a relation
- Composite keys combine several attributes

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

What is the Entity-Relationship approach

A

The Entity-Relationship approach
• Design your database by drawing a picture
of it – an Entity-Relationship diagram
– Allows us to sketch the design of a database
informally (which is good when
communicating with customers)
• Use (more or less) mechanical methods to
convert your diagram to relations.
– This means that the diagram can be a formal
specification as well

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

Which are the three main elements of an E/R diagram?

A

E/R Model
• Three main element types:
– Entity sets
– Attributes, and
– Relationships

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

What are entities?

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

What are Entities set?

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

What are Attributes?

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

What is a Relationship?

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

How to translate E/R to Schema?

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

Explain the usage of References

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

What is a Foreign Key?

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

Can relationships have attributes?

A
22
Q

Can a relationship have a key?

A
23
Q

How to differentiate between entity and relationship?

A
24
Q

Describe a Many-to-Many Relationship.

A
25
Q

Describe a Many-to-One relationship.

A
26
Q

Describe a Many-to-”exactly one”.

A
27
Q

Describe a “One-to-One” relationship.

A
28
Q

How do you translate Many-to-Many relationship?

A
29
Q

What does NULL mean?

A
30
Q

Is this a good or bad design?

A
31
Q

When should we model something as an
entity in its own right (as opposed to an
attribute of another entity)?

A
32
Q

How to translate this?

A
33
Q

Translate schema.

A
34
Q

Translate to schema.

A
35
Q

Translate to schema.

A
36
Q

Explain SubClassing.

A
37
Q

Explain what ISA means in this context.

A
38
Q

Can a subclass have many superclasses?

A
39
Q

How to Translate ISA to relations?

A
40
Q

What are 2 Alternate ISA translations to the E-R approach?

A
41
Q

How is E-R in comparison to Object Oriented and NULL approach?

A
42
Q

How does Object Oriented compare to E-R and NULL approach?

A
43
Q

How does NULL compare to the E-R and Object Oriented approach?

A
44
Q

What are Weak Entities?

A
45
Q

What are Weak Entities dependent on? How do you draw a Weak Entity?

A
46
Q

How are Weak Entities’ discriminator drawn?

A
47
Q

Explain how Multiway Relationships can be modeles as Weak Entities.

A

Multiway relationships as WEs
• Multiway relationships can be transformed
away using weak entities
– Subtitute the relationship with a weak entity.
– Insert supporting relationships to all entities
related as ”many” by the original relationship.
– Insert ordinary many-to-one relationships to
all entities related as ”one” by the original
relationship.

What’s the point?
• Usually, relationships work just fine, but in
some special cases, you need a weak
entity to express all multiplicity constraints
correctly.
• A weak entity is needed when a part of an
entity’s key is a foreign key.

48
Q

Should you use Multivalued Attributes?

A

”Multivalued” attributes
• Inflexible if you later want more attributes on
teachers.
• No guarantees against e.g. spelling errors of
teacher names.
– less flexible to insert a constraint on what values are
allowed than to use an extra table.
• Tables are cheap – references are cheap
– No reason NOT to use an entity.
• Rule of thumb: Don’t use multivalued attributes!!

49
Q

Should you use “Flag” attributes on relationships?

A

”Flag” attributes on relationships
• Less intuitively clear.
• Inflexible if later you need more roles.
• Tables are cheap, union of two tables is a cheap
operation (O(1)) – filtering can be expensive (O(n))!
• Only benefit: automatic mutual exclusion (a teacher can
only be either responsible or an assistant).
– If important, can be recovered via assertions (costly).
• Rule of thumb: Don’t use flag attributes on relationships!

50
Q

Does and don’ts of special relationships?

A