Sei sulla pagina 1di 45

Course Code : CS-67

Course Title : RDBMS Lab


Assignment Number : BCA (4)-67/Assignment/ 2011
Maximum Marks : 100
Last Date of Submission : 30
th
April, 2011/30
th
October, 2011

(Solve by Deepanjan Dey, Siliguri, west Bengal )

Answer all the questions. You may use examples illustrations or diagrams to support your
answer. You have to implement the database system using any RDBMS.
A Central University runs Irom its main campus and a number oI associated colleges. The
University has several programs ranging Irom Diploma (1 year duration), Bachelor`s degree (3 or
4 year`s duration), Post Graduation (2 to 3 years duration) and research degree programs (2-3 years
duration). The structure oI each program is approved centrally. A program may be oIIered through
the main campus or associated college. The students are registered centrally in a program and
college oI his/her choice. The Iee is also paid centrally yearly. The Iinal data oI admission can be
obtained by the colleges through a query to the central database. The University has a centralized
examination system. It conducts the examination oI the students in various courses oI various
programs. For simplicity you may assume that a program oI the University only have three
compulsory courses in a year. PerIorm the Iollowing tasks Ior the University. Please make and
state assumptions, iI any.
"uestion 1: (10 Marks)
ist the entities, their attributes and relationships Ior the description and make an ER-diagram Ior
the University. You may use the concept oI keys, aggregation, generalization, cardinality etc. in a
proper way.


Ans:
Here I use Enhanced Entity Relationship diagram (EERD) because we can apply generalization
specialization concept in EERD. BeIore draw an EERD, here explanation oI steps oI Draw an
ERD.
Entity-Relationship (ER) diagramming technique has been used as a graphical technique Ior
modeling the real world. In our daily liIe, we use natural languages to describe the real world. The
main correspondence relationships between ER diagram structures and English grammar structures
have been identiIied. The Iollowing are some examples: A 'common noun in English usually
corresponds to an entity types/set in ER diagrams, while a 'proper noun usually corresponds to
a 'speciIic entity`. A 'verb usually corresponds to a 'relationship`. An adjective corresponds to
an 'attribute oI an entity while an 'adverb` corresponds to an 'attribute oI relationship. The
gerund and 'clauses structures also have corresponding structures in ER diagrams

An EER model with entity, relationship, grouping and aggregation types and generalization is
used.
Generalization in which a set oI similar types is regarded as a generic entity type. All
Attribute oI the super type are deIined on all subtype. Entity oI any subtype may participate in any
relationship. Additional attribute can be deIined on each subtype
Specialization: Identifying subclass. And their distinguishing characteristics (attributes &
relationship)
Generalization: aggregate entity to a super class entity type by identifying their common
characteristics
Aggregation Used when we have to model a relationship involving (entity sets and) a relationship
set. Aggregation allows us to treat a relationship set as an entity set Ior purposes oI participation
in (other) relationships
Aggregation:
II we consider the ternary relationship orks-on, suppose we want to record managers Ior tasks
perIormed by an employee at a branch
Ior example.
:
Following E-R Diagram with Aggregation





Entity relationship diagram of ABC CentraI University



































&niversity
College
has
N
1
Program
Conduct
Avail on
Students
Research
degree
Diploma
Bachelor`s
degree
Post
Graduation
Fees Structure
d
College
student
Main campus
student
oI
D Exam
Fees
Admissi
on fee
Subject
N
1
N
1
Diploma
Student
Bachelor
Student
Post Graduate
student
Research
student
D
d
Major in
Minor in
n
Year
Exam
College ID
Name
Name
Address
Name
Prog.
Name
Prog
Code
Name
Enroll no.
Exam
Code
Date oI admission
Exam
schedule
P
a
y

I
e
e
s

I
o
r


A
p
p
l
i
e
d

I
o
r


Get marks
Marks
C
o
l
l
e
g
e
s

C
l
a
s
s

s
c
h
e
d
u
l
e

Attendance
Grade
C
l
a
s
s

s
c
h
e
d
u
l
e


M
a
i
n

c
a
m
p
u
s

C
l
a
s
s

s
c
h
e
d
u
l
e

D
e
m
a
n
d

D
r
a
I
t


Is
Compulsor
y
N
Has
N N
Department
offers
N
On
ON
Teach
in yr

"uestion 2: (10 Marks)
Design the suitable RDBMS tables Ior the ER-diagram so created in question 1. The database
design should include keys, Ioreign keys, constraints and reIerential integrity constraints.


Answer
Step by step to convert entity of ERD to RDBMS tables






Name Address Contact to Whom Phone


This university runs several programs, and program has many subjects.
Some subjects are compulsory, and some are optional or elective.
Programs are Iour types. Diploma, Bachelor, post graduate, research.
In case of diploma program like DIC (Diploma in Computer) or, where student should learn
all subjects that are mentioned. That means subjects are Iixed.
But in case oI Bachelor degree, there are two diIIerent matters.
In case of Bachelor degree programs like B.Sc. B.Com., some subjects are elective. And student
will select some subject as a Major subject as well as minor subjects.
Another thing some student opt a mafor subfects and three other minor subfect. But some student
chose no mafor subfects, they study in pass course.
But some Bachelor degree BBA, BCA, where subjects are Iixed. And there is no question oI
major or minor subjects.
In case of post graduate, programs are like M.Sc. in mathematics department, M.Sc. in
Chemistry department or M.A. in Hindi department.
I.e. post graduate program is done on some subjects like mathematics, Hindi etc.
Similarly in case of research program, research program is done on some particular subjects.
&niversity
Name Address
Contact to Whom Phone

The University has several program ranging Irom Diploma (1 year duration), Bachelor`s degree (3
or 4 year`s duration), Post Graduation (2 to 3 years duration) and research degree program (2-3
years duration).











Program table
Prog. Code Program Name
Duration


Sub tables of Program table
Diploma programs
Prog. Code
Post Graduate program
Prog. Code Prog_PG_SrNo Dept Code
Research program
Prog. Code Dept Code Topic

Program has subject`s relation
Prog. Code Sub Code Is Compulsory Teach in Yr
Research
degree
Diploma
Bachelor`s
degree
Post
Graduation
d
Prog. Code
Program
Name
Duration
Program
Subjects
Is Compulsory

Department
OIIer
s
On
on
Department
Dept Code Department name

N
N
1
1
Bachelor`s program
Prog Code

Subject table
Sub Code Subject Name

Has
T
e
a
c
h

i
n

Y
e
a
r

Department offers subject Relation
Dept Code Sub Code

Post graduate program has subject
Post_PG_SrNo
Sub code

The student table
Students are two types,
O Student who get admission in main campus oI university and
O Student who admitted in a college under this university
And as per admission in program students are Iour sub types.
O Diploma student
O Bachelor student
Students
College
student
Main campus
student
Diploma
Student
Bachelor
Student
Post
Graduate
student
Research
student
d
Name
Enroll no. Date oI admission
d
The students table

Enroll
no
Name Father
name
Address Age Date oI
admission
Prog.
Code
Current
Year





Bachelor Student major subject`s relation






Post graduate student
Enroll no Post_PG_SrNo

College
College student
Enroll no College Code

College table
College Code College Name .

Enroll no Major subject code
Subject table
sub code Subjects name

Bachelor students` Minor subjects` relation
Enroll no Minor Sub code

Research student
Enroll no Dept code topic

O Post graduate student
O Research student
Post Graduate program
Prog. Code Post_PG_SrNo Dept Code

Fees structure
The Iees are admission Iee (Ior each year) and examination Iee. The amount oI Iee varies as per
program. And it will be change as per Year or session
Program
Fees Structure
Exam Fees
Admission fee
Year
d
For example
Admission Iee Ior MCA program is Rs 10000/- Ior year 2010
Admission Iee Ior MBA program is 9900/- Ior 2010
(But it may change next year)
Admission Iee Ior MCA program is Rs 11000/- Ior year 2011
Admission Iee Ior MBA program is 10000/- Ior 2011

Admission Iee collected at the beginning oI year (or session)
and Examination Iee will be collected at the end oI year
Total Amount oI exam Iee is depend on how many subject
they Iill up Ior examinations
Fees structure
Fee Code Fee amount Type Code Year Sr No Prog. Code

Year ( or session)
Sr
No
Year starDate EndDate
Fees type Name
Type Code Fees type Name
1 Admission Fee
2 Exam Fee
Fee payment made by student
Enroll No Fees Code Date oI
payment
Amount Demand
DraIt No
Bank Demand
DraIt Date
123 1 1/12/2010 100000 456321 SBI 29/11/2010
123 2 1/11/2011 300 651236 SBI 24/10/2011

Fee
Code
Examination application of student

Enroll no. ExamScCode YearSrNo
123 1 3
123 2 3
123 5 3
121 1 3


Calculate total examination Iee
by counting how many subject
They applied Ior

Examination schedule



Exam schedule
ExamScCode ExamCode YearSrNo Subject Prog. Code Date ShiIt
1 1211 3 Sub1 BCA 1/06/11 M
2 1211 3 Sub2 BCA 5/06/11 E

Subject Year
Exam
Exam
schedule
Students
A
p
p
l
i
e
d

I
o
r


G
e
t

m
a
r
k
s

Exam table
ExamCode Exam Name YearSrNo
1210 December 2010 2
1211 December 2011 3

Year
Sr
No
Year starDate EndDate
1 2009 1/1/2009 31/12/2009
3 2011 1/1/2011 31/12/2011

Subject table
Sub Code Subject Name
Sub1 Database Management System
Sub2 Operation System

Program table
Prog. Code Program name
BCA Bachelor in Computer application


Program
Student exam application student admit card

Enroll no. ExamScCode
123 1
123 2
123 5
121 1



Enroll no. ExamScCode
123 1
123 2
121 1

(May some subjects applied by student
may rejected by &niversity Ior some
reason)
Grade card
Enroll No ExamScCode Marks
123 1 69
123 2 75


A
d
m
i
t

c
a
r
d

Class Schedule
Class Schedule of College is vary Irom college to college, and Irom Main campus class schedule





Colleges Class schedule
Class schedule

Main campus Class schedule
Subject: College
College
Code
Name
College
College Code Name Address Contact Number

Program table
Prog. Code Program Name Duration Type

Subject table
Sub Code Subject Name

Subject Belong to Program Relation

Prog Code Sub Code Teach In Year
BCA Sub1 2
MCA Sub1 1
BCA Sub2 2



College Class Schedule table
Class Sr No College Id Sub Code Date Start Time End Time Prog Code

College Student attendance table
Enroll No Class Sr No College Id Is Present

Main Campus Class Schedule table
Class Sr No Sub Code Date Start Time End Time Prog Code

Main Campus Student attendance table
Enroll No Class Sr No Is Present

Program
Available on
Belong to
Assume that this subject Database
Management System (sub1)
Is taught in BCA 2
nd
Year and MCA 1
st

year
"uestion 3: (10 Marks)
Implement the database design that you have created in question 2 using a RDBMS our advice is
that you choose either MySQ or MS ACCESS to do so.
Answer:
Here I :80MS ACCESS
&niversity table
Column name data type size is Primary key Remark
University Name text 50
Address Text 100
Contact to Whom Text 25
Phone Text 13

College table
Column name data type size is Primary key Remark
College Code text 4 primary key
Name text 30
Address text 100
Contact Number text 13

Program table
Column name data type size is Primary key Remark
Prog. Code text 5 primary key

Program Name text 30
Duration number 1

Program Has Subjects relation
Column name data type size is Primary key Remark
Prog Code text 5 part of Primary Key, reference to Program
Sub Code text 5 part of Primary Key,Reference to Subject
Is Compulsory Yes/No 1 bit
Teach in year number 1

Program Diploma Table
Column name data type size is Primary key Remark
Prog Code text 5 Primary Key (reference to Program)

Program Post graduate Table
Column name data type size is Primary key Remark
Prog Code text 5 Primary Key (reference to Program)
Dept code text 3 reference to department table
ProgPGSrNo number 1 Unique key
Program Post graduate program has subject Relation
Column name data type size is Primary key Remark
ProgPGSrNo number 1 reference to Post graduate tab
Sub code text 5 reference to Subject tab

Program Research Degree Table
Column name data type size is Primary key Remark
Prog Code text 5 Primary Key (reference to Program)
Dept code text 3 reference to department table
Topic Text 100

Program Bachelor`s table
Column name data type size is Primary key Remark
Prog Code text 5 Primary Key (reIerence to Program)

Department Table
Column name data type size is Primary key Remark
Dept code text 3 primary key
Department name text 25
Department offers subject Relation
Column name data type size is Primary key Remark
Dept code text 3 reIerence to department table
Sub code text 5 reIerence to Subject table
Student table
Column name data type size is Primary key Remark
Enroll no text 10 Primary key
StudName Text 30
Father name Text 30
Address Text 100
Age number 1
Date oI admission Date / Time short
Prog Code text 5 Primary Key (reference to Program)
Current Year number 2

College student
Column name data type size is Primary key Remark
Enroll no text 10 Primary key reIerence to student table
College Code text 4 reIerence to College table

Prog_Bachelor_Student_has_major_Subject (Bachelor Student has Major Subject relation)
Column name data type size is Primary key Remark
Enroll no text 10 Primary key reIerence to student table
Major subject Text 5 ReIerence to subject table


Prog_Bachelor_Students_Has_Minor_Subjects (Minor subjects oI bachelor students table)
Column name data type size is Primary key Remark
Enroll no text 10 Primary key reIerence to student table
Minor sub code text 5 ReIerence to subject table

Student _ Post graduate
Column name data type size is Primary key Remark
Enroll no text 10 Primary key reIerence to student table
ProgPGSrNo text 5 reIerence to subject table
Studen_Diploma
Column name data type size is Primary key Remark
Enroll no text 10 Primary key reIerence to student table

Student _ Research Student
Column name data type size is Primary key Remark
Enroll no text 10 Primary key reIerence to student table
Sub code text 5 reIerence to subject table
Topic text 255

Year table
Column name data type size is Primary key Remark
Sr no Number 1 Primary key
Year Number 2
Start date Date / time short
End date date / time short
Fees type Name table
Column name data type size is Primary key Remark
Type Code text 1 Primary key
Fees type Name Text 35

Fee structure table
Column name data type size is Primary key Remark
Fee Code number 1 Primary key
Fee amount Currency
Type Code text 1
YearSrNo Number 1 reIerence to Year table
Prog Code text 5 reIerence to Program table

Fee payment table
Column name data type size is Primary key Remark
Enroll no text 10 part oI Primary key reIerence to student tab
Fees Code number 1 part oI Primary key reIerence to Iee
Date oI payment Date / time short
Amount Currency
Demand draIt no Text 6
Bank Text 20
Demand draIt date date / time



Exam table
Column name data type size is Primary key Remark
Exam Code Text 4 Primary key

Exam name Text 15

Year sr no Number 1


Exam schedule table
Column name data type size is Primary key Remark
ExamScCode number 2 primary key

ExamCode text 4 reIerence to exam table

YearSrNo Number 1 ReIerence to Year table
Sub Code text 5 Reference to Subject Table
Prog Code Text 5 reIerence to program table

DateOIExam Date/ Time short

ShiIt text 1 (M` Ior Morning ,E Ior evening)

Student exam application table
Column name data type size is Primary key Remark
Enroll no. Text 10 part oI primary key reIerence to Student

ExamScCode Number 2 part oI primary key reIerence to Exam schedul


Student admit card
Column name data type size is Primary key Remark
Enroll no. Text 10 part oI Primary key ReIerence to student
ExamScCode Number 2 part oI Primary key ReIerence to Exam sche

Student Get Marks relation
Column name data type size is Primary key Remark
Enroll No Text 10 part oI Primary key reIerence to student
ExamScCode number 2 part oI Primary key reIerence to exam sch
Marks single 4


Subject table
Column name data type size is Primary key Remark
Sub Code text 5 Primary key
Subject Name text 25
College Class Schedule table
Column name data type size is Primary key Remark
Class Sr No number 2 part oI primary key
College Code text 4 part oI primary key reIerence to college tab
Sub Code text 5 reIerence to subject table
Date oI Class Date/Time Short Date
Start Time Date/time Short Time
End Time date /time Short Time
Prog Code text 5

College Student attendance table
Column name data type size is Primary key Remark
Enroll No Text 10 part oI Primary key reIerence to student
Class Sr No number 2 part oI Primary key reIerence to ColgClass Sc
College Code text 4 part oI primary key reIerence to Collge
Is Present Yes/ No is absent or present


Main Campus Class Schedule table
Column name data type size is Primary key Remark
Class Sr No number 2 primary key
Sub Code text 5 reIerence to subject table
Date Date/Time short date
Start Time Date/time short time
End Time date /time short time
Prog Code text 5
Main Campus Student attendance table

Column name data type size is Primary key Remark
Enroll No Text 10 part oI Primary key reIerence to student
Class Sr No number 2 part oI Primary key reIerence to main Campus
class Schedule
Is Present Yes/ No is absent or present
"uestion 4: (10 Marks)
Create the Iollowing data entry Iorm with suitable checks Ior the database so created.
a) Form Ior Entry oI student inIormation such as enrolment number, name, Iather`s name, date oI
birth, program code (it should be Irom a list oI valid programs), year oI program, and draIt
number (Ior Iee).
b) Form Ior entry oI examination results oI a course submitted by an examiner. It should be noted
that the examiners are sent printed examination sheet called mark list Ior each subject. The
mark list contains printed enrolment number and name oI the students and a blank column Ior
entering the marks. A mark list is sorted in the order oI enrolment numbers.
Answer:

The relationship screen of Access database

Form1: The Iorm Ior records oI &niversity


Form 2: the Iorm Ior Insert or View records oI College


Form 3: the Iorm Ior Insert or View records oI Student
Form 4: the form Ior insert record oI Program, but there Iour type oI Program

II program is Diploma type

When new record is inserted then
A new record inserted into program
Diploma table along with Program
table

II Program is Bachelor degree

When new record is inserted then
A new record inserted into
ProgramBachelorDegree table along
with Program table




II Program is Post Graduate degree


A new record inserted into
ProgramPostGraduate table along
with Program table

II Program is Research Degree


A new record inserted into
ProgramResearch_Dgree table along
with Program table



Examination
Form 5: insert record into Examination


Form 6: insert record into Year

Form 7: insert record oI Exam schedule


Now question is how marks oI student will be store.
There are exam schedule Ior Subject oI Program code. Student applied Ior examination. These are
veriIied and admit card will be issued,
And among the subjects oI admit card, student appear Ior exam.
Now according to student and subject they appear in exam are entered into student`s marks details
table.
Form 8: Student examination application
(User will select Student name, its enrolment number will be automatically Ietch
User will select exam schedule Irom dropdown list box)



Form 9: insert records oI Admit card


Form 10: Insert marks oI Student

"uestion 5: (10 Marks)
Enter at least 4 sets oI records in each table. Enter marks directly in the tables except Ior the data
that can be entered using the data entry Iorm created in question 3.

Answer:
Here I enter records in College table
CoIIeges
CoIIegeCode CoIIegeName Address ContactNo
C001 Adarsh Maha Vidyalaya Siliguri, West Bengal 035322669778
C002 SLGUR COLLEGE Siliguri , west bengal 0353236987
C003 KOLKATA COLLEGE KOLKAT , WEST BENGAL 0332569744

Here students details
$tudents
nroIINo $tudName FatherName Address Age DateOfAdmission ProgCode CurrentYear
043701803 Deepanjan Niresh ch. Dey Siliguri 33 6/2/2004 BCA 3
043701804 Debashis Ramesh Cooch Behar 23 8/1/2005 BCA 1
043701805 Dipankar Tapash Benarash 22 8/1/2005 BBA 2
And student admit in college
CoIIege$tudent
nroIINo CoIIegeCode
043701803 C001
043701804 C001
043701805 C002

"uestion 6: (10 Marks)
Create the Iollowing reports Ior the database you have created. The reports should have proper
headings and page numbers and should include totals, iI needed.
a) Create the list oI students oI a college. This list should be sorted in the order oI program and
enrolment numbers in that program.
b) Create an attendance list Ior a subject in a college.
c) Print the mark list oI a subject that needs to be veriIied.
d) Create the result card Ior a student.
Answer:
a) Create the list oI students oI a college. This list should be sorted in the order oI program and
enrolment numbers in that program.
SELECT CollegeCode FROM Colleges WHERE CollegeName 'Adarsh Maha Vidyalaya'
Above S"L give the CollegeCode of a Particular college
And this will be used another S"L as Sub query

SEECT S.StudName, S.ProgCode, S.EnrollNo, C.CollegeCode
FROM Students AS S INNER JOIN CollegeStudent AS C ON S.EnrollNo C.EnrollNo
WHERE (((C.CollegeCode) In
(SEECT CollegeCode FROM Colleges WHERE CollegeName'Adarsh Maha Vidyalaya')))
ORDER BY S.ProgCode, S.EnrollNo;

b) Create an attendance list Ior a subject in a college.
Ans
FORM FOR INSERT record of attendance
Before that class schedule is inserted then absent present of student are inserted.

The S"L

SELECT Students.StudName, CollegeStudentAttendance.CollegeCode,
CollegeClassSchedule.DateOfClass, Subjects.SubjectName, Students.ProgCode
FROM Students INNER 1OIN (Subjects INNER 1OIN (CollegeClassSchedule INNER 1OIN
(Colleges INNER 1OIN (CollegeStudentAttendance INNER 1OIN CollegeStudent ON
CollegeStudentAttendance.EnrollNo CollegeStudent.EnrollNo) ON
(CollegeStudentAttendance.CollegeCode Colleges.CollegeCode) AND
(Colleges.CollegeCode CollegeStudent.CollegeCode)) ON (Colleges.CollegeCode
CollegeClassSchedule.CollegeCode) AND (CollegeClassSchedule.ClassSrNo
CollegeStudentAttendance.ClassSrNo)) ON Subjects.SubCode
CollegeClassSchedule.SubCode) ON (CollegeStudentAttendance.EnrollNo
Students.EnrollNo) AND (Students.EnrollNo CollegeStudent.EnrollNo);
The output

$tudName CoIIegeCode DateOfCIass $ubjectName ProgCode
Deepanjan C001 4/27/2011 Computer Architecture BCA
Anil C001 4/1/2011 Visual Basic MSC
Debashis C001 4/1/2011 Visual Basic BCA
Susanta C001 4/1/2011 Visual Basic BSC
Deepanjan C001 4/1/2011 Visual Basic BCA

c) Create the result card Ior a student
SELECT Students.EnrollNo, Students.StudName, Exam.Exam_Name, Subjects.SubjectName,
StudentGetMarks.Marks
FROM Students INNER 1OIN (Subjects INNER 1OIN (Exam INNER 1OIN (Exam_Schedule
INNER 1OIN StudentGetMarks ON Exam_Schedule.ExamScCode
StudentGetMarks.ExamScCode) ON Exam.ExamCode Exam_Schedule.ExamCode) ON
Subjects.SubCode Exam_Schedule.Sub_Code) ON Students.EnrollNo
StudentGetMarks.Enroll_No;



"uestion 7: (20 Marks)
Write and run the Iollowing SQ queries Ior your database:
a) Find the details oI the program having the maximum number oI students.

Answer:
Step1: count number oI student

Output

CountOfProgCode ProgCode
1 BA
1 BBA
2 BCA
1 BSC
1 MSC
Step2: get maximum among count
SEECT Max (Query1.CountOIProgCode) AS MaxOICountOIProgCode
FROM Query1;
Output
2
Now match this with


Step3:
SEECT Query1.ProgCode
FROM Query1
WHERE (((Query1.CountOIProgCode) In (SEECT Max(Query1.CountOIProgCode) AS MaxOICountOIProgCode
FROM Query1)));
The output

ProgCode
BCA
Step4:
Now just get details oI Program
SEECT Programs.ProgCode, Programs.ProgramName, Programs.Duration
FROM Programs
WHERE (((Programs.ProgCode) In (SEECT Query1.ProgCode
FROM Query1
WHERE (((Query1.CountOIProgCode) In (SEECT Max(Query1.CountOIProgCode) AS MaxOICountOIProgCode
FROM Query1))))));
The output

ProgCode ProgramName Duration
BCA Bachelor in Computer Applicati 3


b) Find the program that has the maximum Iee. Also Iind the number oI students enrolled in this
program.
Answer:

Step1:
Get program that has Maximum Iee
SEECT FeeStructure.ProgCode
FROM FeeStructure
WHERE (((FeeStructure.FeeAmount) In (SEECT Max(FeeStructure.FeeAmount) AS MaxOIFeeAmount
FROM FeeStructure)));
OUTPUT IS
Mca

Step2:
Count number oI student enroll in this program
SEECT COUNT( Students.EnrollNo)
FROM Students
WHERE (((Students.ProgCode)"MCA"))
OR USE SUB QUERY
SEECT Count(Students.EnrollNo) AS Expr1
FROM Students
WHERE (((Students.ProgCode) In (SEECT FeeStructure.ProgCode
FROM FeeStructure
WHERE (((FeeStructure.FeeAmount) In (SEECT Max(FeeStructure.FeeAmount) AS MaxOIFeeAmount
FROM FeeStructure))))));
c) Find the student who have either Iailed the subject Database Management System at least once
or has not given the examination Ior this subject. You may assume that this subject is taught in
BCA 2
nd
Year and MCA 1
st
year
Answer:
am
amCode am_Name Yea_$r_No
1 December
2011
3





am_$cheduIe
am$cCode amCode Year$rNo $ub_Code Prog_Code DateOfam $hift
1 1 1 CS-64 BCA 7/12/2011 M
2 1 3 CS-06 BCA 7/12/2011 E
3 1 3 CS-65 BCA 8/12/2011 M
4 1 3 CS-06 MCA 9/12/2011 M

$tudentGetMarks
nroII_No am$cCode Marks
043569876 4 36
043701803 2 55
043701805 3 35
043703803 4 69
654654564 4 60

Student table
nroII No $tud Name
Prog
Code
Cur
Year
043569876 vhggadhg MCA 2
043701803 Deepanjan BCA 3
043701804 Debashis BCA 1
043701805 Dipankar BBA 2
043702001 Debojit BA 1
043703803 Depanjan dey MCA 2
0578/9633 Susanta BSC 3
058796321 Anil MSC 1
654654564 GHGG MCA 2

This table reIlects marks oI student,
II there is no records Ior a student Ior a
particular subject like Database
Management System (CS-06) then he/she
have not appear exam Ior this subject

And we assume pass mark is 40, so iI marks on this table is below 40 then it assume that student Iailed
on this subject

A student oI BCA will apply Ior Database Management System (CS-06) iI he/she in 2
nd
year or more
than 2
nd
year mean 3
rd
year.

Similarly a student oI MCA will apply Ior Database Management System (CS-06) iI he /she in 1
st
year
or more than 1
st
year mean 2
nd
year or 3 rd year. Mean all student oI MCA
Step1:
Get student oI BCA who in 2
nd
year or 3
rd
year
And to get all student oI MCA
SEECT Students.EnrollNo, Students.CurrentYear FROM Students WHERE (((Students.ProgCode)"BCA") AND
((Students.CurrentYear) In (2,3)))
Out put
BCA
nroIINo CurrentYear
043701803 3
043701804 2

SEECT Students.EnrollNo, Students.CurrentYear FROM Students WHERE (((Students.ProgCode)"MCA"));
MCA
nroIINo CurrentYear
043703803 2
043569876 2
654654564 2

Union two SQ, and get all student oI MCA and BCA student who study in 2
nd
year, 3
rd
year
SEECT Students.EnrollNo FROM Students WHERE (((Students.ProgCode)"BCA") AND ((Students.CurrentYear)
In (2,3)))
Union
SEECT Students.EnrollNo FROM Students WHERE (((Students.ProgCode)"MCA"))

The out put
BCA MCA student
nroIINo
043569876
043701803
043701804
043703803
654654564

Now check these enrolment number which no in StudentGetMarks table
Step1:

The output
$tudentWhoAppearamForAM_DBM$
nroII_No
043701804
043701805
043703803
654654564
And student who not appear Ior DBMS Exam

The output
$tudentWhoNotAppearDBM$_am
nroIINo
043569876
043701803
Again student who score below pass mark in subject Database Management System

SEECT StudentGetMarks.EnrollNo
FROM ExamSchedule INNER JOIN StudentGetMarks ON ExamSchedule.ExamScCode
StudentGetMarks.ExamScCode
WHERE (((ExamSchedule.SubCode) In (SEECT SubCode FROM Subjects WHERE SubjectName 'Database
Management System')) AND ((StudentGetMarks.Marks)40));
The output
$tudenWhoFaiI
nroII_No
043569876
Combine these two sql get enrolment number oI students who either Iailed the
subject Database Management System at least once or has not given the examination Ior this
subject
SEECT * FROM StudentWhoNotAppearDBMSExam
union
SEECT * Irom StudenWhoFail

The output

nroIINo
043569876
043701803
043701805

Marks 40
And at last get name oI students with these enrolment no
SEECT Students.EnrollNo, Students.StudName, Programs.ProgramName
FROM (Students INNER JOIN |Q 7 c c| ON Students.EnrollNo |Q 7 c c|.EnrollNo) INNER
JOIN Programs ON Students.ProgCode Programs.ProgCode;
The output

nroIINo $tudName ProgramName
043569876 Bidhan Master in Comp Applica
043701803 Deepanjan Bachelor in Computer Applicati
043701805 Dipankar Bachelor in Computer Applicati


d) Find the student who has topped in BCA 2
nd
Year examination.

Answer:
Here table StudentGetMarks keep records oI student marks
Now Iilter this table with subject code oI BCA 2
nd
year
SQ to get subject code oI BCA 2
nd
year

Now Iilter
SEECT StudentGetMarks.EnrollNo, StudentGetMarks.Marks, Programs.ProgCode, ExamSchedule.SubCode
FROM Programs INNER JOIN (ExamSchedule INNER JOIN StudentGetMarks ON ExamSchedule.ExamScCode
StudentGetMarks.ExamScCode) ON Programs.ProgCode ExamSchedule.ProgCode
WHERE (((Programs.ProgCode)"BCA") AND ((ExamSchedule.SubCode) In (SEECT SubCode FROM ProgramHasSubjects
WHERE ProgCode "BCA" AND TeachInYear 2)));
Now I save this SQ with a name StudentMarksOfBCA2ndYear
$tudentMarksOfBCA_2ndYear
nroII_No Marks ProgCode $ub_Code
043701805 56 BCA CS-64
043701804 70 BCA CS-64
043701803 80 BCA CS-64
043701805 35 BCA CS-06
043701804 60 BCA CS-06
043701803 66 BCA CS-06
043701803 56 BCA CS-65
043701804 80 BCA CS-65
043701805 70 BCA CS-65

Next apply Sum aggregate Iunction to get total marks oI BCA 2
nd
year student
SEECT StudentMarksOIBCA2ndYear.EnrollNo, Sum(StudentMarksOIBCA2ndYear.Marks) AS SumOIMarks
FROM StudentMarksOIBCA2ndYear
GROUP BY StudentMarksOIBCA2ndYear.EnrollNo;
BCA_2nd_year_TotaIMarks
nroII_No $umOfMarks
043701803 202
043701804 210
043701805 161
Now Iind out WHO GET maximum value
SEECT BCA2ndyearTotalMarks.EnrollNo
FROM BCA2ndyearTotalMarks
WHERE (((BCA2ndyearTotalMarks.SumOIMarks) In (SELECT Max(SumOfMarks) AS MaxOfSumOfMarks
FROM BCA_2nd_year_TotalMarks)));
The output
nroII_No
043701804
So we get enrolment number, and we easily get student details with these enrolment number
SEECT Students.EnrollNo, Students.StudName, Students.FatherName
FROM Students
WHERE (((Students.EnrollNo) In (SEECT BCA2ndyearTotalMarks.EnrollNo
FROM BCA2ndyearTotalMarks
WHERE (((BCA2ndyearTotalMarks.SumOIMarks) In (SEECT Max(SumOIMarks) AS MaxOISumOIMarks
FROM BCA2ndyearTotalMarks))))));
And the Iinal output oI Question 7 d
nroIINo $tudName FatherName
043701804 Debashis Ramesh

e) Find the number oI programs run in each college.
Answer
Here program and college is many to many relation
A program teach in many college and in a college many program available


CoIIeges
CoIIegeCode CoIIegeName Address ContactNo
C001 Adarsh Maha Vidyalaya Siliguri, West Bengal 035322669778
C002 SLGUR COLLEGE Siliguri , west bengal 0353236987
C003 KOLKATA COLLEGE KOLKAT , WEST BENGAL 0332569744

CoIIegeHasProgram
CoIIegeCode ProgCode
C001 BBA
C001 BCA
C001 BCOM
C001 BSC
C001 BTS
C001 DC
C001 MA
C001 MSc
C002 BBA
C002 BSC
C002 BTS
C002 MCA
SO, just count number oI program
SEECT CollegeCode, Count(ProgCode) AS CountOIProgCode FROM CollegeHasProgram GROUP BY
CollegeHasProgram.CollegeCode;
Number of Program in a CoIIege
CoIIegeCode CountOfProgCode
C001 8
C002 4
College Program Has N M


"uestion 8: (20 Marks)
Design two views Ior the database that you have designed and implemented. One view should be
Ior the University Vice Chancellor who is interested in knowing about the perIormance oI students
in various program and colleges. The other view is Ior a student who can view only his/her
inIormation. IdentiIy on what tables and what Iields these two will be allowed to have access.
Implement these views or write equivalent queries Ior the view deIining expression using SQ.
Answer:

In a access database we can create User and group oI user , and apply user level permission

Steps oI creation oI User


And create user under admin






Create a user ViceChancellor




Next crate a User group Students.


Now set permission for user and user groups




And select user 'iceChancellor and then chose query Object type and
select query Student Who Fail



And give Ok

,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,
And of assignment

I am Deepanjan Dey , from siliguri , west Bengal.
I solve this cause some of IGNO& student request me to solve this.

I also solve CS-64 assignment of BCA IGNO& 2011 and others.

Its give me pleasure to solve these assignment




This Assignment so tough that to complete I need 5 more than days

And it is near about to BCA project

Potrebbero piacerti anche