0% found this document useful (0 votes)
45 views

Queries For Creating Tables For College Database

This document outlines the entity relationship (ER) diagram and SQL queries to create tables for a college database. It includes tables for classes, students, subjects, and lecturers with attributes like IDs, names, addresses and foreign key relationships. Sample data is inserted into each table and the outputs are displayed. Queries use features like primary keys, foreign keys and joining related data between tables.

Uploaded by

sathwick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Queries For Creating Tables For College Database

This document outlines the entity relationship (ER) diagram and SQL queries to create tables for a college database. It includes tables for classes, students, subjects, and lecturers with attributes like IDs, names, addresses and foreign key relationships. Sample data is inserted into each table and the outputs are displayed. Queries use features like primary keys, foreign keys and joining related data between tables.

Uploaded by

sathwick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

CONTENTS

ER diagram of college database


Queries for creating tables of college database
Class Table
Student Table
Subject Table
Lecturer Table

ER diagram of college database:-

Queries for creating tables of college database


Class
Class_id

description

Student
Student_name

Student_id

Address

Class_identi

Subjects
Class_iden

Subject_id

Subject_name

Lecturer
Lecturer_id

Lecturer_name

Class_ident

Subject_ide

Creating Class table:create table class100(


class_id number,
description varchar(20),
primary key(class_id));

inserting the values for class table:insert into class100 values(10,'eight_standard');


insert into class100 values(13,'ninth_standard');
insert into class100 values(45,'tenth_standard');
insert into class100 values(67,'eight_standard');
insert into class100 values(75,'tenth_standard');

output:-

CLASS_ID
---------

DESCRIPTION
--- -------------

10

eight_standard

13

ninth_standard

45

tenth_standard

67

eight_standard

75

tenth_standard

Creating student table:create table student101(


student_name varchar(10),
student_id number,
address varchar(40),
class_identi number,
primary key(student_name),
foreign key(class_identi)references class100(class_id));

Inserting the values for student table:insert into student101 values('Dighanth',17,'#290,2nd cross,Kuvempunagar,Mysore',10);
insert into student101 values('Ashok',5,'#109,Vijayanagar,Bangalore',13);
insert into student101 values('Ravi',20,'#533,Bogadhi,Mysore',45);
insert into student101 values('Nishanth',21,'#57,Moodalapalya,Bangalore',67);
insert into student101 values('Shreyas',34,'#45,Vidyaranyapuram,Mysore',75);

output:STUDENT_NA

STUDENT_ID

---------- -------

---------

Dighanth

17

Ashok

ADDRESS

CLASS_IDENTI

- ------- ---------------------------------------- -----------#290,2nd cross,Kuvempunagar,Mysore


#109,Vijayanagar,Bangalore

10
13

Ravi

20

#533,Bogadhi,Mysore

Nishanth

21

#57,Moodalapalya,Bangalore

Shreyas

34

#45,Vidyaranyapuram,Mysore

Creating subjects table:create table subjects100(


class_iden number,
subject_id number,
subject_name varchar(10),
primary key(subject_id),
foreign key(class_iden)references class100(class_id));

Inserting the values for subjects table:insert into subjects100 values(10,1531,'social');


insert into subjects100 values(13,1532,'science');
insert into subjects100 values(45,1538,'maths');
insert into subjects100 values(67,1539,'english');
insert into subjects100 values(75,1540,'kannada'

Output:CLASS_IDEN
----------

SUBJECT_ID
---------

SUBJECT_NA
---- -----------

10

1531

social

13

1532

science

45

1538

maths

67

1539

english

45
67
75

75

1540

kannada

Creating lecturer table:-

create table lecturer102(


lecturer_id number,
lecturer_name varchar(10),
class_ident number,
subject_ide number,
primary key(lecturer_id),
foreign key(subject_ide)references subjects100(subject_id));

Inserting the values for lecturer table:insert into lecturer102 values(12,'Shobha',10,1531);


insert into lecturer102 values(15,'Rakesh',13,1532);
insert into lecturer102 values(19,'Kumar',45,1538);
insert into lecturer102 values(21,'Suresh',67,1539);
insert into lecturer102 values(25,'Geetha',75,1540);

Output:LECTURER_ID
-----------

LECTURER_N

CLASS_IDENT

SUBJECT_IDE

---------- ---

--------

-----------

12

Shobha

10

1531

15

Rakesh

13

1532

19

Kumar

45

1538

21

Suresh

67

1539

25

Geetha

75

1540

You might also like