Sei sulla pagina 1di 4

create database attendance;

use attendance;
drop table branch;
create table branch(branch_id int not null auto_increment , branch_name varchar(
5) not null, primary key (branch_id));
insert into branch (branch_id,branch_name) values(1,"CSE");
insert into branch (branch_id,branch_name) values(2,"ECE");
insert into branch (branch_id,branch_name) values(3,"EIE");
insert into branch (branch_id,branch_name) values(4,"IT");
desc branch;
select * from branch;
drop table section;
create table section(section_id int not null auto_increment , section_name varch
ar(1)not null, primary key (section_id));
insert into section (section_id,section_name) values(1,"A");
insert into section (section_id,section_name) values(2,"B");
insert into section (section_id,section_name) values(3,"C");
insert into section (section_id,section_name) values(4,"D");
insert into section (section_id,section_name) values(5,"E");
desc section;
select * from section;
drop table each_class;
create table each_class (class_id int not null auto_increment ,branch_id int ,se
ction_id int , constraint fk_bi foreign key (branch_id) references branch(branch
_id), constraint fk_si foreign key (section_id) references section(section_id) ,
primary key (class_id));
insert into each_class (class_id,branch_id,section_id) values (1,1,1);
insert into each_class (class_id,branch_id,section_id) values (2,1,2);
insert into each_class (class_id,branch_id,section_id) values (3,1,3);
insert into each_class (class_id,branch_id,section_id) values (4,2,1);
insert into each_class (class_id,branch_id,section_id) values (5,3,1);
insert into each_class (class_id,branch_id,section_id) values (6,4,1);
desc each_class;
select * from each_class;
drop table student ;
create table student (student_roll_no int not null,primary key (student_roll_no,
class_id) ,student_name varchar(100) not null,class_id int ,constraint fk_ci for
eign key (class_id) references each_class(class_id));
insert into student values(1,"a",1);
insert into student values(2,"b",1);
insert into student values(3,"c",1);
insert into student values(4,"d",1);
insert into student values(5,"e",1);
insert into student values(1,"a",2);
insert into student values(2,"b",2);
insert into student values(3,"c",2);
insert into student values(4,"d",2);
insert into student values(5,"e",2);
insert into student values(1,"a",3);
insert into student values(2,"b",3);
insert into student values(3,"c",3);
insert into student values(4,"d",3);
insert into student values(5,"e",3);
insert into student values(1,"a",4);
insert into student values(2,"b",4);
insert into student values(3,"c",4);
insert into student values(4,"d",4);
insert into student values(5,"e",4);
insert into student values(1,"a",5);

insert into student values(2,"b",5);


insert into student values(3,"c",5);
insert into student values(4,"d",5);
insert into student values(5,"e",5);
insert into student values(1,"a",6);
insert into student values(2,"b",6);
insert into student values(3,"c",6);
insert into student values(4,"d",6);
insert into student values(5,"e",6);
desc student;
select * from student;
create table subject (subject_id int not null auto_increment , subject_name varc
har(50) not null, primary key(subject_id));
insert into subject values (1,"Operating Systems");
insert into subject values (2,"Computer Networks");
insert into subject values (3,"Compiler Design");
insert into subject values (4,"Software Engineering");
insert into subject values (5,"Principles of Programming Languages");
insert into subject values (6,"Intellectual Property Rights");
create table lecturer (lecturer_id int not null auto_increment , class_id int ,
subject_id int ,constraint fk_sii foreign key (subject_id) references subject(s
ubject_id) ,constraint fk_cii foreign key (class_id) references each_class(class
_id),primary key(lecturer_id,class_id,subject_id) );
insert into lecturer values (1,1,1);
insert into lecturer values (1,2,1);
insert into lecturer values (1,3,1);
insert into lecturer values (1,4,1);
insert into lecturer values (1,5,1);
insert into lecturer values (1,6,1);
insert into lecturer values (2,1,2);
insert into lecturer values (2,2,2);
insert into lecturer values (2,3,2);
insert into lecturer values (2,4,2);
insert into lecturer values (2,5,2);
insert into lecturer values (2,6,2);
insert into lecturer values (3,1,3);
insert into lecturer values (3,2,3);
insert into lecturer values (3,3,3);
insert into lecturer values (3,4,3);
insert into lecturer values (3,5,3);
insert into lecturer values (3,6,3);
insert into lecturer values (4,1,4);
insert into lecturer values (4,2,4);
insert into lecturer values (4,3,4);
insert into lecturer values (4,4,4);
insert into lecturer values (4,5,4);
insert into lecturer values (4,6,4);
insert into lecturer values (5,1,5);
insert into lecturer values (5,2,5);
insert into lecturer values (5,3,5);
insert into lecturer values (5,4,5);
insert into lecturer values (5,5,5);
insert into lecturer values (5,6,5);
insert into lecturer values (6,1,6);
insert into lecturer values (6,2,6);
insert into lecturer values (6,3,6);
insert into lecturer values (6,4,6);
insert into lecturer values (6,5,6);
insert into lecturer values (6,6,6);
create table period (period_id int auto_increment not null,the_date date not nul

l,lecturer_id int,class_id int ,primary key(period_id) , constraint fk_li forei


gn key (lecturer_id) references lecturer(lecturer_id) ,constraint fk_ciii foreig
n key (class_id) references each_class(class_id) );
insert into period (the_date,lecturer_id,class_id) values (curdate(),1,1);
insert into period (the_date,lecturer_id,class_id) values (curdate(),2,1);
insert into period (the_date,lecturer_id,class_id) values (curdate(),3,1);
insert into period (the_date,lecturer_id,class_id) values (curdate(),4,1);
insert into period (the_date,lecturer_id,class_id) values (curdate(),5,1);
insert into period (the_date,lecturer_id,class_id) values (curdate(),6,1);
insert into period (the_date,lecturer_id,class_id) values (curdate(),1,2);
insert into period (the_date,lecturer_id,class_id) values (curdate(),2,2);
insert into period (the_date,lecturer_id,class_id) values (curdate(),3,2);
insert into period (the_date,lecturer_id,class_id) values (curdate(),4,2);
insert into period (the_date,lecturer_id,class_id) values (curdate(),5,2);
insert into period (the_date,lecturer_id,class_id) values (curdate(),6,2);
insert into period (the_date,lecturer_id,class_id) values (curdate(),1,3);
insert into period (the_date,lecturer_id,class_id) values (curdate(),2,3);
insert into period (the_date,lecturer_id,class_id) values (curdate(),3,3);
insert into period (the_date,lecturer_id,class_id) values (curdate(),4,3);
insert into period (the_date,lecturer_id,class_id) values (curdate(),5,3);
insert into period (the_date,lecturer_id,class_id) values (curdate(),6,3);
insert into period (the_date,lecturer_id,class_id) values (curdate(),1,4);
insert into period (the_date,lecturer_id,class_id) values (curdate(),2,4);
insert into period (the_date,lecturer_id,class_id) values (curdate(),3,4);
insert into period (the_date,lecturer_id,class_id) values (curdate(),4,4);
insert into period (the_date,lecturer_id,class_id) values (curdate(),5,4);
insert into period (the_date,lecturer_id,class_id) values (curdate(),6,4);
insert into period (the_date,lecturer_id,class_id) values (curdate(),1,5);
insert into period (the_date,lecturer_id,class_id) values (curdate(),2,5);
insert into period (the_date,lecturer_id,class_id) values (curdate(),3,5);
insert into period (the_date,lecturer_id,class_id) values (curdate(),4,5);
insert into period (the_date,lecturer_id,class_id) values (curdate(),5,5);
insert into period (the_date,lecturer_id,class_id) values (curdate(),6,5);
insert into period (the_date,lecturer_id,class_id) values (curdate(),1,6);
insert into period (the_date,lecturer_id,class_id) values (curdate(),2,6);
insert into period (the_date,lecturer_id,class_id) values (curdate(),3,6);
insert into period (the_date,lecturer_id,class_id) values (curdate(),4,6);
insert into period (the_date,lecturer_id,class_id) values (curdate(),5,6);
insert into period (the_date,lecturer_id,class_id) values (curdate(),6,6);
select * from period;
desc period;
desc student;
create table attendance (attendance_id int not null auto_increment , primary key
(attendance_id) ,period_id int , student_roll_no int ,attendance_status tinyint(
1) , constraint fk_ppi foreign key (period_id) references period(period_id) , co
nstraint fk_lsi foreign key (student_roll_no) references student(student_roll_no
) );
insert into attendance (period_id,student_roll_no,attendance_status) values(1,1,
0);
insert into attendance (period_id,student_roll_no,attendance_status) values(1,2,
1);
insert into attendance (period_id,student_roll_no,attendance_status) values(1,3,
1);
insert into attendance (period_id,student_roll_no,attendance_status) values(1,4,
1);
insert into attendance (period_id,student_roll_no,attendance_status) values(1,5,
0);
insert into attendance (period_id,student_roll_no,attendance_status) values(2,1,
0);
insert into attendance (period_id,student_roll_no,attendance_status) values(2,2,

1);
insert into attendance (period_id,student_roll_no,attendance_status) values(2,3,
1);
insert into attendance (period_id,student_roll_no,attendance_status) values(2,4,
1);
insert into attendance (period_id,student_roll_no,attendance_status) values(2,5,
0);