-- 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
(31, '909557544_2024 Kawasaki Ninja 500, Dopdolu Geliyor.jpeg', 'F2559EU', 'Honda', 2020, 'BPKB,STNK,Faktur', 'Ninja 500', 'hidup', 'Hitam', '80000000', '83000000', '82000000', '83000000', '2024-10-28 11:42:09'),
(32, '1391942284_download (2).jpeg', 'F2913EK', 'Honda', 2000, 'BPKB,STNK,Faktur', 'Legenda 2000', 'hidup', 'Hitam', '3000000', '4500000', '4000000', '4300000', '2024-10-28 12:34:57');

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

--
-- 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
(25, 'Yasim', '1292929', 'Gunung Putri, Bogor', 'Laki-laki', '081291602423', 31),
(26, 'Syahabi', '1283821893', 'Jl. cidangiang 20 RT 03 RW 03', 'Laki-laki', '0895365057581', 32);

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

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

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

--
-- Dumping data for table `pembelian`
--

INSERT INTO `pembelian` (`id_transaksibeli`, `id_kendaraan`, `id_user`, `harga_beli`) VALUES
(10, 31, 2, 80000000.00),
(11, 32, 1, 3000000.00);

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

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

CREATE TABLE `penjualan` (
  `id_transaksijual` int(11) NOT NULL,
  `id_kendaraan` int(11) DEFAULT NULL,
  `id_user` 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`, `id_user`, `harga_jual`) VALUES
(10, 31, 1, 83000000.00),
(11, 32, 1, 4300000.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`),
  ADD KEY `fk_id_user` (`id_user`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

--
-- 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 `fk_id_user` FOREIGN KEY (`id_user`) REFERENCES `user` (`id`),
  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 `fk_id_user_penjualan` FOREIGN KEY (`id_user`) REFERENCES `user` (`id`),
  ADD CONSTRAINT `penjualan_ibfk_1` FOREIGN KEY (`id_kendaraan`) REFERENCES `motor` (`id`);
COMMIT;

