Nama : Ririn Endah Palupi
Kelas : MI 12-09(Sem-2)
Dosen : Sundari Retno,S.KOM
Selamat malam semuanya,,baiklah saya akan langsung menjelaskan materi ini,kembali diperjelas contoh ini minggu kemari saya memberikan penjelasan tentang pengertian cross join ,dan outer join.Begitu juga saya telah memberikan contohnya yang berupa one to one,one to many,selanjutnya ,saya mebuat contoh many to many,Dan inilah contoh many to many dgn cross coin ,outer join:
create database Data_Nilai
use Data_Nilai
create table Mahasiswa(
NIM
char(12)not null primary key,
Nama
varchar(25),
Agama
varchar(9),
Alamat
varchar(25),
Jenkel
char(1))
select * from Mahasiswa
Insert into Mahasiswa
values('201201030181','Ririn,S','Kristen','Jl.Melanthon Siregar','P')
Insert into Mahasiswa
values('201201030182','Risky,N','Islam','Jl.Rindam','P')
Insert into Mahasiswa
values('201201030183','Ricardo,H','Kristen','Jl.Tanahjawa','L')
Insert into Mahasiswa
values('201201030184','Romega,D','Kristen','Jl.Sibayak','P')
Insert into Mahasiswa
values('201201030185','Susvawega,N','Islam','Jl.Nagahuta','P')
create table Mahasiswa_1(
NIM
char(12)references Mahasiswa (NIM),
Nama
varchar(25),
Agama
varchar(9),
Alamat
varchar(25),
Jenkel
char(1))
select * from Mahasiswa_1
Insert into Mahasiswa_1
values('201201030181','Ririn,S','Kristen','Jl.Melanthon Siregar','P')
Insert into Mahasiswa_1
values('201201030182','Risky,N','Islam','Jl.Rindam','P')
Insert into Mahasiswa_1
values('201201030183','Ricardo,H','Kristen','Jl.Tanahjawa','L')
Insert into Mahasiswa_1
values('201201030184','Romega,D','Kristen','Jl.Sibayak','P')
Insert into Mahasiswa_1
values('201201030185','Susvawega,N','Islam','Jl.Nagahuta','P')
create table Mata_Kuliah(
Kode_Matkul
char(3) not null primary key,
Nama_Matkul
varchar(25))
select *from Mata_Kuliah
insert into Mata_Kuliah
values('M01','Manajemen')
insert into Mata_Kuliah
values('M02','Akuntansi')
insert into Mata_Kuliah
values('M03','Bahasa Inggris')
insert into Mata_Kuliah values('M04','Pengolah
Citra')
insert into Mata_Kuliah
values('M05','Database')
create table Mata_Kuliah_1(
Kode_Matkul
char(3)references Mata_Kuliah(Kode_Matkul),
Nama_Matkul
varchar(25))
select *from Mata_Kuliah_1
insert into Mata_Kuliah_1
values('M01','Manajemen')
insert into Mata_Kuliah_1
values('M02','Akuntansi')
insert into Mata_Kuliah_1
values('M03','Bahasa Inggris')
insert into Mata_Kuliah_1
values('M04','Pengolah Citra')
insert into Mata_Kuliah_1
values('M05','Database')
create table KRS(
Id_KRS
char(4) not null primary key,
NIM
char(12)references Mahasiswa(NIM),
Kode_Matkul
char(3) references Mata_Kuliah(Kode_Matkul))
select *from KRS
Insert into KRS
values('DB01','201201030183','M01')
Insert into KRS
values('DB02','201201030181','M01')
Insert into KRS
values('DB03','201201030183','M02')
Insert into KRS
values('DB04','201201030184','M03')
Insert into KRS
values('DB05','201201030185','M05')
Insert into KRS
values('DB06','201201030182','M04')
GAMBARAN KODE CROSS JOIN & OUTER JOIN
select * from Mahasiswa cross
join Mata_kuliah cross join KRS
select
M.Nama,M.Jenkel,MK.Nama_Matkul from Mahasiswa M inner join Mata_Kuliah MK inner
join KRS K on K.NIM = K.NIM on K.Kode_Matkul = K.Kode_Matkul
select
M.Nama,M.Jenkel,MK.Nama_Matkul from Mahasiswa M left outer join Mata_Kuliah MK
left outer join KRS K on K.NIM = K.NIM on K.Kode_Matkul = K.Kode_Matkul
select
M.Nama,M.Jenkel,MK.Nama_Matkul from Mahasiswa M right outer join Mata_Kuliah MK
left outer join KRS K on K.NIM = K.NIM on K.Kode_Matkul = K.Kode_Matkul
select
M.Nama,M.Jenkel,MK.Nama_Matkul from Mahasiswa M full outer join Mata_Kuliah MK
left outer join KRS K on K.NIM= K.NIM on K.Kode_Matkul = K.Kode_Matkul
Sekian dulu yah tugas saya buat,semoga bermanfaat,,. :)
Tidak ada komentar :
Posting Komentar