DBMS LAB 4 SOLUTION

SQL>create table customer(cust_no number(5) primary key,cust_name varchar2(20));

SQL>desc customer;

Name                                      Null?              Type
……………………………………………………………………………………………………………..
CUST_NO                           NOT NULL          NUMBER(5)
CUST_NAME                                                 VARCHAR2(20)

Valid Test Data:

SQL>insert into customer values(&cust_no,’&cust_name’);
SQL>select * from customer;

CUST_NO           CUST_NAME
……………………………………………………………….
50                                          scott
51                                          pandey
52                                          varshney
53                                          naidu
54                                          bhimbra

SQL>create table membership(mem_no number(5) primary key,cust_no number(5) references customer(cust_no));

SQL>dsec membership;
Name                                      Null?                      Type
………………………………………………………………………………………………………...
MEM_NO                                    NOT NULL          NUMBER(5)
CUST_NO                                                           NUMBER(5)

SQL>insert into memship values(&mem_no,&cust_no);
SQL>select * from memship;

MEM_NO            CUST_NO
…………………………………………………
920                           50
981                           51
897                           52
820                           53    
928                           54
                                                                                                SQL>create table cassette(cass_no number(5) primary key,
Cass_name varchar2(15),language varchar2(15));

SQL>desc cassette;

Name                                      Null?              Type
………………………………………………………………………………………..
CASS_NO                                NOT NULL      NUMBER(5)
CASS_NAME                                                  VARCHAR2(15)
LANGUAGE                                                VARCHAR2(15)

SQL>insert into cassette values(&cass_no,’&cass_name’,’&language’);

SQL>select * from cassette;

CASS_NO      CASS_NAME                     LANGUAGE
………………………………………………………………………………………
1                      tagore                       telugu
2                      the lion king               English
3                      anniyan                     tamil
4                      indra                         telugu
5                      lord of rings                English

SQL>create table issu_rec(iss_no number(5) primary key,iss_date date,mem_no number(5)references memship(mem_no),cass_no number(5) references cassette(cass_no));

SQL>desc issu_rec;
Name                                           Null?                          Type
………………………………………………………………………………………………………...
ISS_NO                                     NOT NULL          NUMBER(5)
ISS_DATE                                                          DATE
MEM_NO                                                            NUMBER(5)
CASS_NO                                                           NUMBER(5)

SQL>select * from issu_rec;

ISS_NO      ISS_DATE       MEM_NO     CASS_NO
……………………………………………………………………………………
22             07-JAN-06          920           1
23             10-JAN-00          981           2
26             10-JAN-06          897           5
3              01-JAN-06          820           4
34             31-DEC-05          928           3

c)   List all the customer names with their membership numbers
SQL>select c.custname,m.memno from customer1 c,membership1 m where c.custno=m.custno;

CUSTNAME    MEMNO
……………….. ………………..
NIKHIL              51
VIVEK                52
SHRAVAN           58
VAMSI               57
SHIVA               56


d)   List all the issues for the current date with the customer names and cassette names

SQL>select i.issno,c.custname,cc.cassettename from customer1 c,membership1 m,cassette  cc,issrec1 I where i.issdate=to_char(sysdate) and c.custno=m.custno and i.cassno=cc.cassno and i.memno=m.memno;

OutPut:

no rows selected.

e)   List the details of the customer who has borrowed the cassette whose title is “ The Legend”
f)    Give a count of how many cassettes have been borrowed by each customer
g)   Give a list of book which has been taken by the student with mem_no as 5
h)   List the cassettes issues for today
i)    Create a view which lists outs the iss_no, iss_date, cust_name, cass_name
j)    Create a view which lists issues-date wise for the last one week


Comments

Post a Comment

Popular posts from this blog

PROCEDURE TO CREATE AN ANIMATION TO REPRESENT THE GROWING MOON.

PROCEDURE TO CREATE AN ANIMATION TO INDICATE A BALL BOUNCING ON STEPS.

PROCEDURE TO CHANGE A CIRCLE INTO A SQURE USING FLASH.