Program Basis Data
Laporan Praktikum
Disusun Oleh : Amanda Dwie Kartika
2170231039
Laporan Akhir Praktikum Basis data
Fakultas Teknik Prodi Informatika 2021
MODUL 1
3.Select version (), CURRENT_DATE
4.Ketikan perintah diatas (nomor 3) : - Dengan huruf kecil semua - Dengan huruf besar semua
5.Select SIN (PI () /4), (4+1)*5;
6.Select version (); Select now ();
7.Mysql > Select ->USER () ->,
->CURRENT_DATER;
8. MYsql > Select ->User () ->\c
9.MySQL>SELECT USER () Apa yang terjadi
Kemudian Ketikan:
-> ;
Apa yang terjadi ?
10. MySQL>SHOW DATABASES;
11.MySQL>USE TEST
12.MySQL>USE COBA
13.MySQL>CREATE DATABASE coba;
MySQL>use coba;
MySQL>show tables;
14.MySQL>CREATE TABLE buku (kodebuku CHAR (5) PRIMARY KEY NOT NULL, -> judul VARCHAR (25) NOT NULL, pengarang VARCHAR (20),
-> penerbit VARCHAR (15) , kategori VARCHAR (15));
15.MySQL>desc buku;
MODUL 2
1.Buatlah sebuah database dengan nama db_universitas atau db_nama_mhs 2.Buatlah beberapa tabel dalam database tersebut sesuai dengan kriteria berikut :
A. Table Mahasiswa
B. Table Prodi
C. Table Mata Kuliah
D. Table Ruang
E. Table Dosen
F. Table Mengajar
G. Table Nilai
MODUL 3
1. Aktifkan database db_universitas atau db_nama_mahasiswa.
2. Isikan data – data (record) ke dalam tabel mahasiswa :
Source Code
>INSERT into mahasiswa VALUES ('13120001', 'Anton', 'L', 'Jl. Jenderal Sudirman No.12', 'Brebes', 'SMA 1 Brebes', '081574568921', 'anton', 'anton', '18',
‟S1 IF‟), ('13120002', 'Bany', 'L', 'Jl. Letnan Jenderal Sutoyo No.15','Tegal', 'SMA 1 Tegal', '081574568346', 'bany', 'bany', '18', ‟S1 IF‟),('13120003', 'Cika', 'P', 'Jl. Jenderal Sudirman No.38', 'Purwokerto', 'SMA 4 Purwokerto', '081874568000', 'cika','cika', '17',‟S1 IF‟), ('13120004', 'Doni','L', 'Jl. Pahlawan No. 4', 'Brebes', 'SMK N 1 Adiwerna', '081674568900', 'doni', 'doni', '19', ‟S1 TT‟), ('13120005', 'Eka', 'P', 'Jl. Buntu No.01','Pekalongan', 'SMA 3 Pekalongan', '088874568945', 'eka', 'eka', '17', ‟S1 TT‟), ('13120006', 'Fendi', 'L', 'Jl.
Kemerdekaan No.15', 'Pemalang', 'SMA 1Pemalang', '081257456892', 'fendi', 'fendi', '18', ‟D3 TT‟), ('13120007','Galuh', 'P', 'Jl. Mawar Putih', 'Brebes', 'SMA 2 Brebes', '081273458921', 'galuh', 'galuh', '18', ‟D1 PR‟); select*from student;
3. Isikan data berikut ke dalam tabel dosen :
Source Code
>Source code: INSERT into dosen VALUES ('1', 'DS', 'Didi Supriyadi', 'T', 'L', 'Islam', 'didi', 'didi', 'Jl. Sunan Bonang RT 01/03 Banjaranyar', 'Brebes', '[email protected]', '085743622236', '5000000'), ('2',' STS', 'Sisilia Thya Safitri', 'T', 'P', 'Kristen', 'sisil', 'sisil', 'Jl. Antah berantah RT 001/005 Banjarbaru', 'Jambi', '[email protected]', '085875997546', '5000000'), ('3', 'TW', 'Tenia Wahyuningrum', 'T', 'P', 'Islam', 'tenia', 'tenia', 'Jl.
Ledug RT 01/03 Banyumas', 'Purwokerto', '[email protected]', '085746795432', '5500000'), ('4', 'DJ', 'Dwi Januarita AK', 'T', 'P', 'Islam',
'ita', 'ita', 'Jl. Sunan Kudus RT 01/03 Jekulo', 'Kudus', '[email protected]', '085852829809', '4000000'), ('5', 'IS', 'Irwan Susanto', 'T', 'L', 'Islam', 'irwan', 'irwan', 'Jl. Tanjung RT 01/03 Banyumas', 'Purwokerto', '[email protected]', '081327593529', '5500000'), ('6', 'SL', 'Sarlan', 'LB', 'L', 'Islam', 'sarlan', 'sarlan', 'Jl. Jend. SudirmanRT 01/03 Banyumas', 'Purwokerto', '[email protected]', '081634462738', '3500000'), ('7', 'DN', 'Daniel', 'LB', 'L', 'Kristen', 'daniel', 'daniel', 'Jl. Tanjung RT 04/07 Banyumas', 'Purwokerto', '[email protected]', '081365047309', '4500000');
>Select*from dosen;
4. Lakukan Insert data ke tabel – tabel lain sesuai dengan field, type data da panjang datanya masing – masing tabel;
A. Insert records/data to table prodi
Source Code
>Source code: INSERT INTO prodi VALUES ->(‘D1 IF’, ‘Informatika’),
->(‘D3 PR’, ‘ Sipil’), ->(‘S1 IF’, ‘Informatika’), ->(‘S1 IT’, ‘Teknik Teknik’);
>select * from prodi;
B. Insert records/data to table mata_kuliah.
Souce Code
>INSERT INTO mata_kuliah VALUES -> (‘MAV’, ‘MATRIKS’, ’26,66’, ‘2’),
-> (‘SSD’, ‘STRUKTUR DATA’, ’26.66’, ‘2’),
-> (‘PAI’, ‘PENDIDIKAN AGAMA ISLAM’, ’26.66’, ‘2’), -> (‘ENG’, ‘ENGLISH’, ’26,66’, ‘2’);
>select * from mata_kuliah;
C. Insert records/data to table ruang
Souce Code
>INSERT INTO ruang VALUES ->(‘001’,’PERPUSTAKAAN’,’30’), ->(‘002’, ‘KELAS’, ‘50’),
->(‘003’, ‘LAB’, ‘40’),
->(’004’, ‘RUANG DOSEN’, ‘10’);
> select * from ruang;
D. Insert records/data to table mengajar.
Source Code
>INSERT INTO mengajar VALUES ('7625','10','rabu','PAI','TW','S1 IF','001'), ('7626','8','selasa','MAV','STS','D1 IF','002'), ('7627','10'.'jumat','PAI','TW','D3 PR','003'), ('7628','12','kamis','SSD','DJ','S1 TT','004');
>select*from mengajar;
E. Insert records/data to table nilai
Souce Code
>INSERT INTO nilai VALUES
('1312001','PAI','S1 IF','TW','80','85','90'), ('1312002','MAV','D1 IF','STS','75','85','95'), ('1312003','PAI','D3 PR','TW','70','90','86'), ('1312004','SSD','S1 TT','DJ','80','90','95');
>select*from nilai;
MODUL 4
C. Tampilkan mahasiswa laki – laki yang berasal dari Purwokerto
Source Code
>select*from mahasiswa where sex like ‘L’ and kota like ‘purwokerto’;
D. Tampilkan mahasiswa wanita dari Purwokerto dan Jakarta.
Souce Code
>select*from mahasiswa where sex like ‘P’ and kota like ‘purwokerto’ and ‘jakarta’;
E.Tampilkan mahasiswa yang bukan berasal dari Purwokerto.
Souce Code
F.Tampilkan seluruh mahasiswa menurut abjad dari Z – A
Source Code
>slect nama_mhss,kota from mahasiswa where not kota like “purwokerto”;
>select*from mahasiswa order by nama_mhs desc;
G.Berasal dari kota mana saja mahasiswa yang ada? (hilangkan data kota yang duplikasi)
Souce Code
i. Tampilkan daftar nama mahasiswa, kode prodi dan umur yang usianya tidak diantara 18 dan 19.
Source Code
J. Tampilkan nama dosen yang jumlah gajinya antara 4.500.000 sampai 5.500.000.
Source Code
K. Cari nama mahasiswa yang tempat tinggalnya dimulai dengan ‘P’.
Source Code
>Select nama_mhs, kota from mahasiswa where not kota like “brebes”;
>select nama_mhs, kode_prodi, umur from mahasiswa where not umur between 18 and 19;
>select nama_dosen,salary frim disen where salary between 4500000 and 5000000;
>select distinct kota from mahasiswa;
ii. Tampilkan daftar nama mahasiswa, kode prodi dan umur yang usianya tidak diantara 18 dan 19.
Source Code
L. Tampilkan nama dosen yang jumlah gajinya antara 4.500.000 sampai 5.500.000.
Source Code
M. Cari nama mahasiswa yang tempat tinggalnya dimulai dengan ‘P’.
Source Code
>select nama_mhs, kode_prodi, umur from mahasiswa where not umur between 18 and 19;
>select nama_dosen,salary frim disen where salary between 4500000 and 5000000;
>select distinct kota from mahasiswa;
N.Carilah nama mahasiswa yang tempat tinggalnya ditengahnya terdapat kata ‘kalong
Source Code
J. Carilah nama dosen, inisial yang inisial namanya diawali dengan huruf ‘S’.
Source Code
>select nama_mhs, kota from mahasiswa where kota like ‘%kalong%’;
>select inisial from dosen where inisial like ‘s%’;
TUGAS PRAKTIKUM 1
1. Tabel Pasien
2. Tabel Dokter
3. Tabel Obat
create database db_rumah_sakit;
use db_rumah_sakit;
create table petugas_medis (
->Id_petugas_medis char(10) Primary Key NOT NULL, ->Nama_petugas_medis varchar(30));
desc petugas_medis;
TUGAS PRAKTIKUM 2
1. Create database and use database db_rumah_sakit - Source code:
2. Create table petugas_medis - Source code:
create table petugas_loket (
->Id_petugas_loket char(10) Primary Key NOT NULL, ->Nama_petugas_loket varchar(25));
desc petugas_loket;
3. Create table apoteker - Source code:
4. Create table petugas_loket - Source code:
create table apoteker (
->Id_apoteker char(10) Primary Key NOT NULL, ->Nama_apoteker varchar(30));
desc apoteker;
create table dokter (
->Id_dokter char(10) Primary Key NOT NULL, ->Nama_dokter varchar(30),
->Spesialis varchar(30), ->Id_petugas_medis char(10),
->foreign key (Id_petugas_medis) references petugas_medis(Id_petugas_medis));
desc dokter;
5. Create table dokter - Source code:
6. Create table obat - Source code:
create table obat (
->Kode_obat char(10) Primary Key NOT NULL, ->Nama_obat varchar(20),
->Jenis_obat varchar(20), ->Masa_kadaluarsa date, ->Harga integer,
->Id_apoteker char(10),
->foreign key (Id_apoteker) references apoteker(Id_apoteker));
desc obat;
7. Create table pasien - Source Code:
create table pasien (
->Id_pasien char(10) Primary Key NOT NULL,Nama_pasien varchar(30),Umur integer,Keluhan_pasien varchar(30),
->Id_dokter char(10),
->foreign key fk1 (Id_dokter) references dokter(Id_dokter), ->Kode_obat char(10),
->foreign key fk2 (Kode_obat) references obat(Kode_obat), ->Id_petugas_loket char(10),
->foreign key fk3 (Id_petugas_loket) references ->petugas_loket(Id_petugas_loket));
desc pasien;
8. Insert into petugas_medis - Source Code:
insert into petugas_medis values ('MDS-301', 'Layla'), ('MDS-302', 'Miya');
select * from petugas_medis;
9. Insert into apoteker - Source Code:
10. Insert into petugas_loket - Source Code:
insert into apoteker values ('APK-701', 'Rayi'), ('APK-702', 'Asta'), ('APK-703', 'Nino');
select * from apoteker;
insert into petugas_loket values ('AD-101', 'Miranda');
select * from petugas_loket;
11. Insert into dokter - Source Code:
12. Insert into obat - Source Code:
insert into dokter values ('DR-501', 'Mirana', 'THT', 'MDS-301'), ('DR-502', 'Antonio', 'Penyakit dalam', 'MDS-302'), ('DR-503', 'Bima', 'Umum', 'MDS-302');
select * from dokter;
insert into obat values ('MDC-201', 'Dexamethasone', 'Radang', '2025-05-25', '25000', 'APK-701'), ('MDC-202', 'Amlodipine', 'Darah tinggi', '2025-05-25', '52000', 'APK-702'), ('MDC-203', 'Diapet', 'Diare', '2025-05-25', '15000', 'APK- 703');
select * from obat;
13. Insert into pasien - Source Code:
14. Select Nama_pasien, Umur, Keluhan_pasien - Source Code:
15. Select Id_dokter, Nama_dokter, Spesialis - Source Code:
insert into pasien values ('P-101', 'Yudha', '22', 'Radang', 'DR-501', 'MDC-201', 'AD-101'), ('P-102', 'Nia', '27', 'Darah tinggi', 'DR-502', 'MDC-202', 'AD-101'), ('P-103', 'Agung', '20', 'Diare', 'DR-503', 'MDC-203', 'AD-101');
select * from pasien;
select Nama_pasien, Umur, Keluhan_pasien FROM pasien WHERE Umur LIKE '27';
select Id_dokter, Nama_dokter, Spesialis FROM dokter WHERE Spesialis IN ("THT", "Penyakit dalam");
16. Select Nama_obat, Jenis_obat, Masa_kadaluarsa - Source Code:
17. Select 3 tabel jadi 1 tabel - Source Code:
18. Select Nama_obat dari harga terkecil ke terbesar - Source Code:
select Nama_obat, Jenis_obat, Masa_kadaluarsa FROM obat WHERE Jenis_obat NOT LIKE 'Diare';
select pasien.Id_pasien pasien.Id_dokter,,
selec
pasien.Nama_pasien ,
pasien.Keluhan_pasien, pasien.Nama_pasien, pasien.Keluhan_pasien, pasien.Id_dokter, obat.Nama_obat FROM pasien,
dokter,
obat WHERE pasien.Id_dokter=dokter.Id_dokter AND
select Nama_obat, Harga FROM obat ORDER BY Harga ASC;