UT 1 Class XII Set a and B Answer Key Info

  • Upload
    avclpub

  • View
    220

  • Download
    0

Embed Size (px)

Citation preview

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    1/9

    UNIT CYCLE No 1 Class XII (SET A)(Answer Key)

    Subject : In!or"at#cs $ract#ces

    %ENE&AL INST&UCTI'NS All uest#ons are co"ulsory

    **+ ,- T#"e 1 .r+

    1 (a) Write MySql command to open an existing database.

    Use abc/ 'r Use any0atabasena"e/

    (b) Ms. Mirana wants to remove the entire content of a table BA!"#$ alongwith its str%ct%re to

    release the storage space. What MySql statement sho%ld she %se&

    ro table bac2u/

    (c) 'ive one difference between ()**BA! and )MM+, commands %sed in MySql.

    &'LL3ACK co""an0 #s use0 to 0#scar0 t4e c4an5es "a0e #n t4e

    0atabase u to last co""#t w4ereas co""#t co""an0 #s use0 to

    er"anent sa6e t4e 0ata #n an &3*S+

    (0) A table S,"-/,S has 0 rows and 1 col%mns and another table ,A2( has 3 rows and

    0 col%mns. 2ow many rows and col%mns will be there if we obtain the artesian prod%ct of

    these two tables&

    &ows17

    Colu"ns8

    (e) Mr. Sanghi created two tables with +,4 as #rimary !ey in ,able5 and 6oreign !ey in,able1. While inserting a row in ,able17 Mr. Sanghi is not able to enter a val%e in the col%mn

    +,4. What co%ld be the possible reason for it&

    &e!erent#al #nte5r#ty en!orce"ent ensures t4at 6alue "ust e9#st #n

    re!erre0 table !or success!ul #nsert#on #n t4e 0eart"ent table+

    '&

    Any relat#ons4# s4ow#n5 t4e r#"ary!ore#5n 2ey relat#ons4#+

    5

    (!) Mr. 8ana9 is %sing a table with following col%mns :

    /ame7 lass7 o%rse;+d7 o%rse;name

    2e needs to display names of st%dents7 who have not been assigned any stream or have

    been assigned o%rse;name that ends with

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    2/9

    coursena"e l#2e ; 7ename7 dname from emp gro%p by dname?

    1

    =b> onsider the ,able S2)## given below. Write command in MySql for =i> to =v> and o%tp%t

    for =vi> to =vii>.

    ,able S.'$$E:

    Co0e Ite" Co"any =ty C#ty $r#ce

    5@1 Bisc%it 2ide See9 5@@ -elhi 5@.@@

    5@3 8am !issan 55@ !ol9ata 1.@@

    5@5 offee /estle 1@@ !ol9ata .@@

    5@C Sa%ce Maggi C M%mbai .@@5@D a9e Britannia D1 -elhi 5@.@@

    5@0 Maggi /estle 5@ M%mbai 5@.@@5@ hocolate adb%ry 5D@ -ehli 1.@@

    =i> ,o display names of the items whose name starts with ,o print the ,otal F%antity of +tems s%pplied in ach city.

    Select c#ty ? su"(ty)!ro" s4oe 5rou by c#ty/

    5

    =v> ,o print the total amo%nt of money collected from each city in the table

    Select c#ty? su"(r#cety) !ro" s4oe 5rou by c#ty/

    5

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    3/9

    =v+> Select +tem from Shoppe where +tem +/ =8am$7 offee$>?

    ITEM

    ______

    Jam

    Coffee

    5

    =vii> Select M+/ =Fty>7 Avg=#riceGFty> from Shoppe where ityH$M%mbai$?

    56, 2290

    5

    =viii> Select distinct city from Shoppe where price I 1?

    Kolkata

    Mumbai

    5

    3. (a) Write MySql command to create the ,able S,)! incl%ding its onstraints.

    ,able ST'CK:

    Na"e o! Colu"n Tye S#Be Constra#nt

    /ame Jarchar 1@#rimary !ey

    ompany Jarchar 1@#rice -ecimal K /ot /%ll

    Stoc9 +nteger 1 /ot /%ll

    Create table Stoc2

    (

    na"e 6arc4ar(7-)?

    Co"any 6arc4ar(7-) ?

    $r#ce 0ec#"al(?-) not null?

    Stoc2 #nt(7)not null?

    $r#"ary 2ey(na"e?co"any)

    )/

    5

    =b> +n a -atabase there are two tables:

    ,able ITE*:

    ICo0e Ina"e $r#ce

    5@5 ,elevision D@@@

    1@1 omp%ter 01@@@

    3@3 (efrigerator L@@@@

    0@0 Washing Machine 1D@@@

    ,able3&AN:

    ICo0e 3ran0Na"e5@5 Sony

    1@1 2#3@3 *'

    0@0 +6B

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    4/9

    =i> Write MySql q%ery to display +ode7 +/ame and corresponding Brand /ames of those +tems7

    whose #rice is between 1@@@@ and 0@@@ =both val%es incl%sive>.

    Select Ite"+#co0e? #te"+#na"e? bran0+bran0na"e !ro" #te"?bran0 w4ere

    #te"+#co0eDbran0+#co0e an0 #te"+r#ce between 7--- an0 F--/

    5

    (##) Write MySql q%ery to display +ode7 #rice and Brand;/ame7 of the item which has +/ame as

    ,elevision

    Select Ite"+#co0e? #te"+#na"e? bran0+bran0na"e !ro" #te"?bran0 w4ere#te"+#co0eDbran0+#co0e an0 #te"+#na"eDGTele6#s#onG/

    5

    (###) Write a q%ery to print the details of all +tems of *' and +6B brands only

    Select #te"+ ? bran0na"e !ro" #te"? bran0 w4ere #te"+#co0eDbran0+#co0e HH

    bran0na"e #n(;l5>?>#!b>)/

    5

    (###) Write MySql q%ery to increase the price of all +tem by 5 of existing price

    U0ate #te" set r#ceDr#ce((r#ce1F)J1--) /

    'r select r#ce((r#ce1F)J1--) as #ncrease0 $r#ceG !ro" #te"/

    5

    (#6) Write MySql q%ery to create a cross Noin of +,M and B(A/- table.

    Select !ro" #te"? bran0/

    5

    (c) 'iven below is a ,able #atient and -octor

    ,AB* : #A,+/,

    /ame #;/o -ate;Admn -oc;/o

    Jimla 8ain #@@@5 1@55O5@O55 -1@5

    +shita !ohli #@@51 1@55O5@O55 -@C

    JiNay Jerma #5@@1 1@55O5@O5D -1@5

    JiNay Jerma #5CD 1@55O55O11 -133

    ,AB* : -),)(

    -;/o /ame SpecialiPation #;/o-1@5 -r. (avi #ra9ash ardiologist #@@@5

    -@C -r. Alo9 Mittal )rthopedic #@@51

    -1@5 -r. Ar%n !%mar hild Specialist #5@@1

    -133 -r. Ar%na 'ynecologist #5CD

    (#) write Mysql query (s) to delete D_No attribute in doctor table and

    then use Name and Specialization attributes to jointly act asPrimary key or the Doctor !able

    alter table doctor drop primary key"

    alter table doctor add primary key(name# specialization)"

    alter table doctor modiy primary key( specialization)"

    1

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    5/9

    (##) $rite MySql query to Print the Patient Name and their correspondin%

    Doctor name

    Select doctor&name#patient&name rom patient# doctor where

    patient&p_no'doctor&p_no"

    1

    (###) $rite the output produced by the ollowin% queriesa) Select en%th(Mid(*normatics Practices+#, #,,))"

    ,,

    b) Select pow(*nstr(Delhi Public School -haziabad+#My School+)#,)"

    ,

    c) Select .ound (/012&34/ # 53)"

    /166

    d) Select Day(curdate())" 77 assume that query is e8ecuted today

    ,1

    e) Select year(36,3,3,3+)"

    36,3

    ) Select ucase(mid(M9 S:;

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    6/9

    3 col%mns. What will be the cardinality and degree of the res%ltant table if we obtain the

    artesian prod%ct of these two tables&

    e5ree O

    Car0#nal#ty (e) Mr. Sanghi created two tables with +,4 as 6oreign !ey in ,able5 and #rimary !ey in

    ,able1. While inserting a row in ,able57 Mr. Sanghi is not able to enter a val%e in the col%mn

    +,4. What co%ld be the possible reason for it&&e!erent#al #nte5r#ty en!orce"ent ensures t4at 6alue "ust e9#st #n re!erre0 table !or

    success!ul #nsert#on #n t4e 0eart"ent table+

    5

    (!) Mr. 8ana9 is %sing a table with following col%mns :

    /ame7 lass7 o%rse;+d7 o%rse;name

    2e needs to display names of st%dents7 who have not been assigned any stream or have

    been assigned o%rse;name that ends with to do partial rollbac9 in a -atabase . Also state the category of mySql to

    which these F%eries belong to.

    &'LL3ACK T' SAE$'INT NA*E /

    1

    (4) What is

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    7/9

    =b> onsider the ,able S2)## given below. Write command in MySql for =i> to =v> and o%tp%t

    for =vi> to =vii>.

    ,able S.'$$E:

    Co0e Ite" Co"any =ty C#ty $r#ce5@1 Bisc%it 2ide See9 5@@ -elhi 5@.@@

    5@3 8am !issan 55@ !ol9ata 1.@@

    5@5 offee /estle 1@@ !ol9ata .@@5@C Sa%ce Maggi C M%mbai .@@

    5@D a9e Britannia D1 -elhi 5@.@@

    5@0 Maggi /estle 5@ M%mbai 5@.@@

    5@ hocolate adb%ry 5D@ -ehli 1.@@

    =i> ,o display names of the items whose name does not start with

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    8/9

    3. (a) Write MySql command to create the ,able S,)! incl%ding its onstraints.

    ,able ST'CK:

    Na"e o! Colu"n Tye S#Be Constra#nt

    /ame Jarchar 1@#rimary !ey

    ompany Jarchar 1@

    #rice -ecimal K /ot /%llStoc9 +nteger 1 /ot /%ll

    Create table Stoc2

    (

    na"e 6arc4ar(7-)?

    Co"any 6arc4ar(7-) ?

    $r#ce 0ec#"al(?-) not null?

    Stoc2 #nt(7)not null?

    $r#"ary 2ey(na"e?co"any)

    )/

    5

    =b> +n a -atabase there are two tables:

    ,able ITE*:

    ICo0e Ina"e $r#ce

    5@5 ,elevision D@@@

    1@1 omp%ter 01@@@

    3@3 (efrigerator L@@@@

    0@0 Washing Machine 1D@@@

    ,able3&AN:

    ICo0e 3ran0Na"e

    5@5 Sony1@1 2#

    3@3 *'

    0@0 +6B

    =i> Write MySql q%ery to display ++tem -etails and Brand /ames of those +tems7 whose #rice is

    between 1@@@@ and 0@@@ =both val%es incl%sive>.

    Select ITE*+? bran0na"e !ro" #te"?bran0 w4ere #te"+#co0eDbran0+#co0e an0 r#ce

    between 7---- an0 F---/

    5

    (##) Write MySql q%ery to display +ode7 #rice and Brand;/ame7 of the item which does not have+/ame as ,elevision

    Select Ite"+#co0e?r#ce?bran0+bran0na"e !ro" #te"?bran0 w4ere

    #te"+#co0eDbran0+#co0e an0 not #te"+#na"eDGTele6#s#onG/

    5

    (###) Write a q%ery to print the name and price of all +tems of *' and +6B brands only

    Select #te"+r#ce ?bran0na"e !ro" #te"? bran0 w4ere #te"+#co0eDbran0+#co0e HH

    bran0na"e #n(;l5>?>#!b>)/

    5

  • 8/12/2019 UT 1 Class XII Set a and B Answer Key Info

    9/9

    (###) Write MySql q%ery to decrease the price of all +tem by 5@@ of existing price

    U0ate #te" set r#ceDr#ce1F--/

    5

    (#6) Write MySql q%ery to create a cartisian prod%ct of +,M and B(A/- table.

    Select !ro" #te"? bran0/

    5

    (c) 'iven below is a ,able #atient and -octor

    ,AB* : #A,+/,

    /ame #;/o -ate;Admn -oc;/oJimla 8ain #@@@5 1@55O5@O55 -1@5

    +shita !ohli #@@51 1@55O5@O55 -@CJiNay Jerma #5@@1 1@55O5@O5D -1@5

    JiNay Jerma #5CD 1@55O55O11 -133

    ,AB* : -),)(

    -;/o /ame SpecialiPation #;/o

    -1@5 -r. (avi #ra9ash ardiologist #@@@5-@C -r. Alo9 Mittal )rthopedic #@@51

    -1@5 -r. Ar%n !%mar hild Specialist #5@@1

    -133 -r. Ar%na 'ynecologist #5CD

    (#) write Mysql query (s) to modiy primary key constraint which is

    currently applied on D_No attribute in doctor table &ater

    modiication Name and Specialization attributes shall jointly act

    as Primary key or the Doctor !able

    alter table doctor drop primary key"

    alter table doctor add primary key(name#

    1

    (##) $rite MySql query to Print the Patient Name and Name o Doctors

    attendin% these patientsSelect doctor&name#patient&name rom patient# doctor where

    patient&p_no'doctor&p_no"

    1

    (###) $rite the output produced by the ollowin% queries

    %) Select en%th(Mid(*normatics Practices+#,,))"

    ,,

    h) Select pow(*nstr(Delhi Public School -haziabad+#My School+)#6)"

    ,

    i) Select .ound (/012&34/ # 54)"

    0666

    j) Select Dayname(curdate())" 77 assume that query is e8ecuted today

    monday

    k) Select month(36,3,3,3+)"

    ,3

    l) Select lcase(mid(my school id DPS- +#5/))"

    dps%

    Q

    C

    H

    3