Docsity

SQL Database Creation and Table Manipulation Guide, Schemes and Mind Maps of Computer science

Toggle sidebar
bg1
LOYOLA ACADEMY
DEGREE & PG COLLEGE
OLD ALWAL, SECUNDERABAD - 500 010,
TELANGANA, INDIA
An Autonomous Institution Affiliated to Osmania
University
Re-accredited with ‘A’ Grade (III Cycle) by NAAC
A “College with Potential for Excellence” by UGC
Practical Record
CERTIFICATE
This is to certify that this is a Bonafide record work done in ______________________
practical during __________year ________semester of the academic year 202__-202_.
Name:
UID No:
Class:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download SQL Database Creation and Table Manipulation Guide and more Schemes and Mind Maps Computer science in PDF only on Docsity!

LOYOLA ACADEMY DEGREE & PG COLLEGE OLD ALWAL, SECUNDERABAD - 500 010, TELANGANA, INDIA An Autonomous Institution Affiliated to Osmania University Re-accredited with ‘A’ Grade (III Cycle) by NAAC A “College with Potential for Excellence” by UGC Practical Record

CERTIFICATE

This is to certify that this is a Bonafide record work done in ______________________ practical during __________year ________semester of the academic year 202__-202_. Name: UID No: Class:

Signature of Internal Signature of the External Principal

INDEX

**S.No Experiment Name Date Signature

9.**

COLLEGE DATABASE

SPECIFICATION

  1. A college has many departments.
  2. Each department can offer many number of courses.
  3. Many lecturers can work in a department.
  4. A lecturer can work in only one department.
  5. For each department there is a head.
  6. A lecturer can be head of only one department.
  7. Each lecturer can be head of only one department.
  8. A course can be taken by only one lecturer.
  9. A student can enroll for any number of courses. 10.Each course can have any number of students.

ER DIAGRAM

DEPARTMENT DID DNAME (^) PLACE OFFERS HEAD BY COURSES LECTURER TAUGH T BY HAS ENROLL ED BY STUDENT CID CNAME DURATION FEE ROLLNO PHNO LNAME ADDRESS FNAME ADDRESS PHNO FNAME LNAME LECID 1

1 1 1 1

Creation of tables using SQL SQL> create table department(did int primary key,dname varchar(50),place varchar(50)); Table created. SQL> create table lecturer(lecid int primary key,fname varchar(50),lname varchar(50),phno varchar(50),address varchar(100),did int,foreign key(did) references department(did)); Table created. SQL> create table course(cid int primary key,cname varchar(50),duration int,fee decimal(10,2),did int,lecid int,foreign key(did) references department(did),foreign key(lecid) references lecturer(lecid)); Table created. SQL> drop table student; Table dropped. SQL> create table student(rollno int primary key,Fname varchar(50),Lname varchar(50),Address varchar(100),Phno varchar(15)); Table created. SQL> create table enrolment (rollno int, cid int,primary key(rollno,cid),foreign key(rollno) references student(rollno),foreign key(cid)references course (cid)); Table created.

Insertion of values into a table Insertion of values into tables-department SQL> insert into department values(1,'bcca','hyd'); 1 row created. SQL> insert into department values(2,'ifs','hyd'); 1 row created. SQL> insert into department values(3,'iaf','hyd'); 1 row created. SQL> insert into department values(4,'bpm','hyd'); 1 row created. SQL> insert into department values(5,'sf','hyd'); 1 row created. SQL> insert into department values(6,'bs','hyd'); 1 row created. SQL> insert into department values(7,'ba','hyd'); 1 row created. SQL> insert into department values(8,'ft','hyd'); 1 row created.

5 sf hyd 6 bs hyd DID DNAME


PLACE

7 ba hyd 8 ft hyd 8 rows selected. Insertion of values into tables-lecturer

SQL> insert into lecturer values(1,'tom','pat','hyd',1234567890,1); 1 row created. SQL> insert into lecturer values(2,'tim','pat','hyd',1235567890,2); 1 row created. SQL> insert into lecturer values(3,'tum','pat','hyd',1235597890,3); 1 row created. SQL> insert into lecturer values(4,'tem','pat','hyd',1235587890,4); 1 row created. SQL> insert into lecturer values(5,'tym','pat','hyd',1235587860,5); 1 row created. SQL> insert into lecturer values(6,'tam','pat','hyd',1245587860,6); 1 row created. SQL> insert into lecturer values(7,'trm','pat','hyd',1245587260,7); 1 row created. SQL> insert into lecturer values(8,'tlm','pat','hyd',9245587260,8); 1 row created. SQL> select * from lecturer;

2 tim pat hyd 1235567890 2 LECID FNAME


LNAME PHNO


ADDRESS

DID

3 tum pat hyd 1235597890 3 LECID FNAME

LNAME PHNO

ADDRESS

DID

4 tem pat hyd 1235587890 4 LECID FNAME


LNAME PHNO


ADDRESS

DID

5 tym

ADDRESS

DID

7 trm pat hyd 1245587260 7 LECID FNAME


LNAME PHNO


ADDRESS

DID

8 tlm pat hyd 9245587260

8 rows selected. Insertion of values into tables-course SQL> insert into course values(1,'computers',3,80000,1,1); 1 row created. SQL> insert into course values(2,'info sys',3,80000,2,2); 1 row created. SQL> insert into course values(3,'international',3,80000,3,3); 1 row created. SQL> insert into course values(4,'business p',3,80000,4,4); 1 row created. SQL> insert into course values(5,'strategic',3,80000,5,5); 1 row created. SQL> insert into course values(6,'b studies',3,80000,6,6); 1 row created. SQL> insert into course values(7,'analytics',3,80000,7,7); 1 row created. SQL> insert into course values(8,'fintech',3,80000,8,8); 1 row created.

5 strategic 3 80000 5 5 6 b studies 3 80000 6 6 CID CNAME DURATION


FEE DID LECID


7 analytics 3 80000 7 7 8 fintech 3 80000 8 8 8 rows selected.

Insertion of values into tables-student SQL> insert into student values(1,'pat','tom','hyd',1234567890); 1 row created. SQL> insert into student values(2,'pit','tom','hyd',1834567890); 1 row created. SQL> insert into student values(3,'pot','tom','hyd',1839567890); 1 row created. SQL> insert into student values(4,'put','tom','hyd',1830567890); 1 row created. SQL> insert into student values(5,'pkt','tom','hyd',1830667890); 1 row created. SQL> insert into student values(6,'pet','tom','hyd',1830667890); 1 row created. SQL> insert into student values(7,'pvt','tom','hyd',1830667490); 1 row created. SQL> insert into student values(8,'pmt','tom','hyd',1832667490); 1 row created.