Exam 2 Flashcards

1
Q

Will the Database Application Develop Methodology work for general application development?

A

No

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

Database Application Development Methodology - Assumptions that must hold

A
  • Business processes are well-designed
  • Documents (input to our output from apps on the db) are known
  • Tasks (the processing of those documents) are known
  • System boundary is known
  • One database schema unifying all views can be designed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Troubles with creating one database schema to unify views?

A

Can be difficult because: Interests, goals, power, politics

Question: is that a problem with…

Problems with methodology?

Problems with Organization?

Answer: Organization.

Because Oraganization = an entity created to pursue a shared set of goals

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

Typical waterfall software development steps?

A
  • Business Process design
  • Analysis
  • Specification
  • Design
  • Implementation
  • Testing
  • Operation
  • Maintenance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Software dev steps that are unique to database methodology?

A

<those>bold&gt;</those>

  • Business Process design
  • Analysis
  • Specification
  • Design
  • Implementation
  • Testing
  • Operation
  • Maintenance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In database application method, which is first?

A

Data is First

In contrast, other software dev, process often first

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

What are the steps of databse application development?

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

Information Flow Diagram (IFD) shapes

A
  • Elipses = Tasks
  • Rectangles = documents (input and output screens)
  • Arrows = information flow (NOT CONTROL FLOW)
  • Broken line = system boundary

Never connect 2 tasks

Never connect 2 documents

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

What goes into the database?

What comes out of the database?

A
  • Everything in the database must come from somewhere
  • Everything on the input documents must go somewhere
  • Everything in the database must be used for something
  • Everythingo n the output documents must come from somewhere

Lecture 17 - Lesson 3

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

Constraints - how to include them?

A

There are constraints from the data format.

There are constraints from the EER diagram.

Any other constraints are those that have to be coded into the program.

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

Data formats - How to get?

A

Beg, borrow and steal from existing sources.

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

Rules for Task Decomposition

A
  • Lookup very different vs. insert, delete and update (why? because different “locks” for lookups)
    • If task has many different of these, should likely be decomposed
  • How many schema constructs are involved (requires many locks)
    • Would want to decompose task when many schemas
  • Are enabling conditions consistent across tasks?
    • (easier to run now, when there are resources, so run what you can)
  • Are frequencies consistent across tasks?
    • (if some have high and some have low frequencies, split them)
    • Reason is because you might want to index high frequency things
  • Is consistency essential?
    • (Depends on task, money transfer yes)
    • (ACID transaction properties?)
  • Is mother task control needed or not?
    • Sometimes you do, others you don’t
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Web-based apps features

A
  • Traditionally, almost stateless
    • Must have some state, like user email
    • May need some click stream history
  • Advent of things like AJAX allow more state which allows web-based apps to act more like traditional apps
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Traditional Apps (as opposed to web-based)

A
  • Much easier to manage local state separate from the DB
  • Lots of changes can be collected before submitting them to the DB
    • Means you don’t need a round trip to the DB everytime a minor thing is changed
  • Supports better control of ACID transactions execution
    *
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Formatting for abstract code

A

BoldUnderline: Task definition

Bold: Task call

Italics: Button names

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

Relational Model Terms

A

Row = Tuple

Column header = attribute

Table = relation

Data type = domain

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

Domain (definition)

A

Set of atomic values (i.e. indivisible)

Often specified by a data type

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

Domain Components

A

Comprise a name, datatype and format

Logical definitions = e.g. “set of valid 10-digit us phone numbers”

Datatype or format = (ddd) ddd-dddd where d = decimal

Unit types (optional) = kg

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

Relational Scheme

A

Name = relation name

Attributes are name of a domain in the schema (i.e. column)

Degree = number o attributes

Dom(attribute) = domain of the attribute

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

Relation

A

Set of rows

Each row has n-tuples

n = degree and number of attributes

Schema = intension

Actual rows = extension (i.e. state)

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

Domains can be same in attributes?

A

Yes (just data type).

But attributes play different *roles* in the relation

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

Difference between relation (mathematically defined) and the table or flat file (actual content)

A
  • Order of tuples does not matter in relation, but exists in a table or flat file
    • (therefore tables with different orders are considered identicle)
    • Driven because relation = set of n-tuples
    • Sets don’t have order in math
  • Technically, n-tuple described as ordered list from math, but in reality, order of attributes shouldn’t matter
    • Can re-define a tuple as a set to make it mathematically not care about order
    • Makes two differently orderd tuples identicle
    • Requires “dictionary” format (name:value) which is called *self-describing data*
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Are tuple valus mult-valued or atomic?

A

Must be atomic

Called flat relational model

Assumption was a lot of relational theory

Assumption called first normal form

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

Null value types

A

Value unknown (i.e. not sure if exists)

Value not available (i.e. know it exists, but don’t have it)

Attribute does not apply (value undefined)

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

Interpretation of a relation

A

Can be assertion that an entity or relationship has attributes.

  • Each tuple then is a fact
  • Can be facts about entities or relationships (hard to tell each)

Alternatively, can be a predicate. The values are values that satisfy the predicate. Useful for logical programming.

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

What is the closed world assumption?

A

Only true facts of the universe are those present in a extension (state).

Any other combincation would make a predicate false.

Useful for relational calculus.

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

Types of constraints

A
  1. Implicit constraints or inherent model-based constraints = Those inherent in the data model
  2. Schema-based constraints or explicit constraints = Those that can be expressed direclty in the schema (typically specified in the DDL)
  3. Application-based or semantic or business rules = Constraints that cannot be explicity in the schema or data model and must be enforced in the application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Types of schema- based constraints

A
  • Domain constraints
  • Key constraints
  • Constraints on NULL
  • Entity integrity
  • Referential integrity
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Domain Constraint

A

Specifies each attribute is atomic and of a specific domain

Domain could be a standard type or could be specified as a sub-set or even enumerated as explicit, possible values

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

Definition of relation

A

A set of tuples

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

Key constraint

A

That any given tuple is has a unique set of values.

This follows from fact that a relation is a set of tuples (and sets don’t have duplicates)

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

Superkey of a relational scheme

A

The subset of attributes in a tuple that would establish the uniqueness constraint

Every relation has one default superkey: the set of all its attributes

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

Key in a relational scheme

A

Like a superkey but if you remove any attribute, it is no longer a superkey (i.e. doesn’t have redundancy like a superkey).

Basically rules are:

  • All its values are unique for a tuple
  • Can’t remove any values and still have uniquness constraint hold
34
Q

Is a key a superkey?

A

Yes. A key is a superkey but not vice versa.

Reason is a key removes all redundant attributes.

35
Q

What if there is more than one key in a schema?

A

Both keys are candidate keys

Usually one key is designated the primary key

The other candidate keys are called unique keys

36
Q

Constraints on attributes

A

Must be unique to a tuple

Must specify which values can or cannot be NULL

Key must be time invariant (i.e. as new rows added)

37
Q

How do you translate the following from an EER diagram to a relational database:

  • Entity
  • Attribute
  • Identifier/key
  • Composite attribute
A
38
Q

How does the relational model handle multi-valued attributes?

A
39
Q

How do you map 2 entities (from an EER diagram) into the relational model?

A

You put the primary key for one entity as a column in the other entity.

You only choose one to do this to.

It doesn’t matter which UNLESS, there is a mandatory participation relationship (see other card)

40
Q

How do you show a relationship with 2 entities in a relational database, when one has a mandatory participation relationship with the other?

A

This is better because it means every ET2 definitively has a relationship with an ET1, whereas if you had it the other way, that would not have to be the case.

41
Q

How do you map a 1 to N relationship between entities in a relational model?

A

You have to map each instance of the many relationship to a given key of the 1 relationship.

The reason is because, if you did the other way, the 1 relationship would have a field that has to map to many instances of the N relationship and that doesn’t work (i.e. one column mapping to many primary keys).

42
Q

How do you show a M to N relationship in a relational model?

A

You can’t simply add the primary key for one entity as a field to another entity’s table.

Instead, you have to create a new table (R, say) that has both the primary keys from each entity.

The primary key in R is a combo of the two primary keys.

43
Q

How do you represent an identifying relationship betwen a strong entity ET1 and many a weak entity ET2, in a relational model?

A

ET2 can’t exist without an ET1 (per the ownership relationship).

So the ET2 table is actually identified by an ET1 key in the first column and ET2 keys in the second.

This is done for all the many ET2 instances.

Together, each of these form key for an instance in ET2.

44
Q

How do you represent a disjoint relationship between an entity ET and its subclasses ET1 and ET2, if ET has a mandatory relationship to its subclasses?

A

Because the subclasses might have their own attributes that the superclass doesn’t have, we don’t do a table for ET.

We do a table for ET1 and another for ET2. Both have all the attributes of ET.

They also then have the unique attribute to their subclass.

45
Q

What is “a foreign key onto ET”?

A

When there is a second table for ET1, say, with the same key as ET, we say the reference from ET1 is “a foreign key onto ET”.

We also draw an arrow from ET1 to ET.

46
Q

How do we handle a mandatory overlapping relationship between a superclass and its subclass, in a relational model?

A

Recall that with an overlapping (assuming a mandatory participation), the superclass is also a member of one subclass, the other or both.

There are two options for representing this (second preferred).

First, you can have one table that includes a field (column) for each of the overlapping subclass entities. Then you include another column that specifies the “Type” of relationship (e.g. it has one, the other or both entities)

Second, you can create three tables: ET, ET1 and ET2, each with the same primary key + the attributes from the subclasses. It just means that the instance shows up in all tables, which Prof was OK with

Lesson 6: Lecture 9

47
Q

How do we show NON-mandatory relationship between superclass and subclasses that have overlap?

A

Same as with mandatory relationship to overlapping subclasses.

Only difference is the key from ET might not have any instances in ET1 or ET2.

48
Q

How do you representa NON-mandatory, disjoint relationship in a relatoinal model?

A

Similar to the non-mandatory for overlapping relationship.

As far as I can tell, though, you’d have to use business logic to ensure the instance doesn’t show up in either disjoint table.

49
Q

How do you represent a union type in a relational model (with ET, ET1 and ET2)?

A

Create an “artificial identifier” in the relation ET, possibly comprising an element of ET1 or ET2.

Then have that identifier show up in ET1 or ET2, whichever one it is associated with, like any other relationship.

These will be foreign keys to the ET identifier in ET.

50
Q

What is “Closed Algebra”

A

For every rational number you give you get a rational number back.

You get the same kind as the operands you started.

Helps you formulate “high level models” based on previous thoughts (i.e. previous calculations)

51
Q

What are the relational algebra set operators?

A

Set operators:

R U S = union

R Π S = intersection

R \ S = set difference

R x S = Cartesian Product

π A1, A2, … An (R) = project (think of as eliminating columns)

σexpression (R) = selection (think of as eliminating rows)

52
Q

What are the relational algebra join (or construct) operators?

A

Join Operators:

R * S = natural join

R [something] S = outer joins (left, right, full)

R [something] S = theta-join (similar to universal quantification in relational calculus)

R [something] S = divideby

[greek p] = rename (lets you somehow combine joins and set operators)

53
Q

How does a selection operation work?

A

Select… all the tuples from relation R… that satisfy this expression

No expression selects all tuples (i.e. rows)

The usual symbols work to form expressions

54
Q

How do composite expressions work in selections?

A

Similar to other math and code:

They can use AND and OR, parentheses or NOT.

55
Q

How does projection work?

A

Projection returns the attributes listed for the given expression or relation.

Basically creates a “view”

NOTE: This is an example of “closed” algebra. It takes a “relation”, does “selection” on that relation in the parentheses, that yields a relation, which then we do projection on.

Every step is a relation so you can keep apply operations to them.

56
Q

Relations are or are not sets?

A

Relations are sets!!

So if a view only shows a unique row once.

57
Q

How does the union operator work?

A

Union puts the results of relation in one attribute or result (e.g. home town U current city => cities)

It is the two circles of a Venn + the overlap.

NOTE: The operands of the operator need to be type compatible (i.e. same number of attributes and pairwise same types)

For example, with a union of two projections, the projections have to have only one attribute each.

58
Q

How does the Intersection operator work?

A

Intersection finds the just the overlapping items between two attributes and returns them as a relational attribute.

In the Venn diagram, it is just the overlap.

59
Q

Conceptually, how does set difference work?

A

Basically includes all of one set MINUS the items of overlap from another set.

60
Q

Mechanically, how does set difference work?

A

Basically takes attributes of a relation, keeps the main relation MINUS the items that are part of the other relation.

Returns a view of the items that remain.

61
Q

How does a natural join operator work?

A

Combines the two tables (i.e. doesn’t just keep the attributes queried… it MATCHES attributes in the tuples but gets the whole tuples that matchs and combines them.

Only includes tuples where attributes of the join have matching names (i.e. the same values)

  • For example, if the relations each of a year attribute, those are compared
  • If they ALSO have a sex attribute, that too would be compared

Has all attributes of both relations BUT only keeps only one copy of the matched attribute

It is an “inner” join because only includes tuples that match.

62
Q

What is a theta join operator?

A

Brings the attributes from both relations together in one view.

Does so by matching attributes based on a comparison expression (theta).

The attributes actually have different names (i.e. “BirthYear” vs. “EventYear”)

Also an “inner join” because it only includes tuples that match.

63
Q

How does a (Left) Outer Join work?

A

Combines the attributes of both relations.

Will, in particular, combine attributes that have a match in attributes (of the same attribute name I THINK?).

This is the “inner” part.

It will still include tuples that didn’t have matching attributes and the matched attribute will be NULL

These are the “outer” part

It is a “NATURAL” join ( think because same named attribute).

Is a special case of the theta join

64
Q

How does the cartesian product work?

A

Combines ALL tuples in the two relations.

For example (the image): user 4 in RU is combined with all users in UsserInterests

65
Q

How is Cartesian Product userful?

A

See the example image.

It is basically creating a table that has all possible combination of user and interests and then subtracting out anything the user is already signed up to.

The result could then be used to email the user what’s remaining.

66
Q

How does the divideby operator work?

A

The divideby basically takes the items on the left and then, if ALL values of an attribute on the right are part of a match, it grabs the OTHER attribute from there.

In other words, it is checking the 3 values that are the attribute for “Interest” and extracting any email + interest combo that has that.

Then is keeping only the email part of that resulting relation.

67
Q

How does the rename operator work?

A

Can beused to control natural join, theta join and others.

Lets you create a relation that replaces the name of attributes.

See example: main point is the expression, comma separated, where REPLACEMENT precededs ORIGINAL

68
Q

What is relational calculus?

A

Relational Algebra is procedural in nature (it’s operator based)… you take relations and join them, project them, do a selection. You say what to do step by step.

In calculus, you simply describe the result that you want.

69
Q

Is relational calculus higher-level and more expressive than relational algebra?

A

With respect to data-retrieval horsepower, they are equivalent.

SQL is mostly based on tuple calculus.

70
Q

Are queries in relational calculus procedural or declarative in nature?

A

They are declarative. Relational algebra is procedural.

71
Q

How to construct a relational calculus predicate?

A

See image

Also, mention in lecture about a “bound” variable: Lesson 10, lecture 20 (near the end)

72
Q

How do you write a selection in relational calculus?

A

In example, expression reads: find an r such that r is a member of RegularUser

73
Q

How do you do a composite expression in relational calculus?

A

See example

Basically reads like regular logic

74
Q

How do you do a projection in relational calculus?

A

See example

75
Q

How does union work in relational calculus?

A

Example is creating an attribute s.City.

And basically saying for every tuple in Regular user, s.City should equla current city OR same for hometown.

Then returns that as a set.

76
Q

How does intersection work in relational calculus?

A

In the example, the AND basically makes it so that only cities in both sides work.

77
Q

How does set difference work in relational calculus?

A

See example

78
Q

How does a natural join work in relational calculus?

A

See example

Interesting that the year are a comparison but the others are an assignment.

79
Q

How does cartesian product work in relational calculus?

A

See image.

Basically they just do (s,r | USER AND INTERESTS).

SEEMS like (based on lecture 30) that the part of this that means ALL of Regular User and ALL of UserInterests are mapped, is actually the s, r part.

80
Q

Tricky Cartesian Product in relational calclus

A

See image and look at lesson 10, lecture 30

81
Q

How does divideby work in relational calculus?

A

see example and lecture 31

82
Q
A