SQL Tables Cbse Boards
SQL Tables Cbse Boards
             (v)    Observe the following table carefully and write the names of the most
                   appropriate columns, which can be considered as (i) candidate keys
                                                                     and (ii) primary key.
                                                                  (CBSE-Outside Delhi 2015)
 (vi)         Observe the following STUDENTS and EVENTS tables carefully and write the
              name of the RDBMS operation which will be used to produce the output as
              shown in LIST. Also, find the Degree and Cardinality of the LIST. (CBSE- Delhi
              2016)
                      STUDENTS                         EVENTS
                      No Name                 EVENTCODE EVENTNAME
                      1   Tara mani            1001     Programming
                      2   Jaya Sarkar          1002     IT Quiz
                      3   Tarini Trikha
                                        LIST
                      NO         NAME EVENTCODE EVENTNAME
                      1  Tara mani    1001     Programming
                      1  Tara mani    1002     IT Quiz
                                                   1
              2   Jaya Sarkar     1001       Programming
              2   Jaya Sarkar     1002       IT Quiz
              3   Tarini Trikha   1001       Programming
              3   Tarini Trikha   1002       IT Quiz
(vii)   Observe the following PARTICIPANTS and EVENTS tables carefully and write the
        name of the RDBMS operation which will be used to produce the output as
        shown in RESULT. Also, find the Degree and Cardinality of the RESULT.
        (CBSE- Outside Delhi 2016)
                                         2
            PARTICIPANTS                            EVENTS
            PNo   Name                   EVENTCODE EVENTNAME
            1     Aruanabha Tariban       1001     IT Quiz
            2     John Fedricks           1002     Group Debate
            3     Kanti Desai
                                      RESULT
            PNO             NAME       EVENTCODE    EVENTNAME
            1     Aruanabha Tariban    1001        IT Quiz
            1     Aruanabha Tariban    1002        Group Debate
            2     John Fedricks        1001        IT Quiz
            2     John Fedricks        1002        Group Debate
            3     Kanti Desai          1001        IT Quiz
            3     Kanti Desai          1002        Group Debate
(iii)   Write SQL commands for the following queries on the basis of Club relation
        given below:
                                          4
               Coach-    CoachNam     Ag       Sports   date_of_ap   Pay    Sex
               ID        e             e                    p
                 1       Kukreja      35     Karate    27/03/1996    1000   M
                 2       Ravina       34     Karate    20/01/1998    1200   F
                 3       Karan        34     Squash    19/02/1998    2000   M
                 4       Tarun        33     Basketbal 01/01/1998    1500   M
                                             l
                 5       Zubin        36     Swimmin 12/01/1998      750    M
                                             g
                 6       Ketaki       36     Swimmin 24/02/1998      800    F
                                             g
                 7       Ankita       39     Squash    20/02/1998    2200 F
                 8       Zareen       37     Karate    22/02/1998    1100 F
                 9       Kush         41     Swimmin 13/01/1998      900 M
                                             g
                10       Shailya      37     Basketbal 19/02/1998    1700 M
                                             l
        a) To show all information about   the swimming coaches in   the club.
        b) To list the names of all coaches with their date of appointment
           (date_of_app) in descending order.
        c) To display a report showing coach name, pay, age, and bonus (15% of
           pay) for all coaches.
        d) To insert a new row in the Club table with ANY relevant data:
        e) Give the output of the following SQL statements:
                 i.   Select COUNT(Distinct Sports) from Club;
                ii.   Select Min(Age) from Club where SEX = “F”;
(iv)   Write SQL commands for (a) to (f) and write the outputs for    (g) on the basis
       of tables FURNITURE and ARRIVALS
                                      FURNITURE
              NO ITEMNAME        TYPE         DATEOFSTO PRICE         DISCOUNT
                                              CK
              1    White lotus   Double Bed 23/02/02       30000      25
              2    Pink feather  Baby cot     20/01/02     7000       20
              3    Dolphin       Baby cot     19/02/02     9500       20
              4    Decent        Office Table 01/01/02     25000      30
              5    Comfort zone  Double Bed 12/01/02       25000      25
              6    Donald        Baby cot     24/02/02     6500       15
              7    Royal Finish  Office Table 20/02/02     18000      30
              8    Royal tiger   Sofa         22/02/02     31000      30
              9    Econo sitting Sofa         13/12/01     9500       25
              10 Eating Paradise Dining Table 19/02/02     11500      25
                                        ARRIVALS
                 NO ITEMNAME       TYPE     DATEOFSTO      PRICE DISCOUN
                                            CK                   T
                 1    Wood         Double   23/03/03       25000 25
                      Comfort      Bed
                 2    Old Fox      Sofa     20/02/03       17000 20
                 3    Micky        Baby cot 21/02/03       7500 15
         a)To show all information about the Baby cots from the FURNITURE table.
         b)To list the ITEMNAME which are priced at more than 15000 from the
           FURNITURE table.
                                           5
c) To list ITEMNAME and TYPE of those items, in which date of stock is before
   22/01/02 from the FURNITURE table in descending of ITEMNAME.
d)To display ITEMNAME and DATEOFSTOCK of those items, in which the
   discount percentage is more than 25 from FURNITURE table.
e)To count the number of items, whose TYPE is "Sofa" from FURNITURE table.
f)    To insert a new row in the ARRIVALS table with the following data:
      14,“Valvet touch”, "Double bed", {25/03/03}, 25000,30
                                6
         g)   Give the output of following SQL stateme
              Note: Outputs of the above mentioned queries should be based on
              original data given in both the tables i.e., without considering the
              insertion done in (f) part of this question.
              (i)     Select COUNT(distinct TYPE) from FURNITURE;
              (ii)    Select MAX(DISCOUNT) from FURNITURE,ARRIVALS;
              (iii)   Select AVG(DISCOUNT) from FURNITURE where TYPE="Baby cot";
              (iv)    Select SUM(Price) from FURNITURE where
                      DATEOFSTOCK<{12/02/02};
(v)    Consider the following tables GAMES and PLAYER. Write SQL commands for the
       statements
       (a) to (d) and give outputs for SQL queries (E1) to (E4)
                                               GAMES
                     GCode GameName Numbe PrizeMone ScheduleDat
                                          r         y           e
                     101     Carom        2         5000        23-Jan-2004
                             Board
                     102     Badminton 2            12000       12-Dec-2003
                     103     Table        4         8000        14-Feb-2004
                             Tennis
                     105     Chess        2         9000        01-Jan-2004
                     108     Lawn Tennis 4          25000       19-Mar-2004
                                              PLAYER
                                    PCode Name          Gcode
                                    1      Nabi         101
                                           Ahmad
                                    2      Ravi Sahai 108
                                    3      Jatin        101
                                    4      Nazneen      103
       (a) To display the name of all Games with their Gcodes
       (b) To display details of those games which are having PrizeMoney more than
           7000.
       (c) To display the content of the GAMES table in ascending order of
           ScheduleDate.
       (d) To display sum of PrizeMoney for each of the Number of participation
              groupings (as shown in column Number)
       (e1) SELECT COUNT(DISTINCT Number) FROM GAMES;
       (e2) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM
       GAMES; (e3) SELECT SUM(PrizeMoney) FROM GAMES;
       (e4) SELECT DISTINCT Gcode FROM PLAYER;
(vi)   Consider the following tables WORKER and PAYLEVEL and answer (a) and (b)
       parts of this question:                                        (CBSE
       2011)
                                           WORKER
          ECOD          NAM         DESIG     PLEVEL      DOJ           DO
          E              E                                               B
          11       Radhey         Superviso P001      13-Sep-2004 23-Aug-1981
                   Shyam          r
          12       Chander Nath Operator P003         22-Feb-2010 12-Jul-1987
          13       Fizza          Operator P003       14-June-    14-Oct-1983
                                                      2009
          15       Ameen Ahmed Mechanic P002          21-Aug-2006 13-Mar-1984
          18       Sanya          Clerk     P002      19-Dec-2005 09-June-
                                        7
                                                                 1983
                                       PAYLEVEL
                         PAYLEVE        PAY     ALLOWAN
                             L                      CE
                           P001        2600       12000
                                         0
                           P002        2200       10000
                                         0
                           P003        1200        6000
                                         0
(a) Write SQL commands for the following statements:
    (i) To display the details of all WORKERs in descending order of DOB.
    (ii) To display NAME and DESIG of those WORKERs whose PLEVEL is
         either P001 or P002.
                                  8
          (iii) To display the content of all the WORKERs table, whose DOB is in
                between ’19- JAN-1984’ and ’18-JAN-1987’.
          (iv) To add a new row with the following:
                       19, ‘Daya kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-1984’
       (b) Give the output of the following SQL queries:
          (i) SELECT COUNT(PLEVEL), PLEVEL FROM WORKER GROUP BY PLEVEL;
          (ii) SELECT MAX(DOB), MIN(DOJ) FROM WORKER;
          (iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P WHERE
                W.PLEVEL=P.PLEVEL AND W.ECODE<13;
          (iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL WHERE
                PLEVEL=’P003’;
(vii) Consider the following tables CABHUB and CUSTOMER and answer (a) and (b)
      parts of this question:                                             (CBSE
      2012)
                                               CABHUB
                  Vcod VehicleNa             Make    Color Capaci Charg
                     e    me                                  ty      es
                   100    Innova          Toyota     WHITE     7      15
                   102    SX4             Suzuki     BLUE      4      14
                   104    C Class         Mercede RED          4      35
                                          s
                   105    A-Star          Suzuki     WHITE     3      14
                   108    Indigo          Tata       SILVE     3      12
                                                     R
                                             CUSTOMER
                                   CCod       CName      VCod
                                      e                    e
                                      1     Hemant        101
                                            Sahu
                                      2     Raj Lal       108
                                      3     Feroza Shah 105
                                      4     Ketan Dhal    104
      (a) Write SQL commands for the following statements:
          1) To display the names of all white colored vehicles
          2) To display name of vehicle, make and capacity of vehicles in ascending
              order of their sitting capacity
          3) To display the highest charges at which a vehicle can be hired from
              CABHUB.
          4) To display the customer name and the corresponding name of the
              vehicle hired by them.
      (b) Give the output of the following SQL queries:
          1) SELECT COUNT(DISTINCT Make) FROM CABHUB;
          2) SELECT MAX(Charges), MIN(Charges) FROM CABHUB;
          3) SELECT COUNT(*), Make FROM CABHUB;
          4) SELECT VehicleName FROM CABHUB WHERE Capacity = 4;
(viii) Write SQL queries for (a) to (f) and write the outputs for the SQL queries
       mentioned shown in (g1) to (g4) parts on the basis of tables ITEMS and
       TRADERS:                                                              (CBSE
       2013)
                                               ITEMS
                COD            INAM           QTY PRIC COMPAN TCOD
                  E              E                   E           Y         E
                1001 DIGITAL PAD 12i          120 1100        XENITA      T01
                                                     0
                1006 LED SCREEN 40            70     3800 SANTORA         T02
                                           9
                                   0
1004   CAR GPS SYSTEM        50    2150    GEOKNOW     T01
                                   0
1003   DIGITAL CAMERA        160   8000    DIGICLICK   T02
       12X
1005   PEN DRIVE 32GB        600   1200    STOREHO     T03
                                              ME
                        TRADERS
           TCod         TName              CITY
             e
            T01   ELECTRONIC              MUMBAI
                  SALES
            T03   BUSY STORE              DELHI
                  CORP
            T02   DISP HOUSE INC          CHENNA
                                          I
                        10
          a) To display the details of all the items in the ascending order of item
              names (i.e. INAME).
          b) To display item name and price of all those items, whose price is in
              range of 10000 and 22000 (both values inclusive).
          c) To display the number of items, which are traded by each trader. The
              expected output of this query should be:
                      T01   2
                      T02   2
                      T03   1
          d) To display the price, item name and quantity (i.e. qty) of those
              items which have quantity more than 150.
          e) To display the names of those traders, who are either from DELHI
              or from MUMBAI.
          f) To display the names of the companies and the names of the items in
              descending order of company names.
         g 1 ) SELECT MAX(PRICE), MIN(PRICE) FROM ITEMS;
         g 2 ) SELECT PRICE*QTY AMOUNT FROM ITEMS WHERE
         CODE-1004; g 3 )      SELECT DISTINCT TCODE FROM ITEMS;
         g 4 ) SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE
                 I.TCODE=T.TCODE AND QTY<100;
(ix)   Answer the (a) and (b) on the basis of the following tables STORE and ITEM:
       (CBSE 2014)
                                              STORE
                            SNo           SNam              AREA
                                            e
                            S01    ABC                   GK II
                                   Computronics
                            S02    All Infotech Media CP
                            S03    Tech Shoppe           Nehru Place
                            S05    Hitech Tech Store SP
                                               ITEM
                             INo         IName        Pric     SNo
                                                       e
                             T01    Mother Board 1200          S01
                                                        0
                             T02    Hard Disk         5000     S01
                             T03    Keyboard          500      S02
                             T04    Mouse             300      S01
                             T05    Mother Board 1300          S02
                                                        0
                             T06    Key Board         400      S03
                             T07    LCD               6000     S04
                             T08    LCD               5500     S05
                             T09    Mouse             350      S05
                             T10    Hard disk         4500     S03
                               12
(x)    Consider the following DEPT and WORKER tables. Write SQL queries for (i) to
       (iv) and find outputs for SQL queries (v) to (viii):       (CBSE-Delhi
       2015)
       Table: DEPT
                         DCOD    DEPARTMENT               CITY
                           E
                          D01    MEDIA                    DELHI
                          D02    MARKETING                DELHI
                          D03    INFRASTRUCTURE           MUMBAI
                          D05    FINANCE                  KOLKATA
                          D04    HUMAN RESOURCE           MUMBAI
       Table: WORKER
               WN            NAME             DOJ           DOB     GENDE     DCOD
               O                                                    R           E
               1001 George K          2013-09-02      1991-09-01    MALE       D01
               1002 Ryma Sen          2012-12-11      1990-12-15    FEMALE     D03
               1003 Mohitesh          2013-02-03      1987-09-04    MALE       D05
               1007 Anil Jha          2014-01-17      1984-10-19    MALE       D04
               1004 Manila Sahai      2012-12-09      1986-11-14    FEMALE     D01
               1005 R SAHAY           2013-11-18      1987-03-31    MALE       D02
               1006 Jaya Priya        2014-06-09      1985-06-23    FEMALE     D05
       Note: DOJ refers to date of joining and DOB refers to date of Birth of
       workers.
             (i) To display Wno, Name, Gender from the table WORKER in descending
                 order of Wno.
            (ii) To display the Name of all the FEMALE workers from the table
                 WORKER.
           (iii) To display the Wno and Name of those workers from the table WORKER
                 who
                 are born between ‘1987-01-01’ and ‘1991-12-01’.
           (iv) To count and display MALE workers who have joined after ‘1986-01-01’.
           (v) SELECT COUNT(*), DCODE FROM WORKER GROUP BY DCODE HAVING
                 COUNT(*)>1;
          (vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
         (vii) SELECT NAME, DEPARTMENT, CITY FROM WORKER W,DEPT D WHERE
                 W.DCODE=D.DCODE AND WNO<1003;
          (viii)SELECT MAX(DOJ), MIN(DOB) FROM WORKER;
(xi)   Consider the following DEPT and EMPLOYEE tables. Write SQL queries for (i) to
       (iv) and find outputs for SQL queries (v) to (viii).       (CBSE-Outside Delhi
       2015) Table: DEPT
                               DCOD DEPARTMENT              LOCATIO
                               E                            N
                               D01    INFRASTRUCTUR DELHI
                                      E
                               D02    MARKETING             DELHI
                               D03    MEDIA                 MUMBAI
                               D05    FINANCE               KOLKATA
                               D04    HUMAN                 MUMBAI
                                      RESOURCE
       Table: EMPLOYEE
                   ENO    NAME         DOJ          DOBGENDE         DCOD
                                                       R             E
                     1001 George K     2013090 1991090 MALE          D01
                                       2       1
                     1002 Ryma Sen     2012121 1990121 FEMALE        D03
                                       1       5
                     1003 Mohitesh     2013020 1987090 MALE          D05
                                         13
                                 3         4
             1007 Anil Jha       2014011   1984101    MALE     D04
                                 7         9
             1004 Manila         2012120   1986111    FEMALE D01
                  Sahai          9         4
             1005 R SAHAY        2013111   1987033    MALE     D02
                                 8         1
             1006 Jaya Priya     2014060   1985062    FEMALE D05
                                 9         3
Note: DOJ refers to date of joining and DOB refers to date of Birth of employees.
  (i)  To display Eno, Name, Gender from the table EMPLOYEE in ascending
       order of Eno.
 (ii)  To display the Name of all the MALE employees from the table EMPLOYEE.
                                  14
        (iii)     To display the Eno and Name of those employees from the table
                  EMPLOYEE who
                  are born between '1987‐01‐01' and '1991‐12‐01'.
        (iv)      To count and display FEMALE employees who have joined after '1986‐01‐
                  01'.
         (v)      SELECT COUNT(*),DCODE FROM EMPLOYEE
                  GROUP BY DCODE HAVING COUNT(*)>1;
        (vi)      SELECT DISTINCT DEPARTMENT FROM DEPT;
       (vii)      SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT
                  D WHERE E.DCODE=D.DCODE AND EN0<1003;
       (viii)     SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;
(xii) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on
      the tables.                                                                    (CBSE- Delhi
      2016)
                                  Table: VEHICLE
                      Code                VTYPE PERKM
                      101 VOLVO BUS                   160
                      102 AC DELUXE BUS 150
                      103 ORDINARY BUS 90
                      105 SUV                         40
                      104 CAR                         20
                  Note:
                         PERKM is Freight Charges per kilometer
                         VTYPE is Vehicle Type
                                                      Table: TRAVEL
                           NO              NAME       TDATE               KM       CODE       NOP
                          101   Janish Kin             2015-11-13         200      101        32
                          103   Vedika sahai           2016-04-21         100      103        45
                          105   Tarun Ram              2016-03-23         350      102        42
                          102   John Fen               2016-02-13          90      102        40
                          107   Ahmed Khan             2015-01-10          75      104        2
                          104   Raveena                2015-05-28          80      105        4
                          106   Kripal Anya            2016-02-06         200      101        25
            Note :
                     NO is Traveller Number
                     KM is Kilometer travelled
                     NOP is number of travellers travelled in vehicle
                     TDATE is Travel Date
             (i)       To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.
            (ii)       To display the NAME of all the travellers from the table TRAVEL who are
                       travelling by vehicle with code 101 or 102.
          (iii)        To display the NO and NAME of those travellers from the table TRAVEL
                       who travelled between ‘2015-12-31’ and ‘2015-04-01’.
            (iv)       To display all the details from table TRAVEL for the travellers, who have
                       travelled distance more than 100 KM in ascending order of NOP.
                (v)    SELECT COUNT (*), CODE FROM TRAVEL GROUP BY CODE HAVING
                       COUNT(*)>1;
           (vi)        SELECT DISTINCT CODE FROM TRAVEL;
          (vii)        SELECT A.CODE,NAME,VTYPE FROM TRAVEL A,VEHICLE B WHERE
                       A.CODE=B.CODE AND KM<90;
         (viii)        SELECT NAME,KM*PERKM FROM TRAVEL A, VEHICLE B WHERE
                       A.CODE=B.CODE AND A.CODE=‘105’;
                                                   15
(xiii) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on
       the tables.                                                        (CBSE- Outside Delhi
       2016)
                                                Table: VEHICLE
                                   VCODE           VEHICLETYPE PERKM
                                   V01       VOLVO BUS         150
                                   V02       AC DELUXE BUS     125
                                   V03       ORDINARY BUS      80
                                   V05       SUV               30
                                   V04       CAR               18
                 Note:
                         PERKM is Freight Charges per kilometer
                                                      Table: TRAVEL
                          CNO              CNAME       TRAVELDATE         KM      VCODE       NOP
                          101    K.Niwal               2015-12-13         200     V01         32
                          103    Fredrick Sym          2016-03-21         120     V03         45
                          105    Hitesh Jain           2016-04-23         450     V02         42
                          102    Ravi anish            2016-01-13          80     V02         40
                          107    John Malina           2015-02-10          65     V04         2
                          104    Sahanubhuti           2016-01-28          90     V05         4
                          106    Ramesh jaya           2016-04-06         100     V01         25
            Note :
                     KM is Kilometer travelled
                     NOP is number of travellers travelled in vehicle
                     TDATE is Travel Date
              (i)      To display CNO, CNAME, TRAVELDATE from the table TRAVEL in
                       descending order of CNO.
               (ii)    To display the CNAME of all the customers from the table TRAVEL who are
                       travelling by vehicle with code V01 or V02.
              (iii)    To display the CNO and CNAME of those customers from the table TRAVEL who
                       travelled between ‘2015-12-31’ and ‘2015-05-01’.
              (iv)     To display all the details from table TRAVEL for the customers, who have travelled
                       distance more than 120 KM in ascending order of NOP.
               (v)     SELECT COUNT (*), VCODE FROM TRAVEL GROUP BY V CODE
                       HAVING COUNT(*)>1;
               (vi)    SELECT DISTINCT VCODE FROM TRAVEL;
              (vii)    SELECT A.VCODE,CNAME,VEHICLETYPE FROM TRAVEL A,VEHICLE B
                       WHERE A.VCODE=B.VCODE AND KM<90;
             (viii)    SELECT CNAME,KM*PERKM FROM TRAVEL A, VEHICLE B WHERE
                       A.VCODE=B.VCODE AND A.VCODE=‘V05’;
16