Self Studies

Databases Test 3

Result Self Studies

Databases Test 3
  • 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
    1 / -0

    Which of the following expressions should be used to find the name and address of all students who study in the ‘Science’ department?

    The relational schemas are:

    Student(Sno, name, address, age)

    Department(Dno, Dname, Snumber, building)

    Solution

    To retrieve the name and address of all students who study in the Science department, first select the Science department using 'select' operator and then join the result with the 'Student' table on the condition where Snumber = Sno.

    Finally, a project operation is applied to get name and address of the students.

    Therefore, the expression must be \(∏_{name, address}(σ_{Dname ='Science'}(Department ⋈_{Snumber = Sno} (Student))\).

  • Question 2
    1 / -0

    Consider a database that has the relation schema Random(A, B, C). An instance of the schema Random is as given below.

    A

    B

    C

    10

    10

    7

    10

    7

    10

    7

    10

    7

    10

    7

    7

    10

    13

    7

    13

    10

    7

    10

    7

    13

    10

    2

    7

     

    Tuple calculus expression for the above instance is given as  {t.B | t ϵ r ∧ (t[A] = 10  ∧ t[C] = 7)}

    What is the sum of the elements in the output row of the given expression?

    Solution

    A = 10 and C = 7

    A

    B

    C

     

    10

    10

    7

    True

    10

    7

    10

     

    7

    10

    7

     

    10

    7

    7

    True

    10

    13

    7

    True

    13

    10

    7

     

    10

    7

    13

     

    10

    2

    7

    True

     

    Output:

    B

    10

    7

    13

    2

     

    Therefore, sum = 10 + 7 + 13 + 2 = 32

  • Question 3
    1 / -0

    Which of the following has the same expressive power with regard to relational query language?

    (a) Relational algebra and Domain relational calculus

    (b) Relational algebra and Tuple relational calculus

    (c) Relational algebra and Domain relational calculus restricted to safe expression

    (d) Relational algebra and Tuple relational calculus restricted to safe expression

    Solution
    • Relational algebra is a procedural query language, which takes instances of relations as input and yields instances of relations as output. It uses operators (selection, projection, union etc) to perform queries.
    • Relational calculus consists of two calculi, the tuple relational calculus and the domain relational calculus, that are part of the relational model for databases and provide a declarative way to specify database queries
    • Relational algebra, Domain relational calculus restricted to safe expression and Tuple relational calculus restricted to safe expression have the same expressive power.


    Confusion Points:

    Relation algebra’s expressive power is not equal to Domain relational calculus or Tuple relational calculus unless they are restricted to safe operation.

  • Question 4
    1 / -0
    Let the database has two relations P(a, b) and Q(m, a, n) in which a is the primary key of the relation P and m is the primary of the relation Q. Instance of P has 70 Tuples and Instance of Q has 42. What is the maximum number of rows in the new instance produced by P ⨝ Q? (⨝ is natural join)
    Solution

    Example

    a is a key

    P

    a

    b

    A

    10

    B

    20

    C

    30

     

    m is a key

    Q

    m

    a

    n

    1

    A

    80

    2

    B

    50

     

    \(P~⨝~Q\equiv {{\sigma }_{P.a=Q.a}}\left(P\times Q \right)\)

    a

    b

    m

    n

    A

    10

    1

    80

    B

    20

    2

    50

     

    Maximum tuple possible = |Q| = 2

    From above example:

    Since |P| = 70 and |Q| = 42

     ∴ Maximum tuple possible = 42

  • Question 5
    1 / -0

    Consider the following relation Demo:

    IDnamesalary
    1A65000
    2B90000
    3C40000
    4D95000
    5E60000
    6F87000
    7G75000
    8H62000
    9I80000
    10J72000
    11K92000
    12L80000

     

    The number of tuples returned for the query \(Π_{salary} (Demo)-Π_{Demo.salary} (σ_{Demo.salary<d.salary} (Demo×ρ_d (Demo)))\) is ____.

    Solution

    Let T1\(Π_{Demo.salary} (σ_{Demo.salary<d.salary} (Demo×ρ_d (Demo)))\) gives those salaries in the demo relation for which a larger salary appears somewhere in the demo relation (renamed as d). The result contains all salaries except the largest one. 

    The query \(Π_{salary} (Demo)-Π_{Demo.salary} (σ_{Demo.salary<d.salary} (Demo×ρ_d (Demo)))\) then performs the set difference and returns the largest salary.

    Therefore, the row returned will be:

    salary
    95000

    Important Points:

    95000 is largest hence it not present in T1

    if salary of original table is subtracted with T1 then output is

    Therefore, the row returned will be:

    salary
    95000
  • Question 6
    1 / -0

    Let the two-relation schema be R (A, B,) and S (A, B). which of the following is equivalent to R ∩ S

    I. R – (R – S)

    II. S – (S – R)

    III. R U S – ((S – R) – (R – S))

    IV. ((R U S – (S – R)) – (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 7
    1 / -0

    Consider the following relational schema for Employees (SME):

    Test ID

    TestSeries Name

    SME Age

    Ratings

    1

    GATE CS

    25

    9.5

    2

    GATE ME

    29

    9.6

    3

    GATE EE

    28

    9.3

    4

    RRB JE IT

    26

    9.0

    5

    RRB JE ME

    24

    9.1

    6

    RRB JE EE

    20

    9.2

    7

    ESE EC

    22

    8.9

    8

    ESE CE

    23

    9.3

    9

    SSC CGL

    31

    9.6

    10

    CIL Systems

    28

    9.4

    11TET259.2

    The following query is made on the database.

    D1 → \({{\rm{\Pi }}_{Test \;ID,\; TestSeries\;Name}}\left( {{\sigma _{SME\;age > 23 \wedge SME\; age < 26}}\left( {SME} \right)} \right)\)

    D2 → \({{\rm{\Pi }}_{Test\;ID,TestSeries\;Name}}\left( {{\sigma _{Ratings > 9.1 \wedge Ratings < 9.4}}\left( {SME} \right)} \right)\)

    D → D2 - D1

    The total no. of rows in D is ______. 

    Solution

    Query: D1 → \({{\rm{\Pi }}_{Test \;ID,\; TestSeries\;Name}}\left( {{\sigma _{SME\;age > 23 \;\wedge\; SME\; age < 26}}\left( {SME} \right)} \right)\)

    Output: 

    Test ID

    TestSeries Name

    1

    GATE CS

    5

    RRB JE ME

    11

    TET

    The number of rows: 3

    Query: D2 → \({{\rm{\Pi }}_{Test\;ID,TestSeries\;Name}}\left( {{\sigma _{Ratings > 9.1 \wedge Ratings < 9.4}}\left( {SME} \right)} \right)\)

    Output:

    Test ID

    TestSeries Name

    3

    GATE EE

    6

    RRB JE EE

    8

    ESE CE

    11TET

    The number of rows: 4

    Query: D → D2 - D1

    Output:

    Test ID

    TestSeries Name

    1

    GATE EE

    5RRB JE EE
    8ESE CE

    D contains 3 rows.

  • Question 8
    1 / -0

    Consider the following relation schema

    Sailors(sid, sname, rating, age)

    Reserve(sid, bid, day)

    Boats(bid, bname, color)

    What is the equivalent of following relational algebra query in SQL query.

    πsname((σcolor= ‘red’Boats) Reserves Sailors)  

    Solution

    Sailors:

    Sid

    Sname

    Rating

    Age

    S1

    SA

    1

    30

    S2

    SB

    2

    40

    S3

    SC

    3

    50

    S4

    SD

    3

    20

    S5

    SA

    4

    30

     

    Reserves:

    Sid

    Bid

    Day

    S1

    B1

    Tue

    S2

    B2

    Wed

    S3

    B3

    Thu

    S4

    B4

    Fri

    S5

    B5

    Mon

     

    Boats:

    Bid

    Bname

    Color

    B1

    BA

    Red

    B2

    BB

    Blue

    B3

    BC

    Red

    B4

    BD

    Green

    B5

    BA

    Red

     

     Given query: πsname((σcolor= ‘red’Boats) Reserves Sailors) 

    This query first find the boats having red color than matches B.Bid with R.Sid where it finds equal than matches R.Sid with S.Sid  , at that point finds the name of sailors with same sid.

    Here it results in sailor SA, SC, and SD.

    This query matches with:

    SELECT S.sname

    FROM Sailors S, Reserves R, Boats B

    WHERE S.sid = R.sid AND R.bid = B.bid AND B.color = ‘red’

  • Question 9
    1 / -0

    Consider the following relations:

    course:

    course_idtitledeptnamecredits
    E-101Digital logicElectrical3
    E-102Analog electronicsElectrical4
    CS-101AlgorithmsComputer Science4
    CS-102Data structureComputer Science2
    M-101Strength of materialsMechanical3
    CS-103Theory of computationComputer Science3
    F-101Financial managementFinance3
    M-102TurbomachinesMechanical4

     

    teaches:

    IDcourse_idsec_idsemesteryear
    101CS-1011Even2009
    102CS-1021Even2008
    103CS-1012Odd2010
    104E-1011Odd2012
    105CS-1031Even2011
    106M-1011Odd2014
    107E-1022Odd2011

     

    instructor:

    IDnamedeptnamesalary
    101PriyaComputerScience20000
    102ShikhaComputerScience30000
    103AnjaliComputerScience14000
    104RamElectrical24000
    105KritiComputer Science15000
    106ShamMechanical16000

     

    What is the number of tuples returned when the following query is executed:

    \(Π_{name,title} (σ_{deptname="Computer Science"}(instructor⋈teaches⋈course)) \)

     

    Solution

    The above query finds the names of all instructors in the ComputerScience department together with the course titles of all the courses that the instructors teach.

    The result of the given query is:

    nametitle
    PriyaAlgorithms
    AnjaliAlgorithms
    ShikhaData structure
    KritiTheory of computation

     

    Therefore, the number of tuples returned = 4

  • Question 10
    1 / -0

    Consider a database that has the relation schema CR(StudentName. CourseName). An instance of the schema CR is as given below.

    Employee_Record

    Employee_Name

    Department_Name

    EA

    DA

    EA

    DB

    EA

    DC

    EADD

    EB

    DB

    EB

    DC

    EBDA

    EC

    DA

    EC

    DB

    EC

    DC

    EBDD

    ED

    DA

    ED

    DB

    ED

    DC

    ED

    DD

    ECDD

    EE

    DD

    EE

    DA

    EE

    DC

    EF

    DA

    EEDB

    EF

    DC

     

    The following query is made on the above instance in Database

    TEMP ← ΠDepartment_NameEmployee_Name = ''ED" (Employee_Record))

    RESULT ← Employee_Record ÷ TEMP
    The number of rows in RESULT is _______. 

    Solution

    Query: TEMP ← ΠDepartment_Name(σ Employee_Name = ''ED" (Employee_Record))

    Output:

     TEMP

    DA

    DB

    DC

    DD

     

    Query: RESULT ← Employee_Record ÷ TEMP
    Output

    RESULT

    EA

    EB

    EC
    ED

    EE

     

    So, the number of rows returned by RESULT is 5.

Self Studies
User
Question Analysis
  • Correct -

  • Wrong -

  • Skipped -

My Perfomance
  • Score

    -

    out of -
  • Rank

    -

    out of -
Re-Attempt Weekly Quiz Competition
Selfstudy
Selfstudy
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