0% found this document useful (0 votes)
20 views5 pages

Selma Phpmyadmin

The document contains the SQL code to define the structure and relationships of multiple database tables for an online pharmacy store. It defines tables for products, transactions, users and user types and includes sample data. It also defines primary keys and foreign key constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Selma Phpmyadmin

The document contains the SQL code to define the structure and relationships of multiple database tables for an online pharmacy store. It defines tables for products, transactions, users and user types and includes sample data. It also defines primary keys and foreign key constraints.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

-- phpMyAdmin SQL Dump

-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Waktu pembuatan: 14 Jan 2024 pada 06.23
-- Versi server: 10.4.22-MariaDB
-- Versi PHP: 7.4.26

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";


START TRANSACTION;
SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;


/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `dbtokoobat_selma`
--

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

--
-- Struktur dari tabel `product`
--

CREATE TABLE `product` (


`product_id` int(11) NOT NULL,
`code` varchar(30) NOT NULL,
`product_name` varchar(50) NOT NULL,
`description` varchar(250) DEFAULT NULL,
`price` int(11) NOT NULL,
`discount` int(11) DEFAULT NULL,
`quantity` varchar(25) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data untuk tabel `product`
--

INSERT INTO `product` (`product_id`, `code`, `product_name`,


`description`, `price`, `discount`, `quantity`) VALUES
(1, 'cap-001', 'diapet', 'untuk meredakan buang airbesar', 5000, 5,
'baik');

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

--
-- Struktur dari tabel `transaction`
--

CREATE TABLE `transaction` (


`transaction_id` int(11) NOT NULL,
`transaction_time` date DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`sub_total` int(11) DEFAULT NULL,
`discount` int(11) DEFAULT NULL,
`total` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data untuk tabel `transaction`
--

INSERT INTO `transaction` (`transaction_id`, `transaction_time`,


`user_id`, `sub_total`, `discount`, `total`) VALUES
(1, '2024-01-11', 1, 10000, 5, 9500);

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

--
-- Struktur dari tabel `transaction_product`
--

CREATE TABLE `transaction_product` (


`transaction_product_id` int(11) NOT NULL,
`product_id` int(11) DEFAULT NULL,
`transaction_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data untuk tabel `transaction_product`
--

INSERT INTO `transaction_product` (`transaction_product_id`,


`product_id`, `transaction_id`) VALUES
(1, 1, 1);

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

--
-- Struktur dari tabel `user`
--

CREATE TABLE `user` (


`user_id` int(11) NOT NULL,
`username` varchar(50) NOT NULL,
`email_address` varchar(50) DEFAULT NULL,
`phone_number` varchar(15) DEFAULT NULL,
`password` varchar(50) DEFAULT NULL,
`register_time` date DEFAULT NULL,
`last_login` date DEFAULT NULL,
`user_type_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data untuk tabel `user`
--

INSERT INTO `user` (`user_id`, `username`, `email_address`,


`phone_number`, `password`, `register_time`, `last_login`,
`user_type_id`) VALUES
(1, 'Selma Nursyamsiah', '[email protected]', '087737583256',
'selmaselsel123', '2024-01-01', '2024-01-08', 1);

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

--
-- Struktur dari tabel `user_type`
--

CREATE TABLE `user_type` (


`user_type_id` int(11) NOT NULL,
`user_type` varchar(30) NOT NULL,
`description` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data untuk tabel `user_type`
--

INSERT INTO `user_type` (`user_type_id`, `user_type`, `description`)


VALUES
(1, 'apoterker', 'mahasiswa Universitas Muhammadiyah Tasikmalaya');

--
-- Indexes for dumped tables
--

--
-- Indeks untuk tabel `product`
--
ALTER TABLE `product`
ADD PRIMARY KEY (`product_id`);

--
-- Indeks untuk tabel `transaction`
--
ALTER TABLE `transaction`
ADD PRIMARY KEY (`transaction_id`),
ADD KEY `user_id` (`user_id`);

--
-- Indeks untuk tabel `transaction_product`
--
ALTER TABLE `transaction_product`
ADD PRIMARY KEY (`transaction_product_id`),
ADD KEY `product_id` (`product_id`),
ADD KEY `transaction_id` (`transaction_id`);

--
-- Indeks untuk tabel `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`user_id`),
ADD KEY `user_type_id` (`user_type_id`);

--
-- Indeks untuk tabel `user_type`
--
ALTER TABLE `user_type`
ADD PRIMARY KEY (`user_type_id`);

--
-- AUTO_INCREMENT untuk tabel yang dibuang
--

--
-- AUTO_INCREMENT untuk tabel `product`
--
ALTER TABLE `product`
MODIFY `product_id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT untuk tabel `transaction`
--
ALTER TABLE `transaction`
MODIFY `transaction_id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT untuk tabel `transaction_product`
--
ALTER TABLE `transaction_product`
MODIFY `transaction_product_id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT untuk tabel `user`
--
ALTER TABLE `user`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT untuk tabel `user_type`
--
ALTER TABLE `user_type`
MODIFY `user_type_id` int(11) NOT NULL AUTO_INCREMENT,
AUTO_INCREMENT=2;

--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--

--
-- Ketidakleluasaan untuk tabel `transaction`
--
ALTER TABLE `transaction`
ADD CONSTRAINT `transaction_ibfk_1` FOREIGN KEY (`user_id`)
REFERENCES `user` (`user_id`);

--
-- Ketidakleluasaan untuk tabel `transaction_product`
--
ALTER TABLE `transaction_product`
ADD CONSTRAINT `transaction_product_ibfk_1` FOREIGN KEY
(`product_id`) REFERENCES `product` (`product_id`),
ADD CONSTRAINT `transaction_product_ibfk_2` FOREIGN KEY
(`transaction_id`) REFERENCES `transaction` (`transaction_id`);

--
-- Ketidakleluasaan untuk tabel `user`
--
ALTER TABLE `user`
ADD CONSTRAINT `user_ibfk_1` FOREIGN KEY (`user_type_id`) REFERENCES
`user_type` (`user_type_id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;


/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

You might also like