Self Studies

Databases Test 2

Result Self Studies

Databases Test 2
  • 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
    A relation R(A, B, C) having the following tuples (2, 3, 4) (4, 1, 2) (5, 2, 2) (1, 3, 2). Which of the following functional dependency does not hold true from this relation?
    Solution

    Concept:

    A functional dependency A -> B is true in a relation R(A, B) if

    1) There is different value for attribute A for all the tuples.

    2) If two values are same in A, then their corresponding value in B must also be same.

    Explanation:

    Given relation R (A, B, C) with the tuples (2, 3, 4) (4, 1, 2) (5, 2, 2) (1, 3, 2)

    These are represented in the form of table as:

    A

    B

    C

    2

    3

    4

    4

    1

    2

    5

    2

    2

    1

    3

    2

     

    Consider all the options one by one:

    1. B -> C

    Here, B has two values equal i.e. 3. Their corresponding in value must be same in C but it is different here. One value for 3 is 4 and other is 2. So, it is not correct.

    2. A -> B

    This one has all different value for A. So, this functional dependency holds true.

    3. AC -> B

    All value for AC are different. So, functional dependency is true.

    4) BC -> A

    Same with this, All the values in BC are different. So, it holds true.

  • Question 2
    2 / -0.33

    Which of the following is/are not a part of the ACID properties of database transactions?

    Solution

    ACID Properties:

    A transaction in a database system must maintain Atomicity, Consistency, Isolation, and Durability − commonly known as ACID properties − in order to ensure accuracy, completeness, and data integrity.

    Atomicity − This property states that a transaction must be treated as an atomic unit, that is, either all its operations are executed or none.

    Consistency − The database must remain in a consistent state after any transaction. No transaction should have any adverse effect on the data residing in the database.

    Isolation − In a database system where more than one transaction is being executed simultaneously and in parallel, the property of isolation states that all the transactions will be carried out and executed as if it is the only transaction in the system.

    Durability − The database should be durable enough to hold all its latest updates even if the system fails or restarts.

    Therefore, Duration and Independent are not a part of the ACID properties of database transactions?

  • Question 3
    2 / -0.33

    Consider the following relational schema for students(STU):

    id

    name

    age

    marks

    1

    PPP

    13

    56

    2

    QQQ

    14

    67

    3

    RRR

    13

    76

    4

    AAA

    15

    56

    5

    BBB

    14

    58

    6

    CCC

    16

    79

    7

    SSS

    16

    80

    8

    TTT

    13

    73

    9

    RRR

    14

    54

    10

    YYY

    15

    42

    The following query is made on the database.

    T1 → \({{\rm{\Pi }}_{id,name}}\left( {{\sigma _{age > 13 \wedge age < 16}}\left( {STU} \right)} \right)\)

    T2 → \({{\rm{\Pi }}_{id,name}}\left( {{\sigma _{marks > 55 \wedge marks < 66}}\left( {STU} \right)} \right)\)

    T → T2 - T1

    The total no. of rows in T is ______. 

    Solution

    T1 → \({{\rm{\Pi }}_{id,name}}\left( {{\sigma _{age > 13 \wedge age < 16}}\left( {STU} \right)} \right)\)

    Output: 

    id

    name

    2

    QQQ

    4

    AAA

    5

    BBB

    9

    RRR

    10

    YYY

    Number of rows: 5

    T2 → \({{\rm{\Pi }}_{id,name}}\left( {{\sigma _{marks > 55 \wedge marks < 66}}\left( {STU} \right)} \right)\)

    Output:

    id

    name

    1

    PPP

    4

    AAA

    5

    BBB

    Number of rows: 3

    T → T2 - T1

    Output:

    id

    name

    1

    PPP

    T contains 1 row:

  • Question 4
    2 / -0.33

    Let Account be a relation with attributes (customer_name, amount). Consider

    (i) {T |~Tϵ Account}

    (ii) {T | T ϵ Account}

    Which of the following statement is correct about this?
    Solution

    Concept:

    Safe expression: A safe expression is one that is guaranteed to yield a finite number of tuples in the result.

    Unsafe expression: An expression which result in infinite number of tuples or which does not guarantee about finite number of tuples is an unsafe expression tuple relational calculus.

    Explanation:

    Tuple relational calculus provides the description of query but does not provide methods to solve it.

    An expression {t | P(t)} means set of all the tuples such that predicate P(t) is true for t.

    Here in this question,

    (i) {T |~Tϵ Account}

    It means, all who does not belongs to the relation account. There may be infinite number of tuples for this. So, it is an unsafe expression.

    (ii) {T | Tϵ Account}

    This results in finite number of tuples. So, it is a safe expression.

  • Question 5
    2 / -0.33
    Records are stored in some sorted order based on some search key and that search key is also sorted, is
    Solution

    Primary index:

    It is defined on an ordered data file and the data file is ordered on a key field. The key field is generally the primary key of the relation.

    Clustering Index:

    It is defined on an ordered data file. The data file is ordered on a non-key field.

    Secondary index:

    It may be generated from a field which is a candidate key and has a unique value in every record, or a non-key with duplicate values only dense ordering in the non-clustered index (Secondary index) as sparse ordering is not possible because data is not physically organized accordingly.

  • Question 6
    2 / -0.33

    Let X (a, b, c, d) and Y (p, q, r, s) be two relations in which a is the foreign key of X that refers to the primary key of Y. Which of the following operation does not causes the referential integrity constraint violation?

    Solution

    Attribute of X is referring to attribute of Y:

    If a row is deleted from X, no violation, since X is a referring relation and hence no violation

    But if a row is inserted into X, since X is referring to Y, X may contain value outside the domain of primary key of Y.

    If a row is inserted into Y, no violation, since Y is not referring to any other table and hence no violation

    But if a row is deleted from Y, since Y is being referred by X, referred value may be deleted which leads to violation.

    Hence Insert into Y and Delete from X doesn’t cause violation but insert into X causes violation.

  • Question 7
    2 / -0.33

    Consider 4 transactions T1, T2, T3, and T4 Transaction T1 has 5 transactions, T2 has 4 transactions,  T3 has 3 transactions and T4 has 2 transactions. What is the number of non-serial schedule?

    Solution

    Total number of schedule possible = \(\frac{{\left( {T_{1} + T_{2} + T_{3}+ T_{4}} \right)!}}{{T_{1}!\times T_{2}!\times T_{3} ! +T_4!}} \)

    Total number of schedule possible = \(\frac{{\left( {5 + 4 + 3+ 2} \right)!}}{{5!\times 4! \times 3! \times2!}} =2522520\)

    Total number of serial schedule possible = \(n!\)

    where n is the total number of transaction

    Total number of serial schedules = 4! = 24

    Total number of non-serial schedules =2522520 - 24 = 2522496

  • Question 8
    2 / -0.33

    Which of the following statement is/are true?

    I. A transaction writes a data item after it is read by an uncommitted transaction leads to an irrecoverable error in a database system.

    II. Timestamp ordering protocol does not ensure freedom from deadlock

    III. In case of disk crash, Among the ACID property, the durability property fails to make changes successfully in the database
    Solution

    A transaction read a data item after it has been written by an uncommitted transaction leads to an irrecoverable error in a database system.

    ∴ statement I false

    Time stamp ordering protocol ensures freedom from deadlock

    ∴ statement II false

    In the ACID property, the durability property makes changes successfully in the database in case of:

    Power failure, dish crash or operating system crash

    ∴ statement III false

    None of the statements are true therefore answer is option 4
  • Question 9
    2 / -0.33
    Consider a schema R(X, Y, Z W) and functional dependencies X → Y and W → Z. Then the decomposition of R into T1(X, Y) and T2(Z, W) is
    Solution

    T1(X, Y)

    T2(Z, W)

    X → Y

    W → Z

     

    Therefore, X → Y and W → Z are preserved, after the decomposition.

    There is no common attribute of T1 and T2, therefore decomposition is lossy.

    The decomposition of R into T1(X, Y) and T2(Z, W) is dependency preserving but not lossless join

  • Question 10
    2 / -0.33

    Which of the following is/are true if a relation R has six attributes A, B, C, D, E, and F. The following functional dependencies hold AB → C, B → D, AD → F, C → D, D → E, E → F, F → D.

    Solution

    In R1(DEF),

    D+ = {D, E, F}

    E+ = {E, F, D}

    F+ = {F, D, E}

    Therefore D, E and F are candidate key

    Number of super keys:

    n(D U E U F) = n(D) + n (E) + n(F) – n(DE) – n(DF) – n(EF) + (DEF)

    = 23 – 1 + 23 – 1 + 23 – 1 - 23 – 2 - 23 – 2 - 23 – 2 + 23 – 3

    = 4 + 4 + 4 – 2 – 2 – 2 + 1

    = 7

    Therefore option 1 and 4 are correct.

    Tips and Tricks:

    Since every key is candidate key then every possible key is a super key except Φ

    ∴ number of super keys = 23 – 1 = 7
  • Question 11
    2 / -0.33

    Which of the following is true for the below given functional dependencies of the relation R(X, Y,Z,W) and S(X, Y, Z, W)?

    R: {X → Y, XY → Z, W → XZ, Z → W}

    S: {X → YZ, W → XY}

    I. R ⊇ S

    II. S ⊇ R

    Solution

    Check: R ⊇ S

    X+ = {Y, Z, E}

    ∴ X → YZ

    W+ = {W, X, Z, Y}

    W → XY

    Hence R is covering S, that is, R ⊇ S

    Check: S ⊇ R

    X+ = {X, Y, Z}

    ∴ X → Y

    (XY)+ = {X, Y, Z}

    ∴ XY → Z

    W+ = {W, X, Y, Z}

    ∴ W → XZ

    Z+ = {Z}

    Z → W, it cannot be determined by S

    and hence, S cannot cover R, that is, S ⊇ R is false

    Only I is correct.
  • Question 12
    2 / -0.33
    Consider a relation R(ABC) with Functional dependency {AB → C, AC → B, BC → A}.Which of the following is/are TRUE about the normal form that the relation R is in?
    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.

    Since R is in BCNF. Therefore it is also in 1NF, 2NF and 3NF

  • Question 13
    2 / -0.33

    Database table name Tuition_Records is given below

    Students

    Teachers

    Fees

    Aniket

    Uday

    10000

    Barbie

    Rishi

    7000

    Chandresh

    Uday

    12000

    Dharma

    Rishi

    9000

     

    SELECT count(*) FROM ((SELECT students, Teachers FROM Tuition_Records) AS A NATURAL JOIN (SELECT Teachers, Fees FROM Tuition_Records))

    What is the output of the following SQL query?
    Solution

    A:

    Students

    Teachers

    Aniket

    Uday

    Barbie

    Rishi

    Chandresh

    Uday

    Dharma

    Rishi

     

    B:

    Teachers

    Fees

    Uday

    10000

    Rishi

    7000

    Uday

    12000

    Rishi

    9000

     

    A NATURAL JOIN B

    Students

    Teachers

    Fees

    Aniket

    Uday

    10000

    Aniket

    Uday

    12000

    Barbie

    Rishi

    7000

    Barbie

    Rishi

    9000

    Chandresh

    Uday

    10000

    Chandresh

    Uday

    12000

    Dharma

    Rishi

    7000

    Dharma

    Rishi

    9000

     

    SELECT count(*) FROM A NATURAL JOIN B

    OUTPUT: 8
  • Question 14
    2 / -0.33

    Consider the schema

    Sailors(sid, sname, rating, age) with the following data

    Sid

    Sname

    Rating

    age

    22

    Dustin

    7

    45

    29

    Borg

    1

    33

    31

    Pathy

    8

    55

    32

    Robert

    8

    25

    58

    Raghu

    10

    17

    64

    Herald

    7

    35

    71

    Vishnu

    10

    16

    74

    King

    9

    35

    85

    Archer

    3

    26

    84

    Bob

    3

    64

    96

    Flinch

    3

    17

    For the query

    SELECT S.rating, AVG(S.age) AS avgage FROM Sailors S

    Where S.age >= 18

    GROUP BY S.rating

    HAVING 1 < (SELECT COUNT(*) FROM Sailors S2 where S.rating = S2.rating)

    The number of rows returned is

    Solution

    Without "having" clause query calculates the average age (where age >= 18) and groups by ratings so table returned is:

    RatingAverage
    133
    345
    740
    840
    935

    After applying "having" clause table returned is:.

    RatingAverage
    345
    740
    840
  • Question 15
    2 / -0.33

    Consider the following schedule of transactions T1, T2, T3 and T4.

    T2: R(Y) T2: R(X); T3: R(X); T3: commit; T1:W(X); T2:W(Y); T2: R(z); T2: commit; T4: R(X); T4: R(Y); T1:W(Z); T1:commit; T4:commit.

    Which of the following is correct about this?
    Solution

    Concept:

    Conflict serializable schedule: A schedule is conflict serializable if we can convert it into a serial schedule after swapping of non conflicting operations. If there is no loop in the precedence graph, then schedule is conflict serializable.

    Recoverable schedule: If some transaction Tj is reading value update by Ti, then commit of Tj must occur

    After the commit of Ti.

    Cascadeless schedule: A transactionTj can only read the value updated by T1 after the commit of T1.

    Explanation:

    Following schedule of transactions can be represented in the form of table as :

    T1

    T2

    T3

    T4

     

    R(Y)

     

     

     

    R(X)

     

     

     

     

    R(X)

     

     

     

    COMMIT

     

    W(X)

     

     

     

     

    W(Y)

     

     

     

    R(Z)

     

     

     

    COMMIT

     

     

     

     

     

    R(X)

     

     

     

    R(Y)

    W(Z)

     

     

     

    COMMIT

     

     

     

     

     

     

    COMMIT

     

    (i) As, all the operations are non- conflicting here. So, schedule is conflict serializable.

    (ii) here, T4 is reading the value update by T1. So, commit of T1 must be before T4. Also, T4 is reading

    The value updated by T2 and commit of T2 is before T4. So, schedule is recoverable.

    (iii) This schedule is not cascaseless. Because T4 is reading the value update by T1. But commit of T1 is not before the read of T4. 

  • Question 16
    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.

    How many candidate keys does the relation R have?

    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

    Therefore there are total 4 candidate keys.

  • Question 17
    2 / -0.33
    Consider a file based system in which total overhead for each entry in the file allocation table is 2 bytes in size. Given a 100 × 104 bytes of disk on which file system is stored. Block size of data is 102 bytes, then the maximum file size possible that can be stored on the disk is(in 104 bytes)?
    Solution

    Given:

    Data block size = 102 bytes

    Disk capacity = 100 × 104 B

    Entries in file allocation table \( = \frac{{disk\;capacity}}{{block\;size}} = \frac{{{{10}^6}}}{{{{10}^2}}} = {10^4}\;\)

    Overhead for each entry in FAT = 2 Bytes

    So, total capacity of File allocation table =  104 × 2 Bytes

    Maximum file size that can be stored on disk = 100 × 104 – 2 ×104

    = 98 × 104 Bytes

  • Question 18
    2 / -0.33

    Consider the database that has the relation schema T (X, Y). An instance of the schema T is as given below:

    T1 ← ∏YX = A3 (T))

    T2 ← T ÷ T1

    X

    Y

    A1

    B1

    A1

    B2

    A2

    B1

    A2

    B2

    A1

    B3

    A3

    B1

    A3

    B2

    A2

    B1

    A4

    B1

    A3

    B3

    A4

    B2

     

    Find the number of rows in T2

    Solution

    T1 ← ∏YX = A3 (T))

    T1:

    Y

    B1

    B2

    B3

     

    T2 ← T ÷ T1

    X

    A1

    A3

     

    Therefore, relation T2 contains 2 rows:

    Tips and Tricks:

    After getting the relation of T1, match the value of Y with T and if single value of X corresponds to each values of Y in T1 then include it into T2.
  • Question 19
    2 / -0.33

    Which of the following is/are true?

    Solution

    In the case of M:N, there is a need for a separate table for relationship and hence option 1 is correct

    In the case of I:M and 1:1, there is no need for a separate table for relationships. It can be combined with M side in 1:M case and with any side in 1:1. Hence option 2 is incorrect 

    In the case of a multi-valued attribute separated table is needed. Hence option 3 is correct

    Also, the Cardinality ratio is applicable for only binary relationships, option 4 is correct

  • Question 20
    2 / -0.33

    Consider the following transactions with data items X and Y initialized to zero:

    T1: read (x);

    Read (y);

    if x = 0 then y: = y + 1;

    Write (y);

    T2: read (y);

    write (x);

    If y = 0 then x: x + 1

    Write (x);

    The concurrent execution of T1­ and T­2 lead to
    Solution

    Concept:

    Two schedules are said to be conflict equivalent if the order of any two conflicting operations is the same in both the schedules. A schedule S is said to be conflict serializable if it is conflict equivalent to some serial schedule S’.

    Explanation:

    There can be two cases possible for above given transaction:

    1) T1 is followed by T2

    In this, read (x) for T1 is executed before write (x) of T2.

    2) If T2 is followed by T1

    then read(y) of T2 is executed before write (y) of T1.

    In both the cases, if we try to make any non-serial schedule, then there will be conflict from both T1 -> T2 and T2 -> T1. Precedence graph will contain cycle.

    Consider we are taking Schedule S: r1(x) r2(y) r1(y) w2(x) w2(y) w1(y).

    For this, precedence graph contains cycle. So, the concurrent execution of T1 and T2 leads to a non-conflict serializable schedule.
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