Showing posts with label DBMS. Show all posts
Showing posts with label DBMS. Show all posts

Wednesday, January 8, 2014

Terminologies used in Databases

(i) Data Item: It is the smallest unit of data. It may be derived, atomic, composite or embedded.


(ii) Database: It is a repository of stored data which is both integrated (i.e. unified with reduced redundancy) and shared.


(iii) Data Base Management System (DBMS): It records and maintains information (meaningful data). DBMS software hides all the details of data stored and present it to user in desired operation. Some functions include add, delete, read, modify, and special functions like sorting and math functions. 


(iv) DBMS software may follow hierarchical, network, or relational data model. Latest DBMS also make use of object oriented concepts and may be Object DBMS (ODBMS), Object Oriented DBMS (OODBMS) or Object Relational DBMS (ORDBMS). However, use of RDBMS is most prevalent. 


(v) RDBMS: RDBMS software is based on relational data model and follows relational algebra. RDBMS stores data about attributes of some entities in form of related tables where each table comprises of rows and columns. Some common RDBMS are MS Access, Oracle, MySQL, PostgreSQL.


(vi) Entity: Items about which relevant information is stored. For e.g. Employee, machine part etc.


(vii) Attributes & Domains: Columns of a table are referred to as attributes. A domain is a pool of values from which actual values appearing in a given column are drawn. E.g. COLOR can be an attribute in a table and values like red, orange, green etc. constitutes its domain.


(viii) Tuples & Records: Tuples in a relation represents the records which are the rows in a table. For e.g. in a table for employee, there may be records for me, you, friend etc


(ix) Schema: A schema is a logical database description and is based on types of data being used. It gives name of entities and attributes and specify the relationship between them (which could be one-one, one-many, many-many or even conditional). It is a framework into which values of data item can be fitted. Schema is DBMS independent and remains same, however, values may change over time.


(x) Keys: Some attribute or combination of attributes in a table forms the keys. These keys could be Super Key, Candidate Key, Primary Key, Alternate Key, or Foreign Key. A primary key is used to uniquely identify a record in a table. A foreign key is one which is primary key in another relation (i.e. table) and helps in linking the tables. 


(xi) Database Design: It could be conceptual, logical, or physical. A data modeler does the conceptual database design by studying and modeling the data in technology independent manner. A database designer (or may be Data Base Administrator, DBA) does the logical database design by mapping or translating the conceptual data design into logical database design to fit in the chosen data model (relational, object relational etc.). Physical database design is done by DBA by translating logical design into one or more physical design – each tailored for particular DBMS which will manage the database and particular computer system that will run the database.

Codd's 12 Rules for RDBMS

Rule 0: The system must qualify as relational, as a database, and as a management system.
For a system to qualify as a relational database management system (RDBMS), that system must use its relationalfacilities (exclusively) to manage the database.
Rule 1: The information rule:
All information in the database is to be represented in one and only one way, namely by values in column positions within rows of tables.
Rule 2: The guaranteed access rule:
All data must be accessible. This rule is essentially a restatement of the fundamental requirement for primary keys. It says that every individual scalar value in the database must be logically addressable by specifying the name of the containing table, the name of the containing column and the primary key value of the containing row.
Rule 3: Systematic treatment of null values:
The DBMS must allow each field to remain null (or empty). Specifically, it must support a representation of "missing information and inapplicable information" that is systematic, distinct from all regular values (for example, "distinct from zero or any other number", in the case of numeric values), and independent of data type. It is also implied that such representations must be manipulated by the DBMS in a systematic way.
Rule 4: Active online catalog based on the relational model:
The system must support an online, inline, relational catalogthat is accessible to authorized users by means of their regular query language. That is, users must be able to access the database's structure (catalog) using the same query language that they use to access the database's data.
Rule 5: The comprehensive data sublanguage rule:
The system must support at least one relational language that
  1. Has a linear syntax
  2. Can be used both interactively and within application programs,
  3. Supports data definition operations (including view definitions), data manipulation operations (update as well as retrieval), security and integrity constraints, and transactionmanagement operations (begin, commit, and rollback).
Rule 6: The view updating rule:
All views that are theoretically updatable must be updatable by the system.
Rule 7: High-level insert, update, and delete:
The system must support set-at-a-time insertupdate, anddelete operators. This means that data can be retrieved from a relational database in sets constructed of data from multiple rows and/or multiple tables. This rule states that insert, update, and delete operations should be supported for any retrievable set rather than just for a single row in a single table.
Rule 8: Physical data independence:
Changes to the physical level (how the data is stored, whether in arrays or linked lists etc.) must not require a change to an application based on the structure.
Rule 9: Logical data independence:
Changes to the logical level (tables, columns, rows, and so on) must not require a change to an application based on the structure. Logical data independence is more difficult to achieve than physical data independence.
Rule 10: Integrity independence:
Integrity constraints must be specified separately from application programs and stored in the catalog. It must be possible to change such constraints as and when appropriate without unnecessarily affecting existing applications.
Rule 11: Distribution independence:
The distribution of portions of the database to various locations should be invisible to users of the database. Existing applications should continue to operate successfully :
  1. when a distributed version of the DBMS is first introduced; and
  2. when existing distributed data are redistributed around the system.
Rule 12: The nonsubversion rule:
If the system provides a low-level (record-at-a-time) interface, then that interface cannot be used to subvert the system, for example, bypassing a relational security or integrity constraint.
(Source: Wikipedia)
Importance Level: Usually asked in interviews of those who claim to have worked in field of databases
:) In fact, the rules are so strict that all popular so-called "relational" DBMSs fail on many of the criteria
To-do: Figure out which RDBMS support how many rules

DBMS Vs. RDBMS: Some viewpoints taken from internet


  • In DBMS tables are not related, In RDBMS tables are related.
  • In DBMS only one user can access the same database at the same time, In RDBMS many users simultaneously access the same database.
  • RDBMS is more secure than DBMS.
  • In DBMS store and retrieve small amount of Data In RDBMS store and retrieve large amount of Data.
  • The database which follows Codd's atleast 6 rules is called as RDBMS.

Sunday, June 23, 2013

Relational Algebra, Functional Dependency, Normalization and Decomposition

Relational Algebra
Select Operation
select tuples that satisfy given predicate
the predicate is the where clause
lowest number of tuples selection operation can return is zero and at most n when relation r has n tuples

Project operation
Project operation selects the columns which should be retrieved
that is similiar to select A,B,C from .... where to select only column A B C we need to use project
eliminates duplicates
so a projection on relation r may return at most n tuples, if relation r has n tuples, if all distinct tuples and will return 1 if all same tuples
it restricts the columns unlike selection which restricts rows

Union operation
tuples that appear in either of two relations or both of them
union should be taken on compatible relations
conditions or union opearator to be valid
a) relation must have same number of attributes
b)domain of the attributes must be same

Set difference
tuples in one relation but not in another
same condition like union holds for set difference operation also that is arity and domain condition

Cross product
argument should have distinct names, distinguish same attribute name with table alias
tuple for each pair of tuple in r and s
n1*n2 number of tuples in crossproduct
to get the correct result from cross product we need to identiy tuples in r with tuples in s
that is some condition of the form (r.A = r.B and .. )

Rename operation
allows us to give name to the relation expression
example
a way to find the maximum balance like max function in sql is like
select all those balances which are not greatest that  is they are less than some other value
and subtract them from the available balance values
we can use positional parameters $1 $2 to address the attributes instead o giving them names

Additional operations this can be expressed in terms of fundamental operations
Set intersection
can be rewritten with set difference like
r intersection s = r- (r-s)

Natural join operation
allows to combine certain selection and cartesian product in single operation
in terms of fundamental operation
1)first get the same column names R intersection S which gives same attributes that is {A1,A2..}|
2)perform selection with matching these columns like {r.A1 = s.A1 and r.A2 = s.A2..} in predicate
3) perform projection for R union S attributes
does not returns duplicate tuples
natural join is associative
when no attributes in common that is R intersection S = empty then it returns cartesian product
natural join would return only one attribute for common attribute from r and s


Theta join

Division operation
for queries with statement like 'for all'
S attribute set is subset of R every attribute of S is also in R
r / s is relation on the schema R-S( all attributes in R not in S) that is it contains only attributes R-S
conditions
1)for every tupple ts in s there is a tuple tr in r satisfying

find tuples that donot appears in r that is from r x s - r that is all those tuples for which value in r exists for all values in s will be eliminated in this step then we can subtract is from r to get the required tuples
example
r be relation below and R={x,c}
x    c
-------
x1 c1
x2 c2
x3 c1
x3 c2

and S be relation below and S= {c}
c
--
c1
c2
we want to find those x for which there all c are mapped like x3 which has both c1 and c2 relation tuple
1)find those tuples which are not mapped
R-S = {x}
1)we find cross product   projection(r)_R-S * s_c  which will give all possible relations that is for each x there will be mapping for all c's
3) now we subtract r relation from above cross product which will eliminate all the tuples from r which are in s
we will be left with tuples which donot have all c mapped to x

Outer join

Tuple relational calculas
non procedural
{t| p(t)} set of all tuple t such that predicate P is true for t
{t | e r(Q(t))} r(Q (t)) is the relation of which t is tuple r is created from expression on relation
t[A] value of tuple on attribute A
the attribute on which we specify the condition is only contained in the final expression result

example
find loan number of each loan with amt > 1200
predicate t[loan_number] = s[loan_number] and s[loan_number] > 1200
so the result will have only single attribute loan_number

if there are two relations involved in the statement then we use there exist clause for each and connect them
implications if p then q


Translating to Tuple calculas form
1)if asked to find only A attribute then in the complete predicate we will use t on only A
2)if n relations are involved we need n tuple relation like u element of r,  x element o s ..
3)if we are using implication then we also need to specify what happen when this is not true like if we are asked to find all the customers who have account at all branches in brooklyn
if they have branch we can specify will predicall for all and implication but we also need to connect this relation with expression that tell include all customer names if no branch at brooklyn
4)for every wheare clause involving two relations we write it like
w is tuple such that on relation r {r[A] = s[B]}
5) If we are asked to find something like
find all projects which supplier S supplies entirely
find all the supplier which do not sell green color parts
first we find the complement that is in first case we find the projects which other suppliers also supply
and then subtract it from the project supplier S supplies
in second case we find suppliers which sells green  color parts and subtract them from supplier list

we write query like divison of RA in tuple calculas as
we use 'for all' clause on the relation s whose all attribute values should be mapped and we check for each value in s if there exist a tuple in r mapped to it

SQL

All aggregate function except count(*) ignores null values in input
all aggregate functions returns value of null when applied to empty collection
Nested queries
Set membership

some comparison returns true if  value of tuple is greater that atleast one
=some is identical to IN
<>some is not same as  NOT IN

Integrity constraint
Referential integrity
Child table or referencing table stores the foreign key that references the parent table or referenced table primary key
no insert can be done in the child table if corresponding foreign key does not exist in parent table
Rules
Restrict disallow the deletion or update of  referenced data that is deletion from parent table if not allowed
Set to Null set to null in referencing table associated data on update or delete
Cascade on update in referenced table update the associated data in referencing table and on delete in referenced table delete all associated dependent rows
No action  differs from Restrict in sense that checked at end of statement

Normalization
why use normalization
repetition of inormation, data will be repeated for each instance used in the relation,wastage of space
updation would be problem we need to check all rows to update the value, costly updates
inability to represent certain inormation,  if certain attributes are not available we cannot insert data other attributes and
while deleting we may delete all the data not leaving any master record trace

Functional dependency
type of constraint on set of relations
a  ---> b
set of attributes a, b belong to relation r
holds on schema R, if any legal relation r(R) for all pairs of tuple t1 and t2 in r if t1[a] = t2[a] then t1[b] = t2[b] that is for a value of 'a' there corresponds a unique value of 'b'  one to many not allowed

superkey
if K-->R that is for all pair of tuples if t1[K] = t2[K] then t1=t2

Normal forms

First Normal form
there should not be set of values assigned to attribute that is
no field of  relation should be like {address1.1,address1.2} that would require to parse the value with extra programming effort

Trivial dependency
dependency that are satisfied by all realtions
A  -> A for attributes A
or a ---> b where b is subset of a

Closure of functional dependecy
F+ set of all functional dependecy logically implied by F

Axioms
1) Reflexivity
trivial dependecy A--->B  if B is subset of A
2)Augmentation rule
If A--->B and C is set of attributes then AC-->BC
or
If If A--->B and C is set of attributes then AC-->B
or
If A--->B and C->D  then AC-->BD
3)transitivity
If A--->B and B--->C then A ->C


Rules
Union rule:
If A->B and A->C then A->BC
2)Decomposition rule reverse of union
If A->BC holds then A->B and A-> must also hold
3)pseudo transitive
If A->B and BC->D then AC->D


Closure of attribute set

Finding the set of attributes determined by A
algorithm
set result =A
while result changes do
  for each functional dependency B->C
  if B is subset of result  include C in the result  //

Problem
A, E ---> D -- 1
A --> C -- 2
E --> A -- 3
C ---> E -- 4

find (BA)+
Solution
result =BA
1)find lhs attribute set, superset of BA
2 so we include C, result= BAC 
2) repeat A with new result
i)result=BACE   from 4
ii)result = BACED from 1

Problems Find all CK for
A, D ---> C -- 1
D ---> E      -- 2
E, B ---> A  -- 3
A ---> B      -- 4
Solution:
1) find the attribute set that determines all other
A,D -> CEB
2)can we remove any of the A or D from the above dependency

since D doesnot appear on right side of any functional dependecy that cannot be determined by any other attribute so D cannot be removed
A is determined by EB and B is determined by A so we cannot remove A also
3)checking for other CK
find which other attributes derive the first CK i.e AD
applying psuedotransitivity on 2 and 3 we get DB->A

b)
A ---> C, D   -- 1
C, D ---> E   -- 2
E, A ---> B -- 3
Solution
1) since A doesnot appear on right of any FD so A should be in CK
2) A can derive any other attribute set if we check
A ->E
A-> EA
A->B
so A is the CK


c)
A, E ---> D -- 1
A --> C -- 2
E --> A -- 3
C ---> E -- 4
Solution
BA ->ABCED
AB is the CK
we see A is determined by E so BE is also CK
and E can be determined from C so EC is also CK


d)
B --> A,E   -- 1
E, B --> C   -- 2
A, C ---> D   -- 3
A ---> B      -- 4
Solution
B->ABECD
so is A


Cannonical Cover
extraneous attribute : if attribute can be removed from functional dependency without changing the closure
1) attribute a of A set is extraneous if for FD A -->B
F logically implies  F-{A->B} U (A-a) -->B

example
F: AB->C and A->C
Lets see if A is extraneous or not in AB->C
F' = B->C U A->C
does F logically implies above F'
no F does not implies B->C


Check if B is extraneous  in AB->C
A->C U A->C  =A->C
F has the same

try reverse does F-{A->B} U (A-a) -->B  logically implies F for
AB->C and A->E
let B be extraneous in AB->C then
F'=A->C , A->E
does F' logically implies F
well it does and will always imply F irrespective of FD's

Method
A' = A-a
check if A' -> B can be inferred from F that is compute closure A'+ under F

2) attribute b of B set is extraneous in FD A-->B
if F-{A->B} U (A) -->(B-b) logically implies F
example
F: AB->CD and A->C
let C be extraneous in AB->CD then
F'= AB->D , A->C
does F' implies F, yes
reveres would be always true in this case also that F would always imply F'
Method
check if A ->b is implied by F' that is computer A+ on F' and check if right hand side has b

Cannonical cover
set of depndencies Fc such that F logically implies Fc
1)no functional dependency in Fc contains an extraneous attribute
2)each lef t side of functional dependency in Fc is unique

cannonical cover may not be unique


Decomposition
A set of relation schemas { R1, R2,…, Rn } is a
decomposition of R if
R = R1 U R2 U …..U Rn
each Ri is a subset of R ( for i = 1,2…,n)

Given instances of the decomposed relations,
we may not be able to reconstruct the
corresponding instance of the original relation
– information loss
Lossy decomposition or lossy join bad design gets more tuples but less information
After Natural Join, we get  extra tuples. Thus, there is loss of information.
A decomposition {R1, R2,…, Rn} of a relation R is called a lossless decomposition for R if the natural join of
R1, R2,…, Rn produces exactly the relation R.
 
     R(A, B, C)
          |
     Decompose
R1(A, B)   R2(A, C)
         |
    Recover
   R’(A, B, C)

Thus,
R’ = R

R : relation
F : set of functional dependencies on R
X,Y : decomposition of R

Decomposition is lossles if :
if X ∩ Y forms a superkey of either X or Y, the decomposition of R is a lossless decomposition

Superkey
no distinct tuple in the realtion have same values for the attributes in this set


Normal forms
1NF
all attributes directly or indirect depend on candidate key


2NF
1)should be in 1NF
2)Every non key  attribute is fully dependent on candidate key


when not in 2NF its vulnerable to update anomaly


example AB is key for R(ABCD)
if we have values like
A    B    C     D
A1 B1  C1   D1
A2 B1  C1   D2
A3 B1  C1   D3

here B ->C that is C is dependent only on B which is partial key
now if we have update C for B1  we need to make sure we update all B1 records

So we divide the table in to two BC and ABD for table to be in 2NF
3)case when mutual dependence between non key attribute
2NF eliminates certain update anomaly but not all
the case when non key attribute is dependent on another non key attribute is not handled here
example
R(supplier_no,status,city)
and functional dependency are
--------------------------
supplier_no --> status
supplier_no -->city
city ---> status
---------------------------
This relation is in 2NF but not in 3NF
Reason  here both non key attributes status and city are dependent on whole of candidate key but there is dependency city -->status which can lead to update anomaly

4) Anomalies in 2NF
Insertion anomaly : we cannot maintain status of city in above case until we have supplier in that city
Deletion Anomaly:same way if we delete all supplier for a city we loose status information
Updation Anomaly:status occurs many times like if we update status for a particular city we have to update all rows with that city otherwise inconsistency

5)can exist only if table has composite key, always in 2NF if no composite key

6) Case when not proper subset of candidate key and not super key either
Consider the Relation R(pubId, title,pagecount,price)
if FD's are
PubId, title --> pagecount,price
PubId, pagecount --> price
This is still in 2NF because price depends not on the proper subset of candidate key{pubId,title} but on part of candidate key with some other non key attribute
so its not proper subet of key
and not superkey either
This is not in 3NF because
1)non key attribute price should be dependent on superkey or we can say
2) pubId,title -> pagecount,pubId -->price, which is transitive dependency that is non prime attribute price here is transitively dependent on candidate key {pubId,title}

reference

7)Check for all the candidate key for partial dependency

3NF
1)If relation has only one candidate key then no non key column should determine another non key column
2) 2NF say non key attributes depend on whole key, 3NF restraints it further and says non key attribute depends on nothing but the whole key
that is in 3NF cases like X->A,B where X is composite candidate key and A and B are non prime attribute then A->B is not allowed though B depends on whole key X but it also depends on A
2)For each functional dependency X-->A either of the condition should hold true
i)X->A non trivial dependency that is A is subset of X or
ii)X is superkey or
iii)A-X that is nontrivial attributes on right side is prime attribute that is part of some candidate key
3)Anomalies in 3NF
can suffer from all three in case when its not in BCNF
4)when all attributes are prime then its in 3NF

BCNF
1)more restrict than 3NF
2)for every functional dependency X->A either
i)X->A is trivial dependency or
ii)X is superkey
3)3NF with no overlapping candidate key is guaranteed to be in BCNF
4)Dcomposition in BCNF may not preserve certain dependency when attribute functionally dependent moves in to another table


Decomposition of BCNF
for A -> B where A is not key we divide the relation R in to AB and {R-B}
Any relation in BCNF is in 3NF

Problem
1)R(A, B, C)
FD's
--------------
AB -> C,
C -> B
-------------

check for BCNF
i)find closure of the left side attributes
for C->B
closure of C is B that is not = ABC so not key hence not in BCNF

Check for 3NF
i)find the minimal keys
AB and AC
since all right side attributes are prime its in 3NF or 
ii)check 3NF conidtion for each dependecy
AB - >C   AB is key so satisfies 3NF
C->B   C is not key but B is part of key so it also satisfy 3NF


Problem R(A,B,C,D,E) and FD’s
A->B,
B->AE,
AC->D
why not in BCNF?  Decompose in BCNF
solution
i) A->B check closure of A which is ABE so not in 3NF
ii) B->AE  closure of B is BAE this also violates
iii) AC-> D  closure of AC is ACDBE  which satisfies
Now we decompose relation such that FD i and ii are satisfied
first rewrite FD like we check this on new FD whenever some transitive dependecy comes from present FD
A-> B , B->A , B->E,A->E, AC->D
for A->B  decompose it in R1(AB) and R2(ACDE) and check if FDs hold
on R2 A ->E violates as A is not superkey so we decompose R2 as R3(AE) R4(ACD)
now every FD holds

Problem  R(A,B,C,D,E) with functional dependencies A→ E, BC→ A, DE→ B.
Solution
find keys
ACE ACD ACB
since all right side are prime key attributes or part of superkey so it satisfies the 3NF
but left side are not the key so not in BCNF
BCNF decomposition
R1(AE)  and  R2(ABCD) holds A->E violates BC - A
R1(AE) R2(BCA) R3(CBD)  only dependency in R3 is trivial BCD -> BCD
lost the dependency DE->B


Problem  R1(A,B), R2(C,D,E,F) A→ B, C → D, D → EF
Solution
key for R1 is A and key for R2 is C
it holds 2NF condition because A-> B, B depends on complete key, for C->D, D depends on complete key and D->EF, EF doesnot depends on partial key either



Entity Relationship
coneptual representation : ER
logical: relational model with attributes datatype lenght constraints
physical: with schema def views triggers

Realtionship set
set of same type of relations
each entity plays a role in the relation
same entity set can participate in relation set more than one time with different roles
descriptive attributes on relation set
relationship instance in the relation set must be uniquely identifiable from its participating entity without descriptive attributes:
Mapping cardinality: number of entities to which another entity can be associated using relationship set
Participation :if every entity in E participates in atleast one relationship in R total participation

Key for relationship set
Ei entities participating in the realtionship
primarykey(Ei) and {a1,a2,..an} attributes associated with realtionship set

describes individual relationhip and union of keys forms the superkey

set of attributes  primarykey(E1) U  primarykey(E2) U primarykey(E3) ..U {a1,a2..an}

when realtionhship set is many to one
the primary key of the relationship set is identified from the key of the entity on the many side

Translating from ER model o relational model

Many to many relationship
employee[ssn]----------works_in(since)-----deptartment[did]
many employess can work in a department and
and a employee can work in many departments
in translating relation work_in it need to include primary key of both participating entities(which becomes it's PK) and its own attributes


One to Many relation
employee[ssn] <-----------manages(since) ----------department[did]
each employee can manage number of departments but (constraint)
each department is managed by at most one employee

since each deparment has a unique manager we can combine the department entity and manages relation without introducing any redundancy

manages seperate would have been like

ssn ,dId ,since , primary key (did), foreign key(ssn) reference Employees, foreign key (did) REFERENCES Departments)

with combined dept_manages for total participation from "many side"
 attributes of department + attribute of manages above
ssn ,did ,since , primary key (did), foreign key(ssn) reference Employees


Total Participation
If every department must have a manager that is must appear in manages relation with non null ssn then
we represent relation manages and department in single table only but on deletion of employee or ssn we don't delete the dept_manages tuple
and ssn constrain of not null

Weak entity set
A weak entity can be identified uniquely only by considering the primary key of another (owner) entity.
– Owner entity set and weak entity set must participate in a one-to-many relationship set (1 owner, many weak entities).
– Weak entity set must have total participation in this identifying relationship set.

Weak entity set and identifying relationship set are translated into a single table.

employee ([ssn],name)-----------policy(cost) <-----------------------dependents ([pname],age)

Dep_policy
pname,age,cost,ssn
with primary key [ssn ,pname] and foreign key [ssn] referencing employee and on delete cascade

when owner entity is deleted all the owned weak entities must also be deleted



References
www.cs.sjsu.edu/faculty/lee/.../26Presentation_Jung_T_Chang.ppt
pages.cs.wisc.edu/~dbbook/openAccess/firstEdition/.../mod5l1-2.pdf
https://agora.cs.illinois.edu/display/cs411sp10/Assignments
www.cs.arizona.edu/classes/cs460/fall09/hmwk2.pdf

Concurrency Control in Database

Why we want to run transactions concurrently?
Concurrent or overlapping execution of transactions are efficient

How we ensure the correctness of the concurrent transactions?
Concurrency control(Serializability) and Recovery are two criteria that ensure the correctness of concurrent transactions

Why concurrency control is needed
Lost Update : update of some data by one transaction is lost by update from another transaction
Dirty Read or temporary update problem : one transaction updates the value of common data and aborts before it can revert the changes transaction 2 reads the value of updated variable.
incorrect summary problem: transaction reads the data while another transaction is still changing the data

Why recovery is needed
In any kind of problem like hardware malfunction, software error exceptions or violating the concurrency property, deadlock recovery of transaction is needed

Transaction  states
  • begin transaction marks the beginning of transaction. 
  • end_transaction specifies transaction execution is complete and system check whether changes can be permanently applied.
  • rollback or abort for unsuccessful end of tranaction
Fig. transaction states
  • At commit point all transaction operations have been logged and new entry is done in log 'commit T' stating that all transaction operation permanently logged
  • before writing commit T the complete log should be written to disk from buffers
  • Rollback :  when commit T statement  is not found in log, its rollbacked

How recoverability is implemented
System log is kept on disk which logs transaction like write old value new value read.
Protocol that do not provide cascading rollback do not need to keep read entry

Schedules
Recoverable Schedule : If T2 reads a data item written by T1 commit operation of T1 should appear before commit operation of  T2.

Cascadeless Schedule: If T2 reads a data item written by T1 commit operation of T1 should appear before read operation of T2.
Strict Schedule : If a write operation of T1 precedes a conflicting operation of T2 (either read or write), then the commit event of T1 also precedes that conflicting operation of T2.

Fig. schedules recoverability
pattern for recoverable schedule would be like
Fig. simple pattern for recoverability schedules on vertical time line
What is Serializability
If executing interleaved transaction results in same outcome as serial schedule(running transaction in some sequnence) then they are considered serializable. this schedule is type of nonserial schedule.

Serializabality might be compromised in some cases but recoverability compromise would mean violating database integrity. Isolation levels decide tradeoff between correctness and concurrency

Isolation level
when the changes made by one operation becomes visible to another operation
most relaxed ACID property
From more stringent to relaxed isolation levels
Serializable as if transactions execute in complete isolation, in serial fashion. read locks released immediately but write locks released at end of transaction
Read Uncommited Dirty reads allowed that is another transaction reads the data value but then first transaction can revert so other transaction has incorrect value
Repeatable read: A phantom read occurs when range of rows is read by one transaction and another transaction inserts or delete a record in between rows returned by same query is different at two points in time for a transaction that is another transaction updates and commits in between
Read commited(Non repeatable read):prevents dirty read that is reads commited data only.
UPDATE or DELETE of any of the rows read by earlier transaction


Dirty Read
Lost Update

Phantom Records
Read uncommitted
yes
yes

yes
Read committed
No
yes

yes
Repeatable read
No
no

yes
Serializable
No
no

no


Types of serializability

View and conflict serializability

  • conflict is subset of view serializability
  • Conflict is widely utilized because it is easier to determine and covers a substantial portion of the view serializable
Equivalence to serial schedule such that

In view serializable, two schedules write and read the same data values.
and In conflict seriablizable, same set of respective chronologically ordered pairs of conflicting operations.


Conflict serializable
In conflict serializabability two schedules are conflict equivalent and we can reorder the non conflicting operation to get the serial schedule
Conflicting operation
1) they are upon same data item
2)At least one of them is write
3) they are from different transactions
Non commutative that is their orders matter

Testing conflict serializability
Test is through precedence graph. The acyclic preced graph shows conflict serialiczable schedule and topological sorting of that graph gives the serializable schedules
cycle of commited transaction can be prevented by aborting an undecided transaction on each cycle in precedence graph of all transaction

view serializability is NP complete
materialized conflict if the requested conflicting operation is actually executed
//pending

Problem 1 Consider two schedules
S1 : r1(x) w1(x) r1(y) c1
S2: r2(x) r2(y) c2
1.What the number of possible schedules.
2. How many serial schedules are possible
3. Determine type of schedules(recoverable cascadeless strict) and serializability(conflict seriablizable or not) for below schedules
S1: r 1 (X); w 1 (X); r 2 (X); w 2 (X); r 1 (Y); w 1 (Y); C 2 ; C 1
S2: r 1 (X); r 2 (X); w 1 (X); r 1 (Y); w 1 (Y); C 1 ; w 2 (X); C 2
S3: r 1 (X); w 1 (X); r 2 (X); w 2 (X); r 1 (Y); w 1 (Y); C 1 ; C 2 
Solution
1.
In general, given m transactions with number of operations n1, n2, ..., nm, the number
of possible schedules is: (n1 + n2 + ... + nm)! / (n1! * n2! * ... * nm!)
here m=2 and n1= 4 and n2 = 3
so (3+4)! / (3!*4!)
7C3 or 7C4
2.Number of serial schedules is m! where m is number of transactions
so here we have 2!

3. To check type of schedule
we need to check all conflicting operations of schedule 
S1 : r2(X) comes after w1(x) , since no commit before r2(X) its not cascadeless and strict
commit of T1 should be before T2 in this case for it to be recoverable which is not so it is not even recoverable. Its non recoverable schedule
S2: there is only one conflicting operation w1(X) w2(X) and for that we have commit of T1 before w2(X) so its strict schedule and so is cascadeless also
S3: for one of the conflicting operation w1(X) r2(X) there is no commit in between so its not cascadeless and strict. To check for recoverable commit of T1 should be before that of T2 which is there

To check serializability
S1 precedence graph is
T1 ---> T2
acyclic so its conflict serializable

S2 precedence graph
T1-------->T2
^                 |
|_________|
there is cycle so its not conflict serializable

//pending problems
http://academic.udayton.edu/SaverioPerugini/courses/Winter2006/cps432/index.html

Database Concurrency Protocols

Two way phase locking 2PL
guarantees conflict serializability
may be subjected to deadlocks
doesnot guarantees cascading rollbacks
In expanding phase, number of locks can only increase
In shrinking phase locks only released

2PL is superset of SS2PL(rigourness)

Strict 2PL
For any two transactions T1, T2, if a write operation precedes a conflicting operation of T2 (either read or write), then the commit event of T1 also precedes that conflicting operation of T2.

Any strict schedule is cascadeless, but not the converse. Strictness allows efficient recovery of databases from failure.

//http://en.wikipedia.org/wiki/Schedule_%28computer_science%29#Strict

Release exclusive lock only after end of transaction that is unlock happens only after commit or abort
guarantees serialiability and recoverable schedule too
read locks can be released
S2PL class of schedule is (2PL intersection Strictness)
release its write locks only after it has ended
read locks are released regularly during phase 2
we need to know the phase 1 end seperate from transaction end


Transaction can be in following states

Running its executing
Ready its programs execution has ended and its waiting to be Ended
Ended or completed It is either commited or Aborted de

SS2PL Strong Strict 2PL (Rigorous )
release both locks only after END
has actully one phase only, no phase 2
SS2pL enforce both conflict serializability and strictness


Deadlock in 2PL

Other enforcing mechanism for serializability
Time stamp ordering
Correctness of database transaction is defined by its
serializability or isolation and its recoverability
relaxing the serializability criteria isolation levels
view and conflict serializability



Problem 1

Determine whether
1)schedule is serializable or not
2)schedule can be produced by 2PL
3)schedule can be produced by Strict 2PL

Schedule S1



T1 T2 T3


r(D)
w(A)


r(B)
w(B)


r(D)


w(D)

Solution

1) To check the serializability we draw the precedence graph of the schedule

http://www-stud.uni-due.de/~selastoe/?mdl=dbms&mode=precedence

T2--------->T1
 |
 |
 v
T3

Since the graph is acyclic, so its serializable

2)
Non-serializable schedules can not be 2PL or strict 2PL.
Subset of serializable schedules can be 2PL or strict 2PL

2PL protocol says for a transaction all locks should be requested before releasing any lock


T1 T2 T3


Ls(D)


r(D)
Lx(A)

w(A)


Ls(B)

r(B)

Ls(D) U(B)
Lx(B)

w(B)

U(A) U(B)


r(D)

U(D)


Lx(D)


w(D)


U(D)
 Fig. showing how 2 phase locking protocol works for this schedule


Here  transaction requested shared lock for read and exclusive lock for write
Shared locks on data item are compatible like here T2 requested shared lock on data item D which was shared locked by T3.

If we look at only the transaction lock requests we can see that for each transaction we first requested all the
locks before releasing any


T1 T2 T3


Ls(D)



Lx(A)





Ls(B)




Ls(D) U(B)
Lx(B)




U(A) U(B)





U(D)


Lx(D)





U(D)
 Fig showing only the lock request and lock release for all transactions



Ls = shared lock
Lx = Exclusive lock
 U = Unlock



converting shared lock to exclusive lock is part of growing phase while
converting exclusive lock to shared lock is part of shrinking phase

Problem read to write lock and write to read lock conversions
Solution A read lock can be converted to write lock if no other readers, this converion happens by first unlocking the data item and then acquiring the write lock, if the request are already queued by some other processes for write lock might not get lock instantly
write to read is always possible.

If transaction Ti has shared lock and transaction Tj request exclusive lock on same item first transaction Ti has to release the lock and then transaction Tj can acquire the lock

Problem consider schedule  S =T1 R(x), T2:R(Y) ,T1:W(z) , T1:commit, T3:R(y) , T3:r(z) ,T2 w(y), T3: w(x),T2:commit , T:commit

2PL
T1           T2            T3
Ls(x)
r(x)
               Ls(y)
               r(y)
Lx(z)
w(z)
U(x)U(z)
commit;
                                Ls(y)
                                 r(y)
                                Ls(z)
                                 r(z)
                                 Lx(x) U(y)
                 Lx(y)
                 w(y)
                 U(y)
                commit;
                               w(x)
                               U(x)
                              commit;

Strick 2PL would require that T2 gets the Lx(y) while T3 has shared lock on y but T3 commits after T2 request so it cannot get the Lx(y)


In the 2PL we are allowed to read or write even after some unlock only condition is no lock can come after first unlock
In S2pL all exclusive lock unlocks comes at the end after commit or abort


Dealing with Deadlock
Deadlock Prevention
A transaction locks all data item it refers to before execution this prevents deadlocks since transaction never has to wait
Another approach is to impose ordering on all the data items and to require that transactions lock data items only in sequence consistent with ordering  example tree protocol

Conservative 2PL uses this approach

Deadlock detection and resolution
wait for graph,created using lock table, is kept which is used to detect the  cycle  and then one of the transaction is rolled back
transactions are added to wait for graph as they get blocked

Deadlock Avoidance
some avoid deadlock by not letting the cycle to  complete, if discovers that blocking a transaction is likely to create a cycle it rollback the transaction
wound wait and wait die algorithms use timestampt to avoid deadlock by rolling back victim

Starvation
particular transaction never gets a chance to proceed further

 Timestamp Protocol
selects ordering among transaction in advance instead at time of execution

timestamp monotonically increasing
timestamp is assigned by system before transaction starts
timestamp for transaction determines serializability order thus if Ti < Tj then system must ensure that Ti appears before transaction Tj in schedule

we associate with each data item Q two timestamps
W-timestamp(Q) largest timestamp of any transaction that executed write (Q) successully
simliarly R-timestamp(Q) for read

Timestamp ordering Protocol
ensures conflict serializability
ensures freedom  from deadlock since no transaction ever waits , its just killed
possibility of starvation
can generate schedules not recoverable but can be guaranteed in several ways

1) when transaction T issues write(X)  check if
read_TS(X) > TS(T) or write < TS then some younger transaction has already read the data item X so abort
and rollback T
when transaction issues read(X)
if younger  transaction has already written to the data item X abort and rollback T
ensures that any conflicting operations are executed in timestamp order

Strict Timestamp Ordering
ensures strict schedule along with conflict serializable
instead of writing when transaction has higher timestamp then on data item it waits until transaction that wrote value of data item commits or aborts

Thomas write Rule
does not ensures conflict serializability
1)IF read_ts(X) >TS(T) that is some younger transaction read the data item before T
abort and rollback T and reject operation
2)write_ts(x) > ts(T) donot execute the write but continue and will be detected in 1)

Wednesday, June 19, 2013

Database Management Systems MCQ - III


101.     The methodology for documenting databases illustrating the relationship between various entities in the database is
(a)        Data flow diagram
(b)        State transition diagram
(c)        Entity-relationship diagram
(d)        Entity sequence diagram
(e)        Object model.

102.     The extent of the database resource that is included with each lock is called
(a)        Level of impact
(b)        Granularity
(c)        Management
(d)        DBMS control
(e)        Recovery.

103.     Check pointing when used in conjunction with incremental log reduces the actual recovery time. However, for proper recovery the system must ensure that (choose the correct one)
(a)        At the time of check pointing there is no incomplete transaction
(b)        If the updates are deferred, at the time of check pointing there is no incomplete transaction
(c)        If updates are immediate, at the time of check pointing there is no incomplete transaction
(d)        At the time of check pointing there exists an incomplete transaction
(e)        All of the above.

104.     Consider the following Employee table.
Employee Table
E_No   Job       Salary   Dept_No
178      System Analyst 25000  10
179      Software Engineer        30000  10
180      Quality Assurer 21000  20
181      Technical Writer           17000  30
182      Associate Software Engineer     20000  10
Which of the following statements gives the list of departments having average salary greater than 20000 from employee table?
(a)        SELECT Dept_No, AVG (Salary) FROM Employee ORDER BY Dept_No HAVING AVG(Salary) > 20000
(b)        SELECT Dept_No, AVG (Salary) FROM Employee HAVING AVG (Salary) > 20000
(c)        SELECT Dept_No, AVG (Salary) FROM Employee GROUP BY Dept_No HAVING AVG (Salary) > 20000
(d)        SELECT Dept_No, AVG (Salary) FROM Employee WHERE AVG (Salary) > 20000
(e)        SELECT Dept_No, AVG (Salary) FROM Employee GROUP BY Dept_No WHERE AVG (Salary) > 20000.

105.     “When a very large record of a file is allocated to disk blocks, some unused spaces will remain and to utilize this unused space, parts of records can be allocated. Each and every part belongs to a record and is referenced through a pointer.”
A record organization which has been distributed as parts among unused spaces of blocks and using a pointer to reference them is called
(a)        Blocking factor
(b)        Spanned record
(c)        Separator
(d)        Variable length record
(e)        BLOB.

106.     State the unit of storage that can store one or more records in a hash file organization
(a)        Buckets
(b)        Disk pages
(c)        Blocks
(d)        Nodes
(e)        Baskets.

107.     When implementing security in a DBMS, which of the following is not supported by the GRANT command?
(a)        Providing DELETE privileges
(b)        Supporting the devolution of access control to non-DBAs
(c)        Removing privileges of other people
(d)        Providing SELECT privileges
(e)        Changing passwords.

108.     The file organization which allows to read records that would satisfy the join condition by using one block read is
(a)        Heap file organization
(b)        Sequential file organization
(c)        Clustering file organization
(d)        Hash file organization
(e)        Index file organization.

109.     What is the means that data used during the execution of a transaction cannot be used by a second transaction until the first one is completed is called
(a)        Serializability
(b)        Atomicity
(c)        Isolation
(d)        Time Stamping
(e)        Durability.

110.     Which of the following is an incorrect statement?
(a)        Pointer – A data model which assumes that all data relationships can be structured as hierarchies
(b)        Data model – A physical address which identifies where a record can be found on a disk
(c)        Child record – An owner record in a hierarchical relationship
(d)        Network model – A data relationship in which a record can be owned by records from more than one type
(e)        Data model – A conceptual method of structuring data.

111.     Which of the following SQL aggregate function gives the number of rows containing not null values for the given column?
(a)        MIN
(b)        COUNT
(c)        MAX
(d)        SUM
(e)        AVG.

112.     “One disadvantage of index schemes in file organizations is that an index must be accessed and read to locate records.  In order to eliminate the need for maintaining and searching indexes, the method can be used as a method of direct record addressing.”
Find the appropriate option which fills in the blanks with suitable terms for (i) and (ii).
(a)        i.     sequential
ii.     indexing
(b)        i.     indexed Sequential
ii.     hashing
(c)        i.     sequential
ii.     hashing
(d)        i.     indexed Sequential
ii.     storage
(e)        i.     sequential
ii.     storage.

113.     A Relational operator that yields all possible pairs of rows from two tables is known as a/an
(a)        Union
(b)        Intersect
(c)        Difference
(d)        Project
(e)        Product.

114.     The following are the three language components of a database management system (DBMS).
I.     Data Definition Language (DDL).
II.     Sub-schema DDL.
III.    Data Manipulation Language (DML).
Two different types of people (users and practioners) are concerned with them. Which of them do users of a DBMS usually deal with?
(a)        Only (I) above
(b)        Only (III) above
(c)        Both (I) and (II) above
(d)        Both (II) and (III) above
(e)        All (I), (II) and (III) above.

115.     In the ANSI/SPARC three level database model, the external view is best described by which of the following options?
(a)        It is the link between users and the storage structures
(b)        It is dependent on the underlying DBMS product used (e.g. Oracle, DBASE)
(c)        It is the place where the users interface to the DBMS
(d)        It is not part of the model
(e)        It is the place where the storage structures link to the database.

116.     Match each term in Column A with the most appropriate definition in Column B.
Column A         Column B
(P)   Technological feasibility     (i)    Needs information from the database to carry out the primary business responsibility
(Q)   User        (ii)    Responsible for the database system and its associated application software
(R)   Practitioner           (iii)   Determines hardware and software availability for database system
(S)   Operational feasibility        (iv)   Determines availability of expertise and personnel needed for the database system

(a)        (P)→(iii), (Q)→(i), (R)→(ii), (S)→(iv)
(b)        (P)→(iv), (Q)→(i), (R)→(ii), (S)→(iii)
(c)        (P)→(iii), (Q)→(ii), (R)→(i), (S)→(iv)
(d)        (P)→(iv), (Q)→(ii), (R)→(i), (S)→(iii)
(e)        (P)→(ii), (Q)→(i), (R)→(iii), (S)→(iv).

117.     Which of the following set of operations represent a complete set of relational algebra operations?
(a)        { σ, π, U}
(b)        { ÷ , x }
(c)        { σ, π, ∩ }
(d)        {π , ∩, x}
(e)        { – , x }.

118.     The following output is to be generated:
Fname  Minit    Ssn       Sex      Salary   SupperSsn        Dno
Sunil     T          334555            M         40000  88866  5
Amila   S          987615            F          43000  54321  4
Mahepala         K         668445            M         38000  33455  5
Which of the following would produce the above output?
(a)        s Employee ) (Dno = 4 AND Salary > 30000) OR (Dno = 5 AND Salary > 30000)
(b)        sEmployee ( ) (Ssn > 30000) AND (Sex = ’M’)
(c)       
(d)       
(e)        p (Employee)  (Employee) Fname, Minit, Ssn, Sex, SupperSsn, Dno Salary.

119.     The referential integrity rule requires that ________.
(a)        Every null foreign key value must reference an existing primary key value
(b)        An attribute have a corresponding value
(c)        You delete a row in one table whose primary key does not have a matching foreign key value in another table
(d)        Every non-null foreign key value reference an existing primary key value
(e)        Both (a) and (c) above.

120.     The lock that prevents the use of any tables in the database from one transaction while another transaction is being processed is
(a)        Database-level lock
(b)        Table-level lock
(c)        Page-level lock
(d)        Row-level lock
(e)        Field-level lock.

(a)        Collapse
(b)        Mix
(c)        Split
(d)        Merge
(e)        Shrink.

122.     Which Model describes entities, relationships and attributes?
(a)        E – R Model
(b)        Functional
(c)        Relational
(d)        Network
(e)        Info logical.

123.     Which among the following is function of DBA?
(a)        Communicating with all computer users
(b)        Classify user groups and provide authorization to access data elements
(c)        Retrieve data and supply daily reports to the top management
(d)        Install upgrades of database hardware
(e)        Monitor systems performance and increasing complexity.

124.     Which property of transaction ensures that either all operations of the transaction are reflected properly in the database or none?
(a)        Atomicity
(b)        Durability
(c)        Isolation
(d)        Consistency
(e)        Concurrency.

125.     What factors would not determine the capacity of a block of a disk organization?
(a)        Blocking factor
(b)        Record size
(c)        Block pointer
(d)        Inter-block gap
(e)        End of track.

126.     When the detection algorithm detects a deadlock, the recovery is normally accomplished by?
(a)        Roll-back of transactions
(b)        Consistency checking
(c)        Locking of data
(d)        Waiting for release of locks
(e)        Enforce two phase locking.

127.     Which of the following statement is component of DBMS?
(a)        Data dictionary/directory subsystem
(b)        Naïve Users
(c)        Database administrator
(d)        Users and programmers
(e)        Hardware and data.

128.     Which type of file is easiest to update?
(a)        Sequential
(b)        Hashed
(c)        Indexed
(d)        Clustered
(e)        Heaped.

129.     Which of the following statement will not affect the performance of a database system?
(a)        Adequate free disk storage capacity
(b)        Disk access time
(c)        Processor speed
(d)        Memory capacity
(e)        Display resolution of data.

130.     Which of the following concept(s) cannot be represented in the Enhanced Entity-Relationship Model?
(a)        Composite attribute
(b)        Derived attribute
(c)        Weak entity
(d)        Generalization relationship
(e)        Versions.

 131.    Which of the following statement is true for the 3 level architecture?
(a)        The physical schema should assist to locate the data stored on disk
(b)        The logical view of the data provides the view of data for the user
(c)        Data authorization can be specified for the physical schema
(d)        Program/data independence is eliminated due to this architecture
(e)        New data cannot be derived with the help of sub-schemas.

132.     In an SQL statement, which of the following parts states the condition for Group selection?
(a)        Select
(b)        From
(c)        Where
(d)        Group By
(e)        Having.

133.     Which normal form states that a relation has no transitive dependencies in it?
(a)        First
(b)        Second
(c)        Third
(d)        Fourth
(e)        BCNF.

134.     Which of the following collection(s) of attributes correctly represent(s) a Lecturer relation and possible relationship(s) it might have with other relations when the E-R model is mapped into a relational model?
(a)        Name, UPFNo, Address, Phone
(b)        Name, UPFNo, Address, Phone, Subject, lecturehours
(c)        Name, UPFNo, Address, Phone, Subject
(d)        Name, UPFNo, Address, Phone, Faculty
(e)        Name, UPFNo, Address, Phone, Subject, Faculty, Dean.

135.     Which of the following statement can be considered as a part of data dictionary?
(a)        Metadata
(b)        The complete set of data records
(c)        Data flow diagram of the system
(d)        Use cases
(e)        An Entity-Relationship diagram of the schema.

136.     Which procedure is used for acquiring the necessary locks for a transaction where all necessary locks are acquired before any are released?
(a)        Record controller
(b)        Exclusive lock
(c)        Authorization rule
(d)        Two phase lock
(e)        Three phase lock.

137.     Which attribute that can be further subdivided to yield additional attributes?
(a)        Composite
(b)        Simple
(c)        Single-valued
(d)        Multi-valued
(e)        Derived.

138.     Which of the following statement is not true?
(a)        Stored procedures can receive and return parameters
(b)        CHECK (bonus <= 0.10 * salary) will ensure that no employee gets a bonus exceeding 10% of the salary
(c)        A graphical language is a computer language whose statements consist of character string symbols
(d)        A database application development environment provides variety types of controls such as drop-down list boxes and buttons
(e)        Event-driven facility is supported by 4GL-application development environment.

139.     The term used to identify a row of a table in the relational data model is
(a)        Cardinality
(b)        Data
(c)        Data Set
(d)        Tuple
(e)        Record.

140.     Employees, Customers, Account, Vehicle are examples of
(a)        Attributes
(b)        Entities
(c)        Fields
(d)        Columns
(e)        Domains.


141.     How a null value is created or represented?
(a)        A zero
(b)        A space
(c)        Entering a value
(d)        Pressing the Enter key without making a prior entry of any kind
(e)        Pressing the ESC key.

142.     What does a multi level index lead to?
(a)        Binary Tree
(b)        B-tree
(c)        Mapping
(d)        Transaction Failure
(e)        Dead Lock.

143.     Select the incorrect statement describing the keys used in a Relational Data Model.
(a)        A primary key is an attribute that uniquely identifies each row in a relation
(b)        A composite key is a primary key that consists of more than one attribute
(c)        A foreign key can be an attribute in a relation of a database that draws values from the same domain as a primary key of another relation in the same database
(d)        Candidate key is an attribute that uniquely identifies a column in a relation
(e)        One field or combination of fields for which more than one record may have the same combination of values is called the secondary key.

144.     Choose the Suitable example for derived attribute from the following:
(a)        Roll no
(b)        Name
(c)        Marks
(d)        Age
(e)        Phone number.

145.     Which clause is used to produce a list of only values that are different from one another?
(a)        Aggregate
(b)        Restricted
(c)        Select
(d)        Distinct
(e)        Group By.

146.     What is the maximum height of a B+-tree of order m with n key values?
(a)        M
(b)        long m/2  n/2
(c)        long m n
(d)        log n m
(e)        log  m/2 (n/2) + 1.

147.     Which set of operators represents the complete set for relational algebra?
(a)        Union, Difference, Projection, Selection, Cartesian Product
(b)        Selection, Cartesian Product, Projection, Union, Intersection
(c)        Cartesian Product, Projection, Selection, Difference, Intersection
(d)        Join, Union, Projection, Selection, Difference
(e)        Difference, Projection, Selection, Join, Intersection.

148.     Which of the following RAID level is also called a rotating parity array?
(a)        1
(b)        2
(c)        5
(d)        4
(e)        0.

149.     Fill in the blanks by selecting the correct option(s) given below:
“In a relational data model, the columns of a table are called  and the rows are called tuples.  The primary key index does not allow data in a field. Views has characteristics of tables and can be used for .”
(a)        (i)  keys          (ii) multiple                       (iii) queries
(b)        (i)  fields        (ii) enter                           (iii) reports
(c)        (i)  fields        (ii) duplicate         (iii) queries
(d)        (i)  data          (ii) enter                           (iii) form
(e)        (i)  attributes   (ii) duplicate         (iii) reports.

150.     What storage device can be used to create an index sequential file?
(a)        ISAM
(b)        Direct Access
(c)        Sequential access
(d)        Tape
(e)        Hashed.



Answers

101.     Answer : (c)
Reason  :       ER diagram describes the relationships among the various entities in the database.
102.     Answer : (b)
Reason  :       The  extent of the database resource that is included with each lock is called the level of Granularity.
103.     Answer : (a)
Reason  :       At the time of check pointing there is no incomplete transaction.
104.     Answer : (c)
Reason  :       SELECT Dept_No,AVG(Salary) FROM Employee GROUP BY Dept_No HAVING AVG(Salary)>20000.
105.     Answer : (b)
Reason  :       The record organization is called as Spanned record .
106.     Answer : (a)
Reason  :       Buckets are used to store one or more records in a hash file organization.
107.     Answer : (a)
Reason  :       while implementing security to the database delete facility should not be provided to the users.
108.     Answer : (c)
Reason  :       Clustering file organization allows us to read records that would satisfy the join condition by using one block read.
109.     Answer : (c)
Reason  :       Isolation means that data used during the execution of a transaction can’t be used by a second transaction until the first one is completed.
110.     Answer : (b)
Reason  :       Data model – A physical address which identifies where a record can be found on a disk.

111.     Answer : (b)
Reason  :       Count function gives the number of rows containing not null values for the given column.
112.     Answer : (b)
Reason  :       (i) indexed Sequential (ii) hashing.
113.     Answer : (e)
Reason  :       product is the Relational operator that yields all possible pairs of rows from two tables.
114.     Answer : (b)
Reason  :       The users and practioners are concerned with only Data manipulation language component of DBMS.
115.     Answer : (c)
Reason  :       It is the place where the users interface to the DBMS.
116.     Answer : (a)
Reason  :       (P)→(iii), (Q)→(i), (R)→(ii), (S)→(iv)
117.     Answer : (a)
Reason  :       { σ, π, U } are the sets of operations which represent a complete set of relational algebra operations.
118.     Answer : (c)
Reason  :  
119.     Answer : (d)
Reason  :       The basic requirement of referential integrity is that every non-null foreign key value reference an existing primary key value.
120.     Answer : (a)
Reason  :       Data base-level lock prevents the use of any tables in the database from one transaction while other transaction is being processed.
Reason:  classify user groups and  provide authorization to access data elements
122.     Answer : (a)
Reason:  Except A remaining all are different users of the database system.
123.     Answer : (a)
Reason:  The physical schema should assist to locate the data stored on disk.
124.     Answer : (a)
Reason:  meta data is a part of data dictionary
125.     Answer : (d)
Reason:  Tuple is the term used to identify row  of a table in relation model
126.     Answer : (d)
Reason:  Candidate key is not the only  an attribute that uniquely identifies a column in a relation.
127.     Answer : (a)
Reason:  Union, Difference, Projection, Selection, Cartesian Product is the complete set of relational algebra.
128.     Answer : (e)
Reason:  E is the apt choice of order for the given question.
129.     Answer : (a)
Reason:  E – R Model Model describes entities, relationships and attributes?
130.     Answer : (a)
Reason:  When the detection algorithm detects a deadlock, the recovery is normally accomplished by Roll-back of transactions.

131.     Answer : (d)
Reason:  Generalization relationship cannot be represented in the Enhanced Entity-Relationship Model
132.     Answer : (d)
Reason:  The following collection(s) of attributes correctly represent(s) a Lecturer relation and possible relationship(s) it might have with other relations when the E-R model is mapped into a relational model. Name, UPFNo, Address, Phone, Faculty
133.     Answer : (c)
Reason:  A graphical language is a computer language whose statements consist of character string symbols.
134.     Answer : (b)
Reason:  B-tree leads to multilevel index.
135.     Answer : (e)
Reason:  The maximum height of a B+-tree of order m with n key values is log  m/2 (n/2) + 1
136.     Answer : (b)
Reason:  Direct Access can be used to create an index sequential file.
137.     Answer : (c)
Reason:  Splitting will happen to leaf and internal nodes if data is inserted into a B-tree
138.     Answer : (e)
Reason:  End of track would not determine the capacity of a block of a disk organization
139.     Answer : (e)
Reason:  E choice will not affect the performance of a database system
140.     Answer : (c)
Reason:  Third normal form states that a relation has no transitive dependencies in it

141.     Answer : (a)
Reason:  Composite attribute that can be further subdivided to yield additional attributes
142.     Answer : (d)
Reason:  A null value is created or represented by pressing the Enter key without making a prior entry of any kind.
143.     Answer : (d)
Reason:  Distinct clause is used to produce a list of only values that are different from one another
144.     Answer : (a)
Reason:  Atomicity property of transaction ensures that either all operations of the transaction are reflected properly in the database or none.
145.     Answer : (b)
Reason:  Hashed type of file is easiest to update.
146.     Answer : (e)
Reason:  Having states the condition for Group Selection
147.     Answer : (d)
Reason:  Two phase lock   procedure is used for acquiring the necessary locks for a transaction where all necessary locks are acquired before any are released
148.     Answer : (b)
Reason:  Employees, Customers, Account, Vehicle  are examples of Entities.
149.     Answer : (d)
Reason:  Age is the derived attribute
150.     Answer : (c)
Reason:  RAID level 5  is also called a rotating parity array