SHARE
TWEET

perpus

jajangtea Jun 18th, 2019 (edited) 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Database: `perpustakaan`
  2. CREATE TABLE `buku` (
  3.   `kode_buku` varchar(10) NOT NULL,
  4.   `judul` varchar(200) NOT NULL,
  5.   `pengarang` varchar(200) NOT NULL,
  6.   `isbn` varchar(20) NOT NULL,
  7.   `foto` varchar(100) DEFAULT NULL,
  8.   `created_at` int(11) NOT NULL,
  9.   `updated_at` int(11) NOT NULL,
  10.   `id_kategori` int(11) NOT NULL
  11. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  12.  
  13. CREATE TABLE `kategori` (
  14.   `id_kategori` int(11) NOT NULL,
  15.   `nama_kategori` varchar(200) NOT NULL
  16. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  17.  
  18. ALTER TABLE `buku`
  19.   ADD PRIMARY KEY (`kode_buku`),
  20.   ADD KEY `id_kategori` (`id_kategori`);
  21.  
  22. ALTER TABLE `kategori`
  23.   ADD PRIMARY KEY (`id_kategori`);
  24.  
  25. ALTER TABLE `kategori`
  26.   MODIFY `id_kategori` int(11) NOT NULL AUTO_INCREMENT;
  27.  
  28. ALTER TABLE `buku`
  29.   ADD CONSTRAINT `buku_ibfk_1` FOREIGN KEY (`id_kategori`) REFERENCES `kategori` (`id_kategori`) ON DELETE CASCADE ON UPDATE CASCADE;
  30. COMMIT;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top