Você está na página 1de 13

ASSIGNMENT OF RDBMS

31/7/2010
RAVI KUMAR
REGISTRATION NO. 10804644

RDBMS Lab Guide


Assignment 1: To understand ER Diagram.

Problem Description:

Draw an ER Diagram for the following scenario:

 There are multiple banks and each bank has many branches. Each branch
has multiple customers
 Customers have various types of accounts
 Some Customers also had taken different types of loans from these bank
branches
 One customer can have multiple accounts and Loans

M 1
Branches

1 Branch
Branch no. Name
name

Bank M
N#

Customers
Bank no. name

1 Account no.

M
Account and
loans

Customer
Loan no.
name

Assignment 2: To convert ER diagram to relational schema


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,eb, a,ed

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.

Ans:

Primary key = a,e

It is in 2nd normal form

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,bc and ca

b. R{a,b,c,d} ab, ad and bc

c. R{a,b,c,d,e} a,bc, a,bd and de

Answer: a) primary key is a,b


It is in 2nd normal form
b) primary key is a
it is 1st normal form
c) primary key is a,b
it is in 1st normal form
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 Constraints


Unique Id generated for an applicant
when he or she applies for admission in
ApplicantId Varchar2(4) the college. Primary Key
ApplicantName Varchar2(30) Name of the applicant Not null
EmailId Varchar2(30) email Id of the applicant Should be Unique
Address Varchar2(50) Complete address of Applicant
City Varchar2(15)

Branch Table

Column name Data type Description Constraints


Primary Key,
Should start with
BranchId Varchar2(2) Unique Id generated for a branch ‘B’
BranchName Varchar2(30) Name of the branch Not Null

Course Table

Column name Data type Description Constraints


CourseId Varchar2(4) Unique Id given to each course Primary Key
CourseName varchar2(30) Name of the course Not Null
Name of the semester in which the
Semester Number(1) course is taught
Id of the branch where the course is Foreign key to
BranchId Varchar2(2) taught Branch Table
Its value can be 'Y'
Elective char(1) Whether it is elective paper or not or 'N' only
Marks of the project in the course (if
ProjectMarks Number(3) any)
Assignment Marks for the course (if
AssignmentMarks Number(3) any)
InternalMarks Number(3) Internal Marks for the course (if any)
Marks of the semester exam of the
SemesterExamMarks Number(3) course

Student Table

Column name Data type Description Constraints


Unique id generated for each student
when he or she gets admitted in to the
StudentId Varchar2(4) college Primary Key
Applicant Id when the student applied Foreign key to
ApplicantId Varchar2(4) for the admission in the college Applicant table
Semester in which the student is
CurrentSemester number(1) currently studying
Decided at the time of selection in the
UserId Varchar2(15) college It should be unique
Decided at the time of selection in the
Password Varchar2(15) college Not Null

Registration Table

Column name Data type Description Constraints


Student Id of the student who has taken Foreign key to
StudentId Varchar2(4) up the course Student table
Course Id of the course in which the Foreign key to
CourseId Varchar2(4) student has appeared Course table
Date on which the semester exam was
DateOfExam Date conducted
Marks obtained by student in the
ProjectMarks Number(3) project of the course (if any)
Assignment Marks obtained by the
AssignmentMarks Number(3) student for the course (if any)
Internal Marks obtained by the student
InternalMarks Number(3) for the course (if any)
Marks of the semester exam obtained by
SemesterMarks Number(3) the student for the course
Grade Char(1) Over all grade of the student in the
course

Department Table

Column name Data type Description Constraints


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

Column name Data type Description Constraints


Primary Key,
Should start with
InstructorId Varchar2(4) Unique Id generated for Instructors ‘I’
InstructorName Varchar2(30) Name of the instructor Not Null
Date when instructor joins the
DateOfJoining Date department
Department id of the department where Foreign key to
DepartmentId Number(2) Instructor works Department table

Course Allocation Table


Column name Data type Description Constraints
Unique Id generated whenever ever a
AllocationId Number(4) course is allocated to a instructor Primary key
Course id of the course for which Foreign key to
CourseId Varchar2(4) allocation is done Course table
Instructor Id of the instructor who has Foreign key to
InstructorId Varchar2(4) been allocated the course Instructor table
Start date when a course is taken up by
the instructor( A course can be
allocated to the instructor in the middle
StartDate Date of the semester also)

Date till which the course is allocated to


the instructor( the instructor can be de
allocated from the course in the middle Can't be less than
EndDate Date of the semester) Start Date

Hostel Table

Colum name Datatype Description Constraints


Unique Id Given to each hostel in the
HostelId Varchar2(10) college
Unique no given to each room in a Composite Primary
Roomno Number(3) particular hostel Key
Student id of the student who reside in
a particular hostel and in a particular Foreign key to
StudentId Varchar2(4) room Student Table
HostelFee Number(6) Monthly fee of the hostel Greater than 0
Attendance Table

Colum name Dzatatype Description Constraints


Student id of the student who’s Foreign key to
StudentId Varchar2(4) attendance is recorded Student table
Course Id of the course in which Foreign key to
CourseId Varchar2(4) attendance is recorded Course table
TotalLecturedays Number(3) Total no of attendance in the course Greater than 0
No of classes the student has attended
NoOfDaysPresent Number(3) in the course

Applicant Data

Applicant
ApplicantId Name EmailId Address City
Raj raj@abc.com 2nd Mysore
A001 Street,Hebbal
Vadi vadi@abc.com 4th Bangalore
Street,Vijayanga
A002 r
Sam Sam_Sundar@a 5th Cochin
A003 bc.com Street,Edappalli
A004 Suraj suraj@abc.co 1st Kolkata
m Main,Rabindra
Nagar
A005 Lakshmi 2nd Vizag
Main,Allipuram
A006 Sandra sandra@abc.co 3rd Corss,RS Coimbatore
m Puram
A007 Vivek Vivek_kumar@ 5th Chennai
abc.com Main,Coimbed
A008 Vikas vikas@abc.com 2nd Bangalore
Main,Jayalakhmi
puram
A009 Bipin 2nd Mysore
Cross,Siddarth
Nagar
A010 Gopi gopi@abc.com 2nd Delhi
Street,Green
Market
A011 Sandy sandy@abc.co 9th Bangalore
m Cross,Seshadripu
ram
A012 Lilly lilly@abc.com 9th Main,Banjara Hyderabad
Hills
A013 Rose 11th Cochin
Cross,Kadavanth
ara
A014 Megha megha@abc.co 10th Lane,Vashi Mumbai
m
A015 Henry henry@abc.co 2nd street,Silk Bangalore
m Board
A016 Joel jeol@abc.com 4th Mysore
street,Vijayanag
ar

Branch Data

BranchId BranchName
B1 Information Science
B2 Computer Science
B3 Electronics
B4 Electrical
B5 Mechanical
B6 Civil

Course Data

Assign- Semester
Course Course Branch Project ment Internal Exam
Id Name Semester Id Elective Marks Marks Marks Marks
Programming 1 B1 N 20 10 10 60
C001 Fundamentals
C002 Data Structures 2 B1 N 20 10 10 60
C003 Basics of RDBMS 2 B1 N 20 10 10 60
C004 System Software 3 B1 N 20 10 10 60
Computer 3 B2 N 20 10 10 60
C005 Hardware
C006 File Structures 4 B1 N 60 10 10 20
Network 4 B3 N 20 10 10 60
C007 Computing
Data 5 B1 Y 20 10 10 60
C008 Warehousing
Analysis of 5 B1 N 20 10 10 60
C010 Algorithms
C009 Neural Networks 6 B2 Y 10 10 80
Student data

Current
StudentId ApplicantId Semester UserId Password
S001 A001 2 raj Tiger
S002 A003 3 sam Tiger
S003 A004 5 suraj Tiger
S004 A006 3 sandra Tiger
S005 A007 4 vivek Tiger
S006 A008 7 vikas Tiger
S007 A009 8 bipin Tiger
S008 A010 3 gopi Tiger
S009 A012 1 lilly Tiger
S010 A013 4 rose Tiger
S011 A014 7 megha Tiger
S012 A015 6 henry Tiger
S013 A016 2 jeol Tiger

Registration Data

Semester
DateOf Project Assignment Internal Exam
StudentId CourseId Exam Marks Marks Marks Marks Grade
S001 C001 5-Jun-08 20 5 5 50 A
S002 C001 24-Aug-08 15 10 8 32 B
S003 C002 15-Mar-08 20 9 9 55 A
S004 C003 13-Aug-08 20 10 10 60 A
S005 C004 8-Sep-08 15 10 10 50 A
S006 C005 22-Nov-08 10 5 5 30 D
S007 C006 6-Feb-08 45 5 5 15 B
S010 C004 8-Sep-08 20 10 10 40 A
S009 C003 29-Dec-08 18 8 10 46 A
S011 C007 13-Sep-08 20 7 8 55 A
S012 C008 16-Jan-08 35 5 5 20 B
S013 C006 6-Feb-08 47 8 7 18 A

Department Data
DepartmentId DepartmentName HeadOfDepartment

10 Information Science I105


20 Computer Science I102
30 Electronics I104
40 Electrical I107
50 Mechanical I109
60 Civil I106

Instructor Data

InstructorId InstructorName DateOfJoining DepartmentId


I101 Bob Hockins 12-Jan-00 10
I102 Suguru Zikovich 21-Feb-01 20
I103 Ritivoi 13-Jan-03 10
I104 David Field 30-Mar-99 30
I105 Emillie Norton 4-Jun-98 30
I106 Ron Hardman 1-Jan-05 60
I107 Scott Urman 8-Apr-08 40
I108 Daisy Samson 9-Dec-04 50
I109 Ford Bravo 10-May-08 50
I110 Rebecca Brown 2-Jan-09 10
I111 Antario 23-Jun-04 10
I112 Samuel 25-Jan-02 60
I113 Justin 14-Apr-03 40
I114 Nissar 16-Mar-09 10
I115 Avinash Naren 27-May-07 20
I116 Micheal Rose 5-Jan-08 40
CourseAllocation Data

AllocationId CourseId InstructorId StartDate EndDate


1001 C001 I101 1-Jun-08 4-Jun-08
1002 C002 I102 7-Mar-08 14-Mar-08
1003 C001 I103 20-Aug-08 23-Aug-08
1004 C001 I101 1-Sep-08 4-Sep-08
1005 C003 I104 10-Aug-08 12-Aug-08
1006 C004 I103 4-Sep-08 7-Sep-08
1007 C003 I104 26-Aug-08 28-Aug-08
1008 C002 I107 21-Jul-08 27-Jul-08
1009 C005 I105 12-Nov-08 21-Nov-08
1010 C006 I106 1-Feb-08 5-Feb-08
1011 C007 I108 7-Sep-08 12-Sep-08
1012 C005 I109 12-Nov-08 21-Nov-08
1013 C008 I110 15-Jan-08 15-Jan-08

Attendance Data

StudentId CourseId TotalLectureDays NoOfDaysPresent

S001 C001 4 3
S002 C001 4 4
S003 C002 8 5
S004 C003 3 3
S005 C004 4 2
S006 C005 10 9
S007 C006 5 5
S010 C004 4 4
S009 C003 3 1
S011 C007 6 5
S012 C008 1 1

Hostel Data

HostelId RoomNo StudentId HostelFee


Violet 101 S001 3000
Violet 201 S003 4000
Violet 301 S004 5000
Indigo 100 S002 3000
Indigo 200 S005 4000
Indigo 300 S006 5000
Blue 102 S007 3000
Blue 202 S008 4000
Blue 302 S009 5000

Você também pode gostar