Sei sulla pagina 1di 3

create table mahasiswa(nim varchar(10) not null primary key, thn_masuk int not

null, nama varchar(30) not null);


create table matakuliah(kodekul varchar(10) not null primary key, kuliah
varchar(30) not null, sksteori int not null, sksprak int not null);
create table dosen(nip varchar(20) not null primary key, nama varchar(30) not
null);
create table krspraktikum(id_krsp varchar(10) not null, kodekul varchar(10) not
null, nim varchar(10) not null, kelas varchar(5) not null, nilai varchar(5) not
null, primary key(id_krsp,kodekul, nim), foreign key(kodekul) references
matakuliah(kodekul), foreign key(nim) references mahasiswa(nim));
create table krsteori(id_krst varchar(10) not null, kodekul varchar(10) not null,
nim varchar(10) not null, kelas varchar(5) not null, nilai varchar(5) not null,
primary key(id_krst,kodekul, nim), foreign key(kodekul) references
matakuliah(kodekul), foreign key(nim) references mahasiswa(nim));
create table kuliah_praktikum(idkp varchar(10) not null, kodekul varchar(10) not
null, nip varchar(5) not null, kelas varchar(5) not null, lab varchar(5) not null,
primary key(idkp ,kodekul, nip), foreign key(kodekul) references
matakuliah(kodekul), foreign key(nip) references dosen(nip));
create table kuliah_teori(idkt varchar(10) not null, kodekul varchar(10) not null,
nip varchar(5) not null, kelas varchar(5) not null, lab varchar(5) not null,
primary key(idkt ,kodekul, nip), foreign key(kodekul) references
matakuliah(kodekul), foreign key(nip) references dosen(nip));

insert into mahasiswa values ('200',1999,'Nita Mariani'),


('201',1999,'Fitria Lutfia'),
('202',2000,'Farhan Saleh'),
('234',2000,'Romi Amanda'),
('232',2000,'Emilia'),
('324',2000,'Fery Aryanto'),
('325',2000,'Miranda Jamil'),
('400',2001,'Astrina Damayanti'),
('425',2001,'Gogon Nandito'),
('426',2001,'Ananda Mirtani');

insert into dosen values ('006', 'Kusrini M.Kom'),


('067','Erik H.S, S.Kom'),
('068','Khusnawi, S.Kom'),
('056','Suyanto, MM');

insert into matakuliah values ('SD', 'Struktur Data',2,2),


('SPBD', 'Basis Data',2,2),
('MM', 'Mutimedia',2,0),
('PT', 'Pengenalan Pascal',0,2);

insert into kuliah_teori values ('KT001','SD','066','A','I'),


('KT002','SD','067','B','I'),
('KT003','SPBD','068','A','I'),
('KT004','SPBD','066','B','II'),
('KT005','MM','056','A','II');

insert into krsteori values ('KRST01','SD','200','A','40'),


('KRST02','SD','202','A','80'),
('KRST03','SD','234','B','50'),
('KRST04','SD','323','B','30'),
('KRST05','SPBD','200','A','15'),
('KRST06','SPBD','234','A','100'),
('KRST07','SPBD','324','B','25'),
('KRST08','SPBD','323','B','34'),
('KRST09','MM','324','A','65');
insert into kuliah_praktikum values ('KP001','SD','068','A','I'),
('KP002','SD','066','B','I'),
('KP003','SPBD','066','A','I'),
('KP004','SPBD','067','B','II'),
('KP005','PT','067','A','II');

insert into krspraktikum values ('KRSP01','SD','200','A','23'),


('KRSP02','SD','201','A','43'),
('KRSP03','SD','202','B','65'),
('KRSP04','SD','234','B','85'),
('KRSP05','SPBD','323','A','35'),
('KRSP06','SPBD','324','A','76'),
('KRSP07','SPBD','234','B','45'),
('KRSP08','PT','234','B','87'),
('KRSP09','PT','202','A','45');

create view krspraktikum_200 as select mahasiswa.nim, mahasiswa.nama,


krspraktikum.id_krsp,matakuliah.kuliah, matakuliah.sksprak, krspraktikum.nilai from
mahasiswa, matakuliah, krspraktikum where mahasiswa.nim=krspraktikum.nim and
matakuliah.kodekul=krspraktikum.kodekul and mahasiswa.nim='200';
create view krspraktikum_201 as select mahasiswa.nim, mahasiswa.nama,
krspraktikum.id_krsp,matakuliah.kuliah, matakuliah.sksprak, krspraktikum.nilai from
mahasiswa, matakuliah, krspraktikum where mahasiswa.nim=krspraktikum.nim and
matakuliah.kodekul=krspraktikum.kodekul and mahasiswa.nim='201';
create view krspraktikum_234 as select mahasiswa.nim, mahasiswa.nama,
krspraktikum.id_krsp,matakuliah.kuliah, matakuliah.sksprak, krspraktikum.nilai from
mahasiswa, matakuliah, krspraktikum where mahasiswa.nim=krspraktikum.nim and
matakuliah.kodekul=krspraktikum.kodekul and mahasiswa.nim='234';
create view krspraktikum_324 as select mahasiswa.nim, mahasiswa.nama,
krspraktikum.id_krsp,matakuliah.kuliah, matakuliah.sksprak, krspraktikum.nilai from
mahasiswa, matakuliah, krspraktikum where mahasiswa.nim=krspraktikum.nim and
matakuliah.kodekul=krspraktikum.kodekul and mahasiswa.nim='324';
create view krspraktikum_202 as select mahasiswa.nim, mahasiswa.nama,
krspraktikum.id_krsp,matakuliah.kuliah, matakuliah.sksprak, krspraktikum.nilai from
mahasiswa, matakuliah, krspraktikum where mahasiswa.nim=krspraktikum.nim and
matakuliah.kodekul=krspraktikum.kodekul and mahasiswa.nim='202';
select*from krspraktikum_200;
select*from krspraktikum_201;
select*from krspraktikum_234;
select*from krspraktikum_324;
select*from krspraktikum_202;

create view krsteori_200 as select mahasiswa.nim, mahasiswa.nama, krsteori.id_krst,


matakuliah.kuliah,matakuliah.sksteori, krsteori.nilai from mahasiswa, matakuliah,
krsteori where mahasiswa.nim=krsteori.nim and matakuliah.kodekul=krsteori.kodekul
and mahasiswa.nim='200';
create view krsteori_202 as select mahasiswa.nim, mahasiswa.nama, krsteori.id_krst,
matakuliah.kuliah,matakuliah.sksteori, krsteori.nilai from mahasiswa, matakuliah,
krsteori where mahasiswa.nim=krsteori.nim and matakuliah.kodekul=krsteori.kodekul
and mahasiswa.nim='202';
create view krsteori_234 as select mahasiswa.nim, mahasiswa.nama, krsteori.id_krst,
matakuliah.kuliah,matakuliah.sksteori, krsteori.nilai from mahasiswa, matakuliah,
krsteori where mahasiswa.nim=krsteori.nim and matakuliah.kodekul=krsteori.kodekul
and mahasiswa.nim='234';
create view krsteori_323 as select mahasiswa.nim, mahasiswa.nama, krsteori.id_krst,
matakuliah.kuliah,matakuliah.sksteori, krsteori.nilai from mahasiswa, matakuliah,
krsteori where mahasiswa.nim=krsteori.nim and matakuliah.kodekul=krsteori.kodekul
and mahasiswa.nim='323';
create view krsteori_324 as select mahasiswa.nim, mahasiswa.nama, krsteori.id_krst,
matakuliah.kuliah,matakuliah.sksteori, krsteori.nilai from mahasiswa, matakuliah,
krsteori where mahasiswa.nim=krsteori.nim and matakuliah.kodekul=krsteori.kodekul
and mahasiswa.nim='324';
select*from krsteori_200;
select*from krsteori_202;
select*from krsteori_234;
select*from krsteori_323;
select*from krsteori_324;

create view rekap_dosen_teori_066 as select dosen.nip, dosen.nama,


matakuliah.kodekul, matakuliah.kuliah, matakuliah.sksteori from dosen,
matakuliah,kuliah_teori where kuliah_teori.nip=dosen.nip and
kuliah_teori.kodekul=matakuliah.kodekul and dosen.nip='066';
create view rekap_dosen_teori_068 as select dosen.nip, dosen.nama,
matakuliah.kodekul, matakuliah.kuliah, matakuliah.sksteori from dosen,
matakuliah,kuliah_teori where kuliah_teori.nip=dosen.nip and
kuliah_teori.kodekul=matakuliah.kodekul and dosen.nip='068';
create view rekap_dosen_praktikum_066 as select dosen.nip, dosen.nama,
matakuliah.kodekul, matakuliah.kuliah, matakuliah.sksprak from dosen,
matakuliah,kuliah_praktikum where kuliah_praktikum.nip=dosen.nip and
kuliah_praktikum.kodekul=matakuliah.kodekul and dosen.nip='066';
create view rekap_dosen_praktikum_068 as select dosen.nip, dosen.nama,
matakuliah.kodekul, matakuliah.kuliah, matakuliah.sksprak from dosen,
matakuliah,kuliah_praktikum where kuliah_praktikum.nip=dosen.nip and
kuliah_praktikum.kodekul=matakuliah.kodekul and dosen.nip='068';
//create view rekap_dosen_teori_dan_praktikum_066 as select dosen.nip, dosen.nama,
matakuliah.kodekul, matakuliah.kuliah, matakuliah.sksteori, matakuliah.sksprak from
dosen, matakuliah,kuliah_teori, kuliah_praktikum where kuliah_teori.nip=dosen.nip
and kuliah_teori.kodekul=matakuliah.kodekul and kuliah_praktikum.nip=dosen.nip and
kuliah_praktikum.kodekul=matakuliah.kodekul and dosen.nip='066';
//create view rekap_dosen_teori_dan_praktikum_068 as select dosen.nip, dosen.nama,
matakuliah.kodekul, matakuliah.kuliah, matakuliah.sksteori, matakuliah.sksprak from
dosen, matakuliah,kuliah_teori, kuliah_praktikum where kuliah_teori.nip=dosen.nip
and kuliah_teori.kodekul=matakuliah.kodekul and kuliah_praktikum.nip=dosen.nip and
kuliah_praktikum.kodekul=matakuliah.kodekul and dosen.nip='068';
select*from rekap_dosen_teori_066;
select*from rekap_dosen_teori_068;
select*from rekap_dosen_praktikum_066;
select*from rekap_dosen_praktikum_068;
//select*from rekap_dosen_teori_dan_praktikum_066;
//select*from rekap_dosen_teori_dan_praktikum_068;

select dosen.nip, dosen.nama, matakuliah.kodekul, matakuliah.kuliah,


matakuliah.sksteori, matakuliah.sksprak from dosen, matakuliah,kuliah_teori,
kuliah_praktikum where (kuliah_teori.nip=dosen.nip and
kuliah_teori.kodekul=matakuliah.kodekul and dosen.nip='066') or
(kuliah_praktikum.nip=dosen.nip and kuliah_praktikum.kodekul=matakuliah.kodekul and
dosen.nip='066');