Self Studies

Databases Test 1

Result Self Studies

Databases Test 1
  • Score

    -

    out of -
  • Rank

    -

    out of -
TIME Taken - -
Self Studies

SHARING IS CARING

If our Website helped you a little, then kindly spread our voice using Social Networks. Spread our word to your readers, friends, teachers, students & all those close ones who deserve to know what you know now.

Self Studies Self Studies
Weekly Quiz Competition
  • Question 1
    2 / -0.33

    Consider the following set of functional dependencies F on the schema S(P, Q, R)

    F = {P → QR, PQ → R, Q → R, P → Q}

    The canonical cover of the above given set is 
    Solution

    Option 3: P → Q and Q → R

    P+ = {P, Q, R}

    It covers, P → QR, PQ → R and P → Q

    Also, Q → R

    It is also minimal

    Therefore, P → Q and Q → R is the canonical cover of the above given set.
  • Question 2
    2 / -0.33

    Which of the following concurrency control protocol ensures both conflict serializability and free from deadlock?

    Solution

    According to the 2PL protocol, a transaction handles its locks in two distinct, consecutive phases during the transaction's execution:

    Expanding phase: locks are acquired and no locks are released (the number of locks can only increase).

    Shrinking phase: locks are released and no locks are acquired.

    2PL ensures conflict serializability but does not ensure deadlock freedom.

    But time stamp ordering ensures both deadlock freedom and conflict serializabilty.

  • Question 3
    2 / -0.33
    Let the two-relation schema be R (A, B,) and S (A, B). which of the following is not equivalent to R ∩ S
    Solution

    Let us take example to prove:

    R:

    A

    B

    1

    3

    2

    4

     

    S:

    A

    B

    2

    4

    8

    5

     

    A U B

    A

    B

    1

    3

    2

    4

    8

    5

     

    R – S

    A

    B

    1

    3

     

    S – R

    A

    B

    8

    5

     

    R ∩ S ≡ R – (R – S) ≡ S – (S – R) ≡ ((R U S – (S – R)) – (R – S)

    A

    B

    2

    4

     

    R U S – ((S – R) – (R – S))

    A

    B

    1

    3

    2

    4

     

    Hence R U S – ((S – R) – (R – S)) is not equivalent to R ∩ S 

  • Question 4
    2 / -0.33

    Consider a relation R(X, Y, Z, W) where X, Y, and Z are attributes and the functional dependencies are X → Y and X → Z.

    What is the number of functional dependencies possible with attribute X?

    Solution

    Functional Dependencies are X → Y and X → Z.

    {X}+ = {YZ}

    8 FD’s are possible

    X → ϕ, X → X,  X → Y, X → Z

    X → XY, X → XZ,  X → YZ, X → XYZ

    The number of functional dependencies possible with attribute B is 4

    Shortcuts:

    Number of FD’s possible = 2n

    where n is the number of attributes in the closure of X

    Number of FD’s possible = 23 = 8.
  • Question 5
    2 / -0.33

    The following table has two attributes X and Y where X is the primary key and Y is the foreign key referencing X with on-delete cascade.

    X

    Y

    2

    4

    3

    4

    4

    3

    5

    2

    7

    2

    9

    5

    6

    4

     

    The set of all tuples that must be additionally deleted to preserve referential integrity when the tuple (3, 4) is deleted is: 

    Solution

    When tuple (3,4) is deleted, then as 3 is referencing to Y because Y is the foreign key. So, in the above table entries that contain 3 in their Y attribute will be deleted.

    So, (4,3) will be deleted. Now, we should delete the row which contains 4 in their Y attribute.

    So, (2,4) and (6,4) will be deleted. Now, we should delete the row which contains 2 and 6 in their Y attribute

    (5,2) and (7, 2) will be deleted. Now, we should delete the row which contains 5 and 7 in their Y attribute

    So, (9,5) will be deleted. Since no Y attibute doesn't have 9, deletion stops. .

  • Question 6
    2 / -0.33
    Given two table R1 (x, y) and R2(y, z) with 50 and 30 number of tuples respectively. Find maximum number of tuples in the output of natural join between tables R1 and R2 i.e. R1 * R2? (* - Natural Join)
    Solution

    Concept:

    A natural join is based on common attributes or common columns to join two tables or relations.

    Explanation:

    Consider an example, suppose there are two tables Employee(Eid, Ename) consists of 5 tuples and department(Eid, Did) consists of 3 tuples only.

    Eid

    Ename

    1

    E1

    2

    E2

    3

    E3

    4

    E4

    5

    E5

     

    Eid

    Did

    1

    D1

    2

    D2

    3

    D3

     

    Natural join of employee and department(Employee * Department) gives:

    Eid

    Ename

    Did

    1

    E1

    D1

    2

    E2

    D2

    3

    E3

    D3

     

    So, maximum number of tuples in natural join are from the relation having minimum tuples. So, in given question, R2 contains 30 tuples, so , maximum number of tuples in the output of natural join between tables R1 and R2 i.e. R1 * R2 = 30.

  • Question 7
    2 / -0.33
    Consider a B+ tree in which the minimum number of keys in a node is 23. What is the maximum number of keys in any non-root node?
    Solution

    Data:

    Minimum number of keys = MIN = 23

    order of a B+ tree = p

    Formula:

    MIN = ⌈p ÷ 2⌉ – 1

    Maximum number of keys = MAX = p – 1

    Calculation:

    23 = ⌈p ÷ 2⌉ – 1  

    If p = 48 and p = 47

    Satisfied the condtion

    Maximum number of keys = p – 1 = 48 – 1 

    Maximum is 47.

  • Question 8
    2 / -0.33

    Assume that there are two transactions T1 and T2 of which T1 started execution before T2. Consider the following schedule involving two transactions T1 and T2

    T1:r(A) T2: r(B)  T2:w(A) T1:w(A)

    Which of the following is true about the following schedule

    Solution
    T1 is rolled back under basic timestamp order protocol
  • Question 9
    2 / -0.33

    Given below is an instance of the MENTOR relation:

    MentorID

    Name

    Salary

    Age

    Department

    1001

    Priya

    10000

    23

    English

    1002

    Sheenam

    20000

    25

    Maths

    1003

    Priya

    25000

    X

    Maths

    1004

    Renu

    10000

    25

    Science

    1005

    Renu

    12000

    27

    English

     

    For (Name, Age) to be a key for this instance, the value X should not be equal to_________.

    Solution

    For (Name, Age) to be a key for this instance, the pair (Name, Age) should be unique. Therefore, X should not be equal to 23 to make it a key.

  • Question 10
    2 / -0.33
    If R(ABC) with FDs = AB → C, AC → B, BC → A, then what is the strongest normal form that is not violated by this relation?
    Solution

    A relation schema R is in BCNF, only if in every non-trivial functional dependency 

    X → Y 

    X is a superkey

    R(ABC)

    (AB)+ = {A, B, C}

    (AC)+ = {A, B, C}

    (BC)+ = {C, B, A}

    Candidate key: AB, AC and BC

    BCNF is the strongest form which is not violated.

  • Question 11
    2 / -0.33

    Consider the following query :

    SELECT E.eno, COUNT(*)

    FROM Employees E

    GROUP BY E.eno

    If an index on eno is available, the query can be answered by scanning only the index if

    Solution

    A clustered index is when a file is organized so that ordering of the data records is the same as or close to the ordering of data entries in the index.  Alternative 1 by definition is clustered.  An index that uses Alternative2 or3 can be a clustered index only if the data records are sorted on the search key field.

    A clustered index offers much better range query performance, but essentially the same equality search performance (modulo duplicates) as an unclustered index. Further, a clustered index is typically more expensive to maintain than an unclus­tered index. Therefore, we should make an index be clustered only if range queries are important on its search key. At most one of the indexes on a relation can be clustered, and if range queries are anticipated on more than one combination of fields, we have to choose the combination that is most important and make that be the search key of the clustered index.

  • Question 12
    2 / -0.33
    Consider the relation R = {ABCDEG} and set of FDs are F = {AB → C, AC → B, AD → E, B →D, BC → A, E → G}, then the decomposition {ABC, ACDE, ADG} is 
    Solution

    F = {AB → C, AC → B, AD → E, B →D, BC → A, E → G}

    R1(ABC)

    AB → C

    AC → B

    BC → A 

    R2(ACDE)

    AD → E

    AC → D (From AC → B and B → D)

    R3(ADG)

    AD → G (From AD → E and E → G)

    Decomposition is not dependency preserving because B → D and E → G cannot be generated after decomposition

    Decomposition is lossless:

    R1(ABC) and R2(ACDE) contains (AC) and (AC) is key in R1 or R2

    Therefore it is lossless

    Consider the joined table be R4

    Now R4(ABCDE) and R3(ADG) contains (AD) and (AD) is key in R3

    Therefore it is lossless

    Hence decomposition is lossless. 

  • Question 13
    2 / -0.33

    Consider a relation book (title, price) which contains the titles and prices of different books.

    Assuming that no two books have the same price, what does the following SQL query list ?

    Select title

    from book as B

    where (select count (*)

    from book as T

    where T.price > B.price) < 7
    Solution

    no two books have the same price

    Assume table BOOK B :

    Title

    Price

    A

    10

    B

    20

    C

    30

    D

    40

    E

    50

    F

    60

    G

    70

    H

    40

     

    Book T:

    Title

    Price

    A

    10

    B

    20

    C

    30

    D

    40

    E

    50

    F

    60

    G

    70

    H

    40

                   

    One record is compared with all the records of another table. I.e. if we consider A (10) in Book T, then it is compared against all the records of book B. it is not greater than any record.

    Now compare B(20) of book T with all records of book B. So, it is greater than 1 record.

    Compare C(30) of book T with all records of book B. So, it is greater than 2 record.

    Compare D(40) of book T with all records of book B. So, it is greater than 3 record.

    Compare E(50) of book T with all records of book B. So, it is greater than 4 record.

    Compare F(60) of book T with all records of book B. So, it is greater than 5 record.

    Compare G(70) of book T with all records of book B. So, it is greater than 6 record.

    Compare H(40) of book T with all records of book B. So, it is greater than 3 record.

    Title

    B

    C

    D

    E

    F

    G

    H

     

    So, it will result in title of seven most expensive books.
  • Question 14
    2 / -0.33

    In a relational schema R(P, Q, R, S, T, V) with functional dependencies are given below:

    P → RS

    R → SV

    S → Q

    T → P

    What is the number of superkey possible in R?

    Solution

    Concepts:

    Any superset of a key (primary key or candidate key) is a superkey.

    Explanation:

    T+ = {T, P, R, S, Q, V}

    T is the only candidate key

    ∴ T is the primary key

    Data:

    n → total number of attributes = 6

    n(s) → total number of super keys

    Since T is a primary key it must be included in every superkey.

    Attribute P, Q, R, S, and V may or may not included in superkey.

    Formula:

    Since only one superkey is present in the relation:

    n(S) = 2n -1

    Calculation:

    n(S) = 26-1 = 25 = 32

    Examples of Superkeys are: {T, TP,TQ, TR...}.

    Important Point:

    A primary key is chosen from a set of candidate key since there is only one candidate key, it is treated as a primary key. 

  • Question 15
    2 / -0.33

    Consider the following relation schema R and S along with their tuple sets.

    R(A, B) = {<a1, b1 >, <a2, b1>, <a3, b1>, <a4, b1), <a1, b2>, <a3, b2>, <a2, b3>, <a3, b3>, <a4, b3>, <a1, b4>, <a2, b4>, <a3, b4>}

    S(A) = {a1, a2, a3}

    What is the value of T ← R/S, where “/” represents the Relational Algebra “division” operation?
    Solution

    The relation returned by the division operator between two relations A and B are those tuples from relation A which are associated to every B’s tuple.

    R:

    A

    B

    a1

    b1

    a2

    b1

    a3

    b1

    a4

    b1

    a1

    b2

    a3

    b2

    a2

    b3

    a3

    b3

    a4

    b3

    a1

    b4

    a2

    b4

    a3

    b4

     

    S:

    A

    a1

    a2

    a3

     

    T = R/S

    T:

    B

    b1

    b4

  • Question 16
    2 / -0.33

    Consider the following tuple relational calculus:

    {t | Ǝ s ε instructor (t[name] = s[name]

        ᴧ Ǝ u ε department (u[dept_name] = s[dept_name]

             ᴧ u[building] = “Taylor”))}

    What does the given expression perform?

    Solution

    There are two 'there exists' clauses in the given tuple relational calculus which are connected by and (ᴧ). The tuple variable u is restricted to departments that are located in the Taylor building, while tuple variable s is restricted to instructors whose dept_name matches that of tuple variable u.

    Therefore, the given expression finds the names of all instructors whose department is in the Taylor building.

  • Question 17
    2 / -0.33

    Database table name Group_A  and Group_B is given below

    Group_A

    Roll_no

    Student_Name

    Age

    10

    X

    18

    15

    Z

    20

    19

    Y

    17

    22

    Z

    19

    89

    Y

    21

    22

    Y

    20

     

    Group_B

    Roll_no

    Student_Name

    Age

    06

    X

    19

    25

    V

    21

    19

    Y

    18

    2

    Z

    20

    22

    W

    17

     

    How many tuples does the result of the following SQL query contain?

    Select Group_A.Roll_no

    FROM Group_A

    Where Group_A.age > All(SELECT Group_B.Age

     FROM Group_B

    where Group_B.Student_Name = ‘Y’)
    Solution

    Inner query:

    SELECT Group_B.Age

     FROM Group_B

    where Group_B.Student_Name = ‘Y’

    Output: 18

    Outer query:

    Select Group_A.Roll_no

    FROM Group_A

    Where Group_A.age > All(18)

    Output:             

    Roll_no

    15

    22

    89

    22

     

    Therefore, number of tuples in a table is 4
  • Question 18
    2 / -0.33

    Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values.

    F={CH→G, A→BC, B→CFH, E→A, F→EG} is a set of functional dependencies (FDs) so that F+ is

    exactly the set of FDs that hold for R.

    The relation R is 

    Solution

    In R(ABCDEFGH), left-hand side of FD has attributes: {G, B, C, F, H, A, E, G} 

    Since it doesn't contain D we cannot derive it unless it is the present right-hand side. 

    (AD)+ =  {A,D, B, C, F, H, G, E } 

    Since all the 8 attributes are present, AD is a candidate key

    (BD)+ =  {B, D, C, F, H, G, E, A } 

    Since all the 8 attributes are present, BD is a candidate key

    (ED)+ =  {E, D, A, B, C, F, H, G } 

    Since all the 8 attributes are present, ED is a candidate key

    (FD)+ =  {F, D, E, G, A, B, C, H } 

    Since all the 8 attributes are present, FD is a candidate key

    The non-prime attributes are dependent on a partial candidate key.

    A → BC      ---(A → C)
    B → CFH    ---((B → H)
    F → EG      ----(F → G)

    Therefore it is in 1NF but not in 2 NF

Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

    out of -
Re-Attempt Weekly Quiz Competition
Self Studies Get latest Exam Updates
& Study Material Alerts!
No, Thanks
Self Studies
Click on Allow to receive notifications
Allow Notification
Self Studies
Self Studies Self Studies
To enable notifications follow this 2 steps:
  • First Click on Secure Icon Self Studies
  • Second click on the toggle icon
Allow Notification
Get latest Exam Updates & FREE Study Material Alerts!
Self Studies ×
Open Now