UNIT 2 Flashcards

1
Q

What do you mean by relational model?

A

Represents the database a collection of relations.
Relation is a concept from set theory.

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

What do you mean by a flatfile?

A

Any files that are stored in the local database as opposed to the other complex files that are stored in structured databases.
The records present in flat files are generally stored in sequential order without any metadata.

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

What do you mean by a flatfile?

A

Any files that are stored in the local database as opposed to the other complex files that are stored in structured databases.
The records present in flat files are generally stored in sequential order without any metadata.

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

How does a flat file table organize its data?

A

Using a single table.

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

What are the problems with flat file database?

A

As the data is stored in a single table, there will be repeated data that might cause modification errors. (updated anomalies).
ERRORS: Might miss a record when you update the table.
Might miss a record when you delete details.
May not be able to insert new details without other details.

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

How do you solve the problem with the flat file database?

A

By using relational database instead of flat fie database. RD used multiple tables instead of a single one in order to avoid redundant data.
This process of converting flat file database to relational database is called as NORMALIZATION.

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

How does the relational database solve the problem?

A

Updates are less prone to errors.
Less storage is required as the data has to be stored only once now.

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

Informally describe what is present in the relational database?

A

Relation - set of values.
Row - tuples - has certain facts which describe the data elements in each row - entities/ relations.
Column - Column header - describes the data items present in that particular column.

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

Give the formal definition / words for the following:
table, row, column, set of values, table defn, populated table.

A

Relation
tuples
attribute
domain
schema
state of relation

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

What do you mean by a key? What do you mean by a surrogate key?

A

Value in a tuple/row that uniquely identifies the row in a table is called as a key.
Surrogate Key: Sometimes seq num and row_id’s are used as a key to uniquely identify a row in the table. This is called as surrogate key.

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

What do you mean by a schema?

A

Schema is the definition of a relation.
It is denoted by: R(A1,A2,…..AN).
R = Relation name
A1… AN = attribute name
Each of these attribute has a set of domain or set of valid values.

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

What do you mean by a tuple?

A

Tuple is an ordered set of values. Each value is derived from a domain.
Row present in a particular relation will be a set of tuples. (Customer relaiton - 4 tuple values )
Relation is a collection of such rows.

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

What do you mean by a domain?

A

It has a logical definition.
It has a datatype and a format defined for it.
Like date or phone numbers.
Attribute names which are used designates the role which is played by each domain in a particular relation.

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

What do you mean by relation state?

A

It is the subset of cartesian product of all domains of its attributes.
Each domain has all set of values that the particular attr can take.

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

What are the different characteristics of relation?

A

Ordering of tuples in Relation r(R).
Ordering of attributes in Relation schema R.
Values in the tuple.

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

How are all values considered in a tuple?

A

They are considered atomic or indivisible,

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

What do you mean by constraints? What are the different types of constraints?

A

Constraints determine which values are permissible and which values do not belong to the dataset.
Three types of constraints:
i) inherent / implicit - Based on the model itself.
ii) schema based / explicit - Based on the facilities provided by the model.
iii) application based / semantic - Beyond the expressive power of the model and enforced by the application programs.

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

What do you mean by a valid state?

A

It is a database state that satisfies all the constraints in the defined set of integrity constraints.

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

What are the main types of constraints?

A

Domain
Key
Integrity - entity integrity
Referential integrity

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

What does domain constraint specify?

A

Domain constraint specifies that within each tuple, the value present for each attribute must be an atomic value from the domain of that attribute. D(A).
Every value must be from the domain of that attribute.

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

What are the different types of keys present?

A

Primary Key
Super Key
Candidate Key
Foreign Key

21
Q

What do you mean by super key and what are the constraints applied on it?

A

Set of attributes Sk of R for which following conditions are applied.
- no two tuples in state r(R) can have same values for Sk.
-

22
Q

What are the two properties that the Key of R follows?

A

Two distinct tuples in any state can not have identical values for all attributes in a key.
minimal super key - A key is a superkey such that removal of any attributes from K results in a set of attributes that is not superkey, i.e they do not posses the properties of the superkey

23
Q

Relatioship between the superkey and key

A

Any key is a superkey, but any superkey is not a key
Any set of attributes that includes a key is a superkey
Minimal superkey is also a key and is time invarient

24
Q

Can the relational schema have more than one key?

A

Yes, it can have more than one key, and this particular condition, each of those keys will be called as a candidate key.

25
Q

What happens when there are several candidate keys?

A

When there are several candidate keys, we have to chose one of them as the primary key. The primary key is underlined.
Primary key uniquely identifies every tuple in a relation.
It can also be used to reference one tuple from another tuple.
Chose as primary key the smallest of all the candidate keys in terms of size.

26
Q

What do you mean by relational database schema?

A

Set S of relational schemas that belong to the same database.

27
Q

What do you mean by realtional database states?

A

Is a set of relation states such thar ri is a state of Ri and such that ri relation satisfies the integrity constraints specified in IC.
They are also called as relational database instances or snapshots.

28
Q

Entity integrity?

A

The primary key attributes cannot have null values.
If PK has several attributes then none of it should be null as PK is used as an identifying value for that tuple.

29
Q

Referential integrity?

A

The constraint involves 2 relations. One is referencing and the other one is referenced.
The tuples in Referencing relation R1, have foreign key attributes that are used to map to the Primary key attributes of the referenced relation.

30
Q

What are the two rules that apply to the foreign key?

A

Attributes in FK have the same domain as primary key attributes PK of R2.
Value of FK in a tuple can either be a value or it can be null.
if t1[FK] = t2[PK] Then we can say that t1 references to t2.

31
Q

How do you display a relational schema?

A

A relation schema is displayed as a row of attribute names.
The relation name is displayed above the attribute names.
The primary key attribute is underlined.
The foreign key is displayed as an arc from the foreign key attributes to the referenced table.

32
Q

What are the other types of constraints that are available?

A

semantic integrity constraint: application semantics, and cannot be expressed by model.
State constraints: explains the constraints that a model should have in order to be valid
Transition constraint: Deals with the transition of states.

33
Q

What actions should be taken in case of an integrity violation?

A

Cancel the operation
Perform operation but inform the user about the violation
Perform the updates so as to rectify the operation
Execute a user specified error correction operation

34
Q

What are the steps that are to be followed to make ER to relational mapping?

A
  1. Mapping of regular entity types
  2. Mapping of weak entity types
  3. Mapping of Binary 1:1 Relationship types
  4. Mapping of Binary 1:N Relationship types
  5. Mapping of Binary M:N Relationship types
  6. Mapping of Multivalued Attributes
  7. Mapping of N-ary Relationship types.
35
Q

What are the goals during mapping?

A

Preserve all the information
Minimize null values
Maintain all constraints as much as possible

36
Q

In mapping of weak entity types, what is the primary key of the newly created relation?

A

It is the combination of the primary keys of owner and partial key of the weak entity type W.

37
Q

What are the three possible ways of mapping binary 1:1 relation types?

A

1) Foreign key approach: Chose one of the relations say S and use as foreign key, a primary key of T. (Chose the one with total participation for S)
2) Merged Relation: Merge 2 entity types and its relationship into one relation.
3) Cross referencing: Create a new relation R for the purpose of cross referencing.

38
Q

What do you mean by relational algebra?

A

Basic set of operations for the relational model.
They are a collection of algebraic operators that are defined on relations.
Enable a user specify basic retrieval operations.
Result of an operation = relation
Algebra is closed.

39
Q

What do you mean by relational algebra expression?

A

A sequence of relational algebra operations.

40
Q

What are the different groups of operations from relational algebra?

A

UNARY - SELECT, RENAME, PROJECT
BINARY - JOIN, DIVISION
SET THEORY - UNION, INTERSECTION, DIFFERENCE, CARTESIAN PRODUCT
ADDITIONAL - OUTER JOINS, OUTER UNION, SUM, COUNT, MIN, MAX, AVG.

41
Q

What do you mean by type compatibility?

A

Required for the binary set. It is needed for union, intersection and set difference.
R1 AND R2 are type compatible if:
They both have the same number of attributes.
Both their domains are type compatible.

42
Q

What are the different types of join operations?

A

Inner join:
Equi join
Natural join
Outer Join:
Left outer join
Right outer join
Full outer join

43
Q

What does the join operation signify?

A

It is mainly describing the cartesian product followed by a select operation.

44
Q

What is the most general case of JOIN operation?

A

It is theta join.
Where theta can be any general boolean expression on the attributes of R and S.

45
Q

Does JOIN operation preserve all the data?

A

No, the join operation eliminates all the tuples whose attributes are NULL and whose join condition give out a false.

46
Q

What is the main use of natural join operation?

A

It is used to remove the second or the superfluous attribute in an equijoin condition.

47
Q

What is the main condition that is needed for the NATURAL JOIN?

A

It requires that the two join attributes or each pair of corresponding join attributes, have the same name in both the relations.
If it is not the case then renaming would have to be done first.

48
Q

What will be the result if no combination of tuples satisfy the join condition?

A

Then the result will be an empty relation with zero tuples.

49
Q

What do you mean by join selectivity?

A

It is a property of every join condition which is the ratio between the expected size of the join result and maximum size which is nr*ns

50
Q

What operations make up the complete set of operations?

A

SELECT, PROJECT, UNION, DIFFERENCE, CARTESIAN PRODUCT

51
Q

Define the sequence in which the division operation can be expressed.

A

Pi, * and -