Student Management System
Student Management System
Student Management System
Chapter-1........................................................................................................................1
Introduction....................................................................................................................1
1.1 Introduction..........................................................................................................1
1.2 Features................................................................................................................1
Chapter-2........................................................................................................................2
ER-Design......................................................................................................................2
2.1 Entity Relationship Diagram................................................................................2
2.2 List of the Entity and Attributes...........................................................................3
Chapter-3........................................................................................................................4
Relational Database Design...........................................................................................4
3.1 Convert ER-Diagram to RDBMS........................................................................4
Chapter-4........................................................................................................................5
Execute MYSQL............................................................................................................5
4.1 Execute Create Statement....................................................................................5
4.2 Execute Insert and Select Statement....................................................................6
4.3 Execute Pattern matching (like Clause/ Wild Card)..........................................15
4.4 Aggregate Function:..........................................................................................18
4.5 Group by Clause:................................................................................................20
4.7 MYSQL Operator...............................................................................................24
4.8 MYSQL ALIAS:................................................................................................27
CHAPTER 5.................................................................................................................31
Conclusion....................................................................................................................31
i
Chapter-1
Introduction
1.1 Introduction
1.2 Features
1
Chapter-2
ER-Design
Ex. Enrolls in
2
2.2 List of the Entity and Attributes
Entity are; Student, university and course
Attributes; Sid, Sname, level, location, Uname, ESTD, Credit, Cname and Cid
Relationship; Enrolls in
3
Chapter-3
Relational Database Design
4
Chapter-4
Execute MYSQL
5
Cid int,
Foreign key (Sid) references student (Sid)
On delete cascade on update cascade,
Foreign key (Cid) references course (Cid)
On delete cascade on update cascade
);
6
Select * from student;
7
Insert record into Course
Insert into course (cid, cname, credit) value (21, 'Math', '43hrs');
Insert into course (cid, cname, credit) value (22, 'science', '32hrs');
Insert into course (cid, cname, credit) value (23, 'English', '20hrs');
Insert into course (cid, cname, credit) value (24, 'Social', '34hrs');
Insert into course (cid, cname, credit) value (25, 'Account', '32hrs');
Insert into course (cid, cname, credit) value (26, 'Economics', '13hrs');
Insert into course (cid, cname, credit) value (27, 'HRM', '43hrs');
Insert into course (cid, cname, credit) value (29, 'Nepali', '23hrs');
Insert into course (cid, cname, credit) value (28, 'Computer', '23hrs');
Insert into course (cid, cname, credit) value (30, 'population', '35hrs');
Insert into course (cid, cname, credit) value (31, 'Occupation', '33hrs');
Insert into course (cid, cname, credit) value (32, 'Health', '23hrs');
Insert into course (cid, cname, credit) value (33, 'GK', '32hrs');
Insert into course (cid, cname, credit) value (34, 'EPH', '34hrs');
Insert into course (cid, cname, credit) value (35, 'Math', '32hrs');
Insert into course (cid, cname, credit) value (36, 'Math', '23hrs');
Insert into course (cid, cname, credit) value (37, 'Math', '43hrs');
Insert into course (cid, cname, credit) value (39, 'Math', '23hrs');
Insert into course (cid, cname, credit) value (40, 'Math', '43hrs');
Insert into course (cid, cname, credit) value (41, 'Math', '23hrs');
Insert into course (cid, cname, credit) value (42, 'Math', '33hrs');
8
Select* From Course;
9
Insert record into Enrolls_in
Insert into Enrolls_in (sid, cid) value (1,21);
Insert into Enrolls_in (sid, cid) value (2,22);
Insert into Enrolls_in (sid, cid) value (3,23);
Insert into Enrolls_in (sid, cid) value (4,24);
Insert into Enrolls_in (sid, cid) value (5,25);
Insert into Enrolls_in (sid, cid) value (6,26);
Insert into Enrolls_in (sid, cid) value (7,27);
Insert into Enrolls_in (sid, cid) value (8,28);
Insert into Enrolls_in (sid, cid) value (9,29);
Insert into Enrolls_in (sid, cid) value (10,30);
Insert into Enrolls_in (sid, cid) value (11,31);
Insert into Enrolls_in (sid, cid) value (12,32);
Insert into Enrolls_in (sid, cid) value (13,33);
Insert into Enrolls_in (sid, cid) value (14,34);
Insert into Enrolls_in (sid, cid) value (15,35);
Insert into Enrolls_in (sid, cid) value (16,36);
Insert into Enrolls_in (sid, cid) value (17,37);
Insert into Enrolls_in (sid, cid) value (18,39);
Insert into Enrolls_in (sid, cid) value (19,40);
Insert into Enrolls_in (sid, cid) value (20,41);
10
Select*From Enrolls_in;
11
Insert record into University
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
12
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
Insert into University (Uname, Location, ESTD) value ('Everest',
'Thapathali', 2000);
13
Select* From University;
14
4.3 Execute Pattern matching (like Clause/ Wild Card)
Select* From Student where Sname like ‘E%’;
15
Select* From Student where Sname like ‘T%T’;
16
Select* From Course where cname like ‘s%’;
17
4.4 Aggregate Function:
Aggregate function is used to calculated a single value from a group of
values
Some aggregate function are Min, Max, Sum, Avg, Count and So on.
Syntax: Select aggregate function(attribute) From <tablename>;
Select count (sid) from student;
18
Select min(credit) From Course;
19
4.5 Group by Clause:
Its often used with aggregate function to group the result sets by one or
more column /attribute. In other word it is used for organizing similar
data into groups.
Syntax:
Select Column-name(s)/*,<aggregate function>from <tablename> where
condition group by <column-name>;
Select cname, count(cid) from course group by cname;
20
Select sname, count(sid) from student group by sname;
21
4.6 Update Statement:
Update student set level=’BCA’ where sid=’3’;
22
Update course set cname='Finance' where cid='22';
23
4.7 MYSQL Operator
Arthmetic Operator: +,-,*,/,%.
Comparison Operator:<, >, <=, >=,!=.
Logical Operator: AND, OR, NOT, Between.
24
Select cname, credit from course where credit='35hrs';
25
Select cname, credit from course where credit<='23hrs';
26
4.8 MYSQL ALIAS:
MYSQL Alisa are used to give table or attribute of temporary
name.
They are often used to make attribute name or table name more
readable. It only exist for duration of particular time.
Syntax:
Select<attributesname> as <aliasnameL> from <tablename>;
27
Select* from student as S;
28
Select cname as Cn from course;
29
Select sname as Sn from student;
30
CHAPTER 5
Conclusion
31