Nama: Ali Fahrial Anwar NIM: 201951256 Kelas: G Tugas Praktikum
Nama: Ali Fahrial Anwar NIM: 201951256 Kelas: G Tugas Praktikum
Nama: Ali Fahrial Anwar NIM: 201951256 Kelas: G Tugas Praktikum
NIM : 201951256
Kelas :G
TUGAS PRAKTIKUM
1. a. Tabel Karyawan
b. Tabel Customer
c. Tabel Jenis Buku
d. Tabel Buku
e. Tabel TrHeaderPeminjaman
f. Tabel TrDetailPeminjaman
Scriptnya
-- phpMyAdmin SQL Dump
-- version 4.9.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 20, 2020 at 08:00 AM
-- Server version: 10.4.8-MariaDB
-- PHP Version: 7.3.11
--
-- Database: `modul2`
--
-- --------------------------------------------------------
--
-- Table structure for table `msbuku`
--
--
-- Dumping data for table `msbuku`
--
-- --------------------------------------------------------
--
-- Table structure for table `mscustomer`
--
--
-- Dumping data for table `mscustomer`
--
-- --------------------------------------------------------
--
-- Table structure for table `msjenisbuku`
--
--
-- Dumping data for table `msjenisbuku`
--
-- --------------------------------------------------------
--
-- Table structure for table `mskaryawan`
--
--
-- Dumping data for table `mskaryawan`
--
--
-- Table structure for table `trdetailpeminjaman`
--
--
-- Dumping data for table `trdetailpeminjaman`
--
-- --------------------------------------------------------
--
-- Table structure for table `trheaderpeminjaman`
--
--
-- Dumping data for table `trheaderpeminjaman`
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `msbuku`
--
ALTER TABLE `msbuku`
ADD PRIMARY KEY (`KDBUKU`),
ADD KEY `FK_KDJENISBUKU` (`KDJENISBUKU`);
--
-- Indexes for table `mscustomer`
--
ALTER TABLE `mscustomer`
ADD PRIMARY KEY (`KDCUSTOMER`);
--
-- Indexes for table `msjenisbuku`
--
ALTER TABLE `msjenisbuku`
ADD PRIMARY KEY (`KDJENISBUKU`);
--
-- Indexes for table `mskaryawan`
--
ALTER TABLE `mskaryawan`
ADD PRIMARY KEY (`KDKARYAWAN`);
--
-- Indexes for table `trdetailpeminjaman`
--
ALTER TABLE `trdetailpeminjaman`
ADD PRIMARY KEY (`NOPEMINJAMAN`,`KDBUKU`),
ADD KEY `FK_DETAILPINJAM` (`KDBUKU`);
--
-- Indexes for table `trheaderpeminjaman`
--
ALTER TABLE `trheaderpeminjaman`
ADD PRIMARY KEY (`NOPEMINJAMAN`),
ADD KEY `FK_KARYAWAN` (`KDKARYAWAN`),
ADD KEY `FK_CUSTOMER` (`KDCUSTOMER`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `msbuku`
--
ALTER TABLE `msbuku`
ADD CONSTRAINT `FK_KDJENISBUKU` FOREIGN KEY (`KDJENISBUKU`)
REFERENCES `msjenisbuku` (`KDJENISBUKU`);
--
-- Constraints for table `trdetailpeminjaman`
--
ALTER TABLE `trdetailpeminjaman`
ADD CONSTRAINT `FK_DETAIL` FOREIGN KEY (`NOPEMINJAMAN`) REFERENCES
`trheaderpeminjaman` (`NOPEMINJAMAN`),
ADD CONSTRAINT `FK_DETAILPINJAM` FOREIGN KEY (`KDBUKU`) REFERENCES
`msbuku` (`KDBUKU`);
--
-- Constraints for table `trheaderpeminjaman`
--
ALTER TABLE `trheaderpeminjaman`
ADD CONSTRAINT `FK_CUSTOMER` FOREIGN KEY (`KDCUSTOMER`)
REFERENCES `mscustomer` (`KDCUSTOMER`),
ADD CONSTRAINT `FK_KARYAWAN` FOREIGN KEY (`KDKARYAWAN`)
REFERENCES `mskaryawan` (`KDKARYAWAN`);
COMMIT;
'
4. UPDATE msjenisbuku SET hargasewa = hargasewa + (hargasewa*10/100) WHERE
char_length(JENISBUKU) > 15;
8. –Menambahkan kolom
ALTER TABLE mscustomer ADD Umur varchar(21)
UPDATE mscustomer SET Umur = '21' WHERE KDCUSTOMER = 'KC001';
UPDATE mscustomer SET Umur = '21' WHERE KDCUSTOMER = 'KC002';
UPDATE mscustomer SET Umur = '21' WHERE KDCUSTOMER = 'KC003';
UPDATE mscustomer SET Umur = '21' WHERE KDCUSTOMER = 'KC004';
UPDATE mscustomer SET Umur = 'NULL' WHERE KDCUSTOMER = 'KC005';
UPDATE mscustomer SET Umur = 'NULL' WHERE KDCUSTOMER = 'KC006';
UPDATE mscustomer SET Umur = 'NULL' WHERE KDCUSTOMER = 'KC007';
UPDATE mscustomer SET Umur = 'NULL' WHERE KDCUSTOMER = 'KC008';
UPDATE mscustomer SET Umur = '21' WHERE 'nama' REGEXP'%(a to n)';
-Menghapus kolom