Sunteți pe pagina 1din 16

Assignment 2: To convert ER diagram to relational schema

Solution:
The relational schema for the given ER Diagram is:
AUTHOR TABLE:
NAME

BOOK TABLE:
ISBN

ADDRESS

TITLE

PRICE

YEAR

PUBLISHER TABLE:
EmAIL
NAME

ADDRESS

WAREHOUSE TABLE:
CODE
PHONE

TELEPHONE#

ADDRESS

Assignment 3: Normalization
Objective: To determine the highest Normal Form
Problem Description:
Let us find out the Primary Key and highest normal form for this relation:
R{a,b,c,d,e,} a,e c, d e, a,eb, a,ed

Solution:
Step 1:
Determining primary key: From above stated functional dependencies, it
is evident that a,e determines c and d . d determines e and hence a,e
determines all the non-key attributes (b,c,d) of the relation. Thus a,e is
the primary key for relation R.
Step 2:
Highest normal form: All the attributes are atomic in nature therefore
Relation R is in 1NF.

All non-key attributes (b, c, d) are fully functionally dependent on the


primary key (a, e). Therefore the relation in is 2NF.
All the non-key attributes (b, c, d) are non-transitively depending on
primary key (a,e). Therefore the relation is in 3NF.
Assignment 6: Normalization
Objective: To determine the highest Normal Form
Problem Description:
Find the primary key and the highest normal form of following relations
a. R{a,b,c} a,bc and ca
b. R{a,b,c,d} ab, ad and bc
c. R{a,b,c,d,e} a,bc, a,bd and de
Assignment 4: Normalization
Objective: Normalize the given relation to 3NF.
Problem Description:
Convert following table to 3NF table. Please add appropriate columns in
normalized tables to make 3NF compliant.
Note: Consider address column as simple attribute
Student Studen
Id
t
Name
1001
Lawren
ce
1002
Jagan
1003
Bobby
1004
Ramse
y
1005
Chang
Hu
Solution:

Address

Cour
se Id

Course
Name

Date Of
Exam

Mark Grade
s

21, Lion Blvd,


St Peter
29, Tiger Blvd,
Burbank
213,Parliament
Blvd, Petas
401,Gazipura
Blvd,Gulbarga
101,Marshal
Blvd,Kingston

101

CHSSC

06-Mar-08

83

102

PF

15-Mar-08

72

103

RDBMS 22-Mar-08

89

104

UNIX

02-Apr-08

63

105

IWT

10-Apr-08

95

Step1:
The given form is already in the first normal form as all the elements are
in atomic order.
Step2:
Student Id

Student
Name

1001
1002
1003
1004
1005

Lawrence
Jagan
Bobby
Ramsey
Chang Hu

Course Id

21, Lion Blvd,


St Peter
29, Tiger Blvd, Burbank
213,Parliament Blvd, Petas
401,Gazipura Blvd,Gulbarga
101,Marshal Blvd,Kingston
Course
Name
CHSSC
PF
RDBMS
UNIX
IWT

101
102
103
104
105
Student ID
1001
1002
1003
1004
1005

Address

Course Id
101
102
103
104
105

Dateof exam
06-Mar-08
15-Mar-08
22-Mar-08
02-Apr-08
10-Apr-08

Marks
83
72
89
63
95

Grade
A
B
A
C
A

Hence the given form is now in third normal form after removing all the
partial dependencies.
Assignment 5 : Sql Queries
Objective: To create tables with appropriate constraints and to insert
data

Problem Description: Create the following tables with appropriate


constraints and insert the given sample data.

Applicant Table
Column name Data type

Description
Unique Id generated for an
applicant when he or she
applies for admission in the
ApplicantId
Varchar2(4) college.
ApplicantName Varchar2(30) Name of the applicant
EmailId
Address
City

Varchar2(30) email Id of the applicant


Varchar2(50) Complete address of Applicant
Varchar2(15)

Constraints

Primary Key
Not null
Should be
Unique

Branch Table
Column name Data type
BranchId
BranchName

Description

Unique Id generated for a


Varchar2(2) branch
Varchar2(30) Name of the branch

Constraints
Primary Key,
Should start
with B
Not Null

Course Table
Column name
CourseId
CourseName
Semester
BranchId
Elective

Data type
Description
Varchar2(4) Unique Id given to each course
varchar2(30) Name of the course
Name of the semester in which
Number(1)
the course is taught
Id of the branch where the
Varchar2(2) course is taught
char(1)

Whether it is elective paper or


not

Constraints
Primary Key
Not Null

Foreign key
Branch Tabl
Its value can
be 'Y' or 'N'
only

ProjectMarks

Number(3)

AssignmentMarks

Number(3)

InternalMarks

Number(3)

SemesterExamMarks Number(3)

Marks of the project in the


course (if any)
Assignment Marks for the
course (if any)
Internal Marks for the course (if
any)
Marks of the semester exam of
the course

Student Table
Column name

Description
Unique id generated for each
student when he or she gets
Varchar2(4) admitted in to the college
Applicant Id when the student
applied for the admission in the
Varchar2(4) college
Semester in which the student
number(1)
is currently studying
Decided at the time of selection
Varchar2(15) in the college
Decided at the time of selection
Varchar2(15) in the college

Constraints

Column name

Data type

StudentId

Varchar2(4)

CourseId

Varchar2(4)

Constraints
Foreign key to
Student table
Foreign key to
Course table

DateOfExam

Date

StudentId
ApplicantId
CurrentSemester
UserId
Password

Data type

Primary Key
Foreign key to
Applicant table
It should be
unique
Not Null

Registration Table

ProjectMarks
Number(3)
AssignmentMarks Number(3)

Description
Student Id of the student who
has taken up the course
Course Id of the course in which
the student has appeared
Date on which the semester
exam was conducted
Marks obtained by student in
the project of the course (if any)
Assignment Marks obtained by
the student for the course (if

InternalMarks

Number(3)

SemesterMarks

Number(3)

Grade

Char(1)

any)
Internal Marks obtained by the
student for the course (if any)
Marks of the semester exam
obtained by the student for the
course
Over all grade of the student in
the course

Department Table
Column name

Data type

Description
Unique Id generated for Each
DepartmentId
Number(2)
Department
DepartmentName
Varchar2(30) Name of the Department
Id of Instructor who is
HeadOfDepartment Varchar2(4) managing the department

Constraints
Primary Key
Not Null

Instructor Table
Column name

Data type

Description

Constraints
Primary Key,
Should start
with I
Not Null

Unique Id generated for


InstructorId
Varchar2(4) Instructors
InstructorName Varchar2(30) Name of the instructor
Date when instructor joins the
DateOfJoining Date
department
Department id of the
department where Instructor
DepartmentId
Number(2)
works

Course Allocation Table


Column name Data type
AllocationId
CourseId
InstructorId

StartDate

EndDate

Description
Unique Id generated whenever
ever a course is allocated to a
Number(4) instructor
Course id of the course for
Varchar2(4) which allocation is done
Instructor Id of the instructor
who has been allocated the
Varchar2(4) course
Start date when a course is
taken up by the instructor( A
course can be allocated to the
instructor in the middle of the
Date
semester also)
Date till which the course is
allocated to the instructor( the
instructor can be de allocated
from the course in the middle of
Date
the semester)

Foreign key to
Department
table

Constraints
Primary key
Foreign key to
Course table
Foreign key to
Instructor table

Can't be less
than Start Date

Hostel Table
Colum name
HostelId

Datatype
Description
Varchar2(10) Unique Id Given to each hostel
in the college

Constraints
Composite
Primary Key

Roomno
StudentId
HostelFee

Number(3)
Varchar2(4)
Number(6)

Unique no given to each room


in a particular hostel
Student id of the student who
reside in a particular hostel and
in a particular room
Monthly fee of the hostel

Foreign key to
Student Table
Greater than 0

Attendance Table
Colum name

Datatype

StudentId

Varchar2(4)

CourseId

Varchar2(4)

TotalLecturedays

Number(3)

NoOfDaysPresent Number(3)

Description
Student id of the student whos
attendance is recorded
Course Id of the course in which
attendance is recorded
Total no of attendance in the
course
No of classes the student has
attended in the course

Constraints
Foreign key to
Student table
Foreign key to
Course table
Greater than 0

Applicant Data

ApplicantId

Applicant
Name
Raj

A001
Vadi
A002
Sam
A003
A004

Suraj

A005

Lakshmi

EmailId
raj@abc.co
m

Address
2nd
Street,Hebba
l
vadi@abc.c 4th
om
Street,Vijaya
ngar
Sam_Sund 5th
ar@abc.co Street,Edapp
m
alli
suraj@abc. 1st
com
Main,Rabindr
a Nagar
2nd
Main,Allipura

City
Mysore
Bangalore
Cochin
Kolkata
Vizag

A006

Sandra

A007

Vivek

A008

Vikas

A009

Bipin

A010

Gopi

gopi@abc.c
om

A011

Sandy

sandy@abc
.com

A012

Lilly

lilly@abc.c
om

A013

Rose

A014

Megha

A015

Henry

A016

Joel

Branch Data
BranchId
B1
B2
B3
B4

BranchName
Information
Science
Computer
Science
Electronics
Electrical

sandra@ab
c.com
Vivek_kum
ar@abc.co
m
vikas@abc.
com

megha@ab
c.com
henry@abc
.com
jeol@abc.c
om

m
3rd Corss,RS
Puram
5th
Main,Coimbe
d
2nd
Main,Jayalak
hmipuram
2nd
Cross,Siddar
th Nagar
2nd
Street,Green
Market
9th
Cross,Sesha
dripuram
9th
Main,Banjara
Hills
11th
Cross,Kadav
anthara
10th
Lane,Vashi
2nd
street,Silk
Board
4th
street,Vijaya
nagar

Coimbatore
Chennai
Bangalore
Mysore
Delhi
Bangalore
Hyderabad
Cochin
Mumbai
Bangalore
Mysore

B5
B6

Mechanical
Civil

Course Data

Cour
se
Id

C001
C002
C003
C004
C005
C006
C007
C008
C010
C009

Course
Name
Programmin
g
Fundamental
s
Data
Structures
Basics of
RDBMS
System
Software
Computer
Hardware
File
Structures
Network
Computing
Data
Warehousing
Analysis of
Algorithms
Neural
Networks

Student data

Bran
ch
Semest Id
er
1 B1

Proje
ct
Mark
s
20

2 B1

2 B1

Electi
ve

Assignment
Marks

Semest
Intern er
al
Exam
Marks Marks

10

10

60

20

10

10

60

20

10

10

60

3 B1

20

10

10

60

3 B2

20

10

10

60

4 B1

60

10

10

20

4 B3

20

10

10

60

5 B1

20

10

10

60

5 B1

20

10

10

60

6 B2

10

10

80

Current
StudentId ApplicantId Semester
S001
A001
2
S002
A003
3
S003
A004
5
S004
A006
3
S005
A007
4
S006
A008
7
S007
A009
8
S008
A010
3
S009
A012
1
S010
A013
4
S011
A014
7
S012
A015
6
S013
A016
2

UserId
raj
sam
suraj
sandra
vivek
vikas
bipin
gopi
lilly
rose
megha
henry
jeol

Password
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger
Tiger

Registration Data

Student Cours
Id
eId
S001
C001
C001
S002
C002
S003
C003
S004
S005
C004
C005
S006
S007
C006
S010
C004
C003
S009
S011
C007

Semest
Project
Assignme
er
Marks
nt
Grad
Interna Exam
Marks
e
l
DateOf
Exam
Marks Marks
5-Jun-08
20
5
5
50 A
24-Aug15
10
8
32 B
08
15-Mar20
9
9
55 A
08
13-Aug20
10
10
60 A
08
8-Sep-08
15
10
10
50 A
22-Nov10
5
5
30 D
08
6-Feb-08
45
5
5
15 B
8-Sep-08
20
10
10
40 A
29-Dec18
8
10
46 A
08
13-Sep20
7
8
55 A

08
16-Jan08
6-Feb-08

C008
S012
S013

C006

35

20 B

47

18 A

Department Data
DepartmentId DepartmentName HeadOfDepartment
10 Information
Science
20 Computer Science
30 Electronics
40 Electrical
50 Mechanical
60 Civil

I105
I102
I104
I107
I109
I106

Instructor Data
InstructorId
I101
I102
I103
I104
I105
I106
I107
I108
I109
I110
I111
I112
I113
I114
I115
I116

InstructorName DateOfJoining DepartmentId


Bob Hockins
12-Jan-00
10
Suguru Zikovich
21-Feb-01
20
Ritivoi
13-Jan-03
10
David Field
30-Mar-99
30
Emillie Norton
4-Jun-98
30
Ron Hardman
1-Jan-05
60
Scott Urman
8-Apr-08
40
Daisy Samson
9-Dec-04
50
Ford Bravo
10-May-08
50
Rebecca Brown
2-Jan-09
10
Antario
23-Jun-04
10
Samuel
25-Jan-02
60
Justin
14-Apr-03
40
Nissar
16-Mar-09
10
Avinash Naren
27-May-07
20
Micheal Rose
5-Jan-08
40

CourseAllocation Data

Allocatio
nId

CourseId
C001

1001
C002
1002
C001
1003
C001
1004
1005 C003
1006 C004
1007 C003
1008 C002
1009 C005
1010 C006
1011 C007
1012 C005
1013 C008

Instructor StartDa EndDate


Id
te
I101
1-Jun- 4-Jun-08
08
I102
7-Mar- 14-Mar-08
08
I103
20-Aug- 23-Aug-08
08
I101
1-Sep- 4-Sep-08
08
I104
10-Aug- 12-Aug-08
08
I103
4-Sep- 7-Sep-08
08
I104
26-Aug- 28-Aug-08
08
I107
21-Jul- 27-Jul-08
08
I105
12-Nov- 21-Nov-08
08
I106
1-Feb- 5-Feb-08
08
I108
7-Sep- 12-Sep-08
08
I109
12-Nov- 21-Nov-08
08
I110
15-Jan- 15-Jan-08
08

Attendance Data
StudentI
d

CourseI TotalLectureDa NoOfDaysPres


d
ys
ent

S-ar putea să vă placă și