-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `keso`
--

-- --------------------------------------------------------

--
-- Table structure for table `motor`
--

CREATE TABLE `motor` (
  `id` int(11) NOT NULL,
  `foto` varchar(255) NOT NULL,
  `no_plat` varchar(40) NOT NULL,
  `merk` enum('Honda','Yamaha','Suzuki','Kawasaki') NOT NULL,
  `tahun_rakit` int(4) NOT NULL,
  `kelengkapan` set('BPKB','STNK','Faktur') NOT NULL,
  `varian` varchar(40) NOT NULL,
  `pajak` enum('hidup','mati') NOT NULL,
  `warna` varchar(40) NOT NULL,
  `harga_beli` varchar(40) NOT NULL,
  `harga_ditawarkan` varchar(40) DEFAULT NULL,
  `harga_nett` varchar(40) DEFAULT NULL,
  `harga_jual` varchar(40) NOT NULL,
  `tanggal_masuk` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `motor`
--

INSERT INTO `motor` (`id`, `foto`, `no_plat`, `merk`, `tahun_rakit`, `kelengkapan`, `varian`, `pajak`, `warna`, `harga_beli`, `harga_ditawarkan`, `harga_nett`, `harga_jual`, `tanggal_masuk`) VALUES
(20, '1931252760_zx25r.jpg', 'AE2455ER', 'Honda', 2022, 'BPKB,STNK,Faktur', 'R1M', 'hidup', 'Putih', '45000000', '60000000', '50000000', '55000000', '2024-10-25 12:59:59'),
(21, '179064475_fazzio.jpg', 'B23RFD', 'Yamaha', 2022, 'BPKB,STNK', 'Fazzio', 'hidup', 'Biru Kuning', '17500000', '19200000', '18500000', '', '2024-10-25 06:54:52'),
(22, '425557214_z1000r.jpg', 'F1000R', 'Kawasaki', 2022, 'BPKB,STNK,Faktur', 'Z1000R Sugomi', 'hidup', 'Hitam', '509000000', '580000000', '550000000', '', '2024-10-25 06:54:52'),
(23, '1195960226_yamahakuning.jpg', 'B8878B', 'Honda', 2020, 'BPKB,STNK', 'Vespa', 'hidup', 'Kuning', '30000000', '40000000', '35000000', '', '2024-10-25 12:57:39'),
(28, '812170555_2024 Kawasaki Ninja 500, Dopdolu Geliyor.jpeg', 'F2559EU', 'Kawasaki', 2020, 'BPKB,STNK,Faktur', 'Ninja 500', 'hidup', 'Hitam', '78000000', '81000000', '80000000', '', '2024-10-25 12:29:28');

-- --------------------------------------------------------

--
-- Table structure for table `pelanggan`
--

CREATE TABLE `pelanggan` (
  `id_pelanggan` int(11) NOT NULL,
  `nama` varchar(250) NOT NULL,
  `nik` varchar(15) NOT NULL,
  `alamat` varchar(250) NOT NULL,
  `jenis_kelamin` enum('Laki-laki','Perempuan') NOT NULL,
  `no_telp` varchar(15) NOT NULL,
  `id_motor` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `pelanggan`
--

INSERT INTO `pelanggan` (`id_pelanggan`, `nama`, `nik`, `alamat`, `jenis_kelamin`, `no_telp`, `id_motor`) VALUES
(21, 'Moch Yasmin', '109827632001', 'jl. Gunung Putri Bogor Barut', 'Laki-laki', '081291602423', 20);

-- --------------------------------------------------------

--
-- Table structure for table `pembelian`
--

CREATE TABLE `pembelian` (
  `id_transaksibeli` int(11) NOT NULL,
  `id_kendaraan` int(11) DEFAULT NULL,
  `harga_beli` decimal(15,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `penjualan`
--

CREATE TABLE `penjualan` (
  `id_transaksijual` int(11) NOT NULL,
  `id_kendaraan` int(11) DEFAULT NULL,
  `harga_jual` decimal(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `penjualan`
--

INSERT INTO `penjualan` (`id_transaksijual`, `id_kendaraan`, `harga_jual`) VALUES
(6, 20, 55000000.00);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `motor`
--
ALTER TABLE `motor`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `pelanggan`
--
ALTER TABLE `pelanggan`
  ADD PRIMARY KEY (`id_pelanggan`),
  ADD KEY `fk_motor` (`id_motor`);

--
-- Indexes for table `pembelian`
--
ALTER TABLE `pembelian`
  ADD PRIMARY KEY (`id_transaksibeli`),
  ADD KEY `id_kendaraan` (`id_kendaraan`);

--
-- Indexes for table `penjualan`
--
ALTER TABLE `penjualan`
  ADD PRIMARY KEY (`id_transaksijual`),
  ADD KEY `id_kendaraan` (`id_kendaraan`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `motor`
--
ALTER TABLE `motor`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;

--
-- AUTO_INCREMENT for table `pelanggan`
--
ALTER TABLE `pelanggan`
  MODIFY `id_pelanggan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;

--
-- AUTO_INCREMENT for table `pembelian`
--
ALTER TABLE `pembelian`
  MODIFY `id_transaksibeli` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `penjualan`
--
ALTER TABLE `penjualan`
  MODIFY `id_transaksijual` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `pelanggan`
--
ALTER TABLE `pelanggan`
  ADD CONSTRAINT `fk_motor` FOREIGN KEY (`id_motor`) REFERENCES `motor` (`id`);

--
-- Constraints for table `pembelian`
--
ALTER TABLE `pembelian`
  ADD CONSTRAINT `pembelian_ibfk_1` FOREIGN KEY (`id_kendaraan`) REFERENCES `motor` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `penjualan`
--
ALTER TABLE `penjualan`
  ADD CONSTRAINT `penjualan_ibfk_1` FOREIGN KEY (`id_kendaraan`) REFERENCES `motor` (`id`);
COMMIT;

