Sie sind auf Seite 1von 10

w-11 q.

consider the following global fragmentation and allocation schema Global schema STUDENT(STUDNO,NAME,DEPT) Fragmentation schema : STUDENT1 = SL DEPT = CSE STUDENT STUDENT2 = SL DEPT = IT STUDENT Allocation schema : STUDENT1 at sites 1,3 STUDENT2 at sites 2,4. (assume that CSE and IT are only possible values of dept) Write an application that requires the student from the terminal and outputs the name and the department at level 1,2 and 3 of transparency. (8m) Write an application that moves a student whose number and department is given at terminal to other department at level 2 of transparency. (5m) ANS: 1> Application that requires the student number from the terminal and outputs the name and the department at level 1,2 and 3 of transparency. Soln: At level 1. Read(terminal, $STUDNO); Select NAME,DEPT into $NAME,$DEPT from STUDENT where STUDNO = $STUDNO; Write (terminal, $NAME, $DEPT). At level 2 Read (terminal, $STUDNO); Select NAME,DEPT into $NAME, $DEPT from STUDENT1 where STUDNO = $STUDNO; If not #FOUND then Select NAME, DEPT into $NAME, $DEPT from STUDENT2 where STUDNO = $STUDNO;

Write(terminal, $NAME,$DEPT).

At level 3 Read(terminal, $STUDNO); Select NAME, DEPT into $NAME, $DEPT from STUDENT1 AT SITE 1 where STUDNO = $STUDNO; Select NAME,DEPT into $NAME, $DEPT from STUDENT1 AT SITE 3 where STUDNO = $STUDNO; If not #FOUND then Select NAME, DEPT into $NAME, $DEPT from STUDENT2 AT SITE 2 where STUDNO = $STUDNO; Select NAME, DEPT into $NAME, $DEPT from STUDENT2 AT SITE 4 where STUDNO = $STUDNO; Write(terminal, $NAME, $DEPT). 2> Application that moves a student whose number and department is given at the terminal to other department at level 2 of transparency. Soln: At level 2 Read(terminal, $STUDNO, $DEPT); Select NAME into $NAME from STUDENT1 where STUDNO = $STUDNO AND DEPT = $DEPT; Insert into STUDENT2 (STUDNO,NAME,DEPT) ($STUDNO,$NAME,$DEPT); Delete STUDENT1 where STUDNO = $STUDNO; If not #FOUND then Select NAME into $NAME from STUDENT2 where STUDNO = $STUDNO AND DEPT = $DEPT; Insert into STUDENT1 (STUDNO,NAME,DEPT) ($STUDNO,$NAME,$DEPT); Delete STUDENT2 where STUDNO = $STUDNO;

PUT RGCOER Global schema Patient ( PNo, Name, Ward) Fragmentation Schema Patient1 = SL Ward = Gen Patient Patient2 = SL Ward = Special Patient Allocation schema Patient1 at sites 1,3 Patient2 at sites 2,4 1> Write an application that takes patient number from terminal & outputs name & ward at level 1,2 and 3 of transparency. [4] 2> Write an application that moves patient whose number & ward is given at terminal to other ward at level 2 of transparency. [2] 3> Write an application that moves patient having no 101 from ward general to special at level 1,2 and 3 of transparency. [5] ANS: 1> Application that takes patient number from terminal & outputs name and ward at level 1, 2 and 3 of transparency. Soln: At level 1 Read(terminal, $PNo); Select Name, Ward into $Name, $Ward from Patient where PNo = $PNo; Write(terminal, $Name, $Ward). At level 2 Read(terminal, $PNo); Select Name, Ward into $Name, $Ward from Patient1 where PNo = $PNo; If not #FOUND then Select Name, Ward into $Name, $Ward from Patient2 where PNo = $PNo;

Write(terminal, $Name, $Ward). At level 3 Read(terminal, $PNo); Select Name, Ward into $Name, $Ward from Patient1 AT SITE 1 where PNo = $PNo; Select Name, Ward into $Name, $Ward from Patient1 AT SITE 3 where PNo = $PNo; If not #FOUND then Select Name, Ward into $Name, $Ward from Patient2 AT SITE 2 where PNo = $PNo; Select Name, Ward into $Name, $Ward from Patient2 AT SITE 4 where PNo = $PNo; Write(terminal, $Name, $Ward). 2> Application that moves patient whose number and ward is given at terminal to other ward at level 2 of transparency. Soln: At level 2 Read(terminal, $PNo, $Ward); Select Name into $Name from Patient1 where PNo = $PNo AND Ward = $Ward; Insert into Patient2 (PNo, Name, Ward) ($PNo, $Name, $Ward); Delete Patient1 where PNo = $PNo; If not #FOUND then Select Name into $Name from Patient2 where PNo = $PNo AND Ward = $Ward; Insert into Patient1 (PNo, Name, Ward) ($PNo, $Name, $Ward); Delete Patient2 where PNo = $PNo;

3> Application that moves patient having number 101 from ward general to special at level 1,2, and 3 of transparency. At level 1 Update Patient set Ward = Special where PNo = 101 and Ward = Gen; At level 2 Select Name into $Name from Patient1 where PNo = 101 AND Ward = Gen; Insert into Patient2 (PNo, Name, Ward) (101, $Name, Special); Delete Patient1 where PNo = 101; At level 3 Select Name into $Name from Patient1 at site 1 where PNo = 101 AND Ward = Gen; Select Name into $Name from Patient1 at site 3 where PNo = 101 AND Ward = Gen; Insert into Patient2 (PNo, Name, Ward) at site 2: (101, $Name, Special); Insert into Patient2 (PNo, Name, Ward) at site 4: (101,$Name,Special); Delete Patient1 at site 1 where PNo = 101; Delete Patient1 at site 3 where PNo = 101;

Pg no 64 ceri q. 3.2 Consider the global , fragmentation, and allocation schema Global schema: STUDENT (NUMBER, NAME, DEPT) Fragmentation schema: STUDENT1 = SL DEPT= EE STUDENT STUDENT2 = SL DEPT = CS STUDENT Allocation schema : STUDENT1 at sites 1,2 STUDENT2 at sites 3,4. (assume that EE and CS are the only possible value for dept). a) Write an application that requires that student number from the terminal and outputs the name and department at levels 1,2 and 3 of transparency. b) Write an application that moves the student having number 232 from department EE to department CS at levels 1,2 and 3 of transparency. c) Write an application that moves a student whose number and department is given at terminal to the other department at level 2 of transparency.

d) Consider the case in which application 1 is repeated for many possible value of the student number write the application Accessing the database for each student number given at the terminal Accessing the database after having collected several inputs from the terminal Accessing the database before collecting inputs from the terminal. a) Application that requires that student number from the terminal and outputs name and department at levels 1 ,2 ,3 of transparency. At level 1 Read(terminal, $NUMBER); Select NAME, DEPT into $NAME, $DEPT from STUDENT where NUMBER = $NUMBER; Write(terminal, $NAME, $DEPT). At level 2 Read(terminal, $NUMBER); Select NAME, DEPT into $NAME, $DEPT from STUDENT1 where NUMBER = $NUMBER; If not #FOUND then Select NAME, DEPT into $NAME, $DEPT from STUDENT2 where NUMBER = $NUMBER; Write(terminal, $NAME, $DEPT). At level 3 Read(terminal, $NUMBER); Select NAME, DEPT into $NAME, $DEPT from STUDENT1 AT SITE 1 where NUMBER = $NUMBER; Select NAME, DEPT into $NAME, $DEPT from STUDENT1 AT SITE 2 where NUMBER = $NUMBER; If not #FOUND then

Select NAME, DEPT into $NAME, $DEPT from STUDENT2 AT SITE 3 where NUMBER = $NUMBER; Select NAME, DEPT into $NAME, $DEPT from STUDENT2 AT SITE 4 where NUMBER = $NUMBER; Write(terminal, $NAME, $DEPT). b> application that moves student having number 232 from department EE to department CS at levels 1,2,3 of transparency. At level 1 Update STUDENT set DEPT = CS where NUMBER = 232 AND DEPT = EE; At level 2 Select NAME into $NAME from STUDENT1 where NUMBER = 232 AND DEPT = EE; Insert into STUDENT2 (NUMBER, NAME, DEPT) (232, $NAME, CS); Delete STUDENT1 where NUMBER = 232; At level 3 Select NAME into $NAME from STUDENT1 at site 1 where NUMBER = 232 AND DEPT = EE; Select NAME into $NAME from STUDENT1 at site 2 where NUMBER = 232 AND DEPT = EE; Insert into STUDENT2 (NUMBER, NAME, DEPT) at site 3 : (232, $NAME, CS); Insert into STUDENT2 (NUMBER , NAME, DEPT) at site 4: (232, $NAME, CS); Delete STUDENT1 at site 1 where NUMBER = 232; Delete STUDENT1 at site 2 where NUMBER = 232;

c> application that moves a student whose number and department is given at terminal to other department at level 2 of transparency. At level 2 Read(terminal, $NUMBER, $DEPT); Select NAME into $NAME from STUDENT1 where NUMBER = $NUMBER AND DEPT = $DEPT; Insert into STUDENT2 (NUMBER, NAME, DEPT) ($NUMBER, $NAME, $DEPT); Delete STUDENT1 where NUMBER = $NUMBER; If not #FOUND then Select NAME into $NAME from STUDENT2 where NUMBER = $NUMBER AND DEPT = $DEPT; Insert into STUDENT1 (NUMBER, NAME, DEPT) ($NUMBER, $NAME, $DEPT); Delete STUDENT2 where NUMBER = $NUMBER;

d> the case in which application 1 is repeated for many possible of the student number. Write the application Accessing the database for each student number given at terminal. Repeat Read(terminal, $NUMBER); Select NAME, DEPT into $SNUM_REL($NUMBER, $DEPT) from STUDENT where NUMBER = $NUMBER; Repeat Read($SNUM_REL,$NAME,$DEPT); Write (terminal, $NAME, $DEPT). until END-OF-$SNUM_REL until END-OF-TERMINAL-INPUT. Accessing database after having collected several inputs from the terminal. Repeat Read(terminal, $NUMBER); Write ($SNUM_REL ($NUMBER),$NUMBER). until END-OF-TERMINAL-INPUT; Select NAME,DEPT into $NUM_REL($NAME,$DEPT) from STUDENT , $SNUM_REL where STUDENT.NUMBER = $SNUM_REL.NUMBER; Repeat Read($NUM_REL, $NAME, $DEPT); Write(terminal, $NAME, $DEPT).

until END-OF-NUM_REL. Accessing database before collecting input from the terminal Sessional q. 5 Global schema: Emp(Empno, Name, Dept) Fragmentation schema: Emp1 = SL Dept = MECH Student Emp2 = SL Dept = CIVIL Student Allocation schema: Emp1 at sites 1,3 Emp2 at sites 2,4. 1. Write an application that requires EMP number from terminal and outputs name and department at level 1,2 and 3 of transparency.[7]. 2. Write an application that moves EMP whose number and department is given at terminal to other number at level 2 of transparency. [3]. ANS: 1. Application that requires EMP number from terminal and output name and department at level 1, 2, 3 of transparency. At level 1 Read(terminal, $Empno); Select Name, Dept into $Name, $Dept From Emp Where Empno = $Empno; Write(terminal, $Name, $Dept). At level 2 Read(terminal, $Empno); Select Name, Dept into $Name, $Dept From Emp1 Where Empno = $Empno; If not #FOUND then Select Name, Dept into $Name, $Dept From Emp2 Where Empno = $Empno;

Write(terminal, $Name, $Dept). At level 3 Read(terminal, $Empno); Select Name, Dept into $Name, $Dept From Emp1 AT SITE 1 Where Empno = $Empno; Select Name, Dept into $Name, $Dept From Emp1 AT SITE 3 Where Empno = $Empno; If not #FOUND then Select Name, Dept into $Name, $Dept From Emp2 AT SITE 2 Where Empno = $Empno; Select Name, Dept into $Name, $Dept From Emp2 AT SITE 4 Where Empno = $Empno; 2. Application that moves emp whose number and department is given at terminal to other department at level 2 of transparency. At level 2 Read(terminal, $Empno, $Dept); Select Name into $Name From Emp1 Where Empno = $Empno AND Dept = $Dept; Insert into Emp2 (Empno, Name, Dept) ($Empno, $Name, $Dept); Delete Emp1 where Empno = $Empno; If not #FOUND then Select Name into $Name From Emp2 Where Empno = $Empno AND Dept = $Dept; Insert into Emp1 (Empno, Name, Dept) ($Empno, $Name, $Dept); Delete Emp2 where Empno = $Empno;

Das könnte Ihnen auch gefallen