Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- не съм сигурен в форейн ключовете това с което се референсват
- create database online_magazin_db;
- use online_magazin_db;
- create table customers (
- customer_id int auto_increment primary key,
- name varchar(100) not null,
- email varchar(100) unique not null,
- address varchar(200),
- phone varchar(20)
- );
- create table categories (
- category_id int auto_increment primary key,
- category_name varchar(100) not null
- );
- create table suppliers (
- supplier_id int auto_increment primary key,
- supplier_name varchar(100) not null,
- contact varchar(100),
- supplier_address varchar(200)
- );
- create table products (
- product_id int auto_increment primary key,
- product_name varchar(100) not null,
- price decimal(10,2) not null,
- quantity int not null,
- category_id int,
- supplier_id int,
- foreign key (category_id) references categories(category_id),
- foreign key (supplier_id) references suppliers(supplier_id)
- );
- create table orders (
- order_id int auto_increment primary key,
- customer_id int,
- order_date date not null,
- total_amount decimal(10,2),
- foreign key (customer_id) references customers(customer_id)
- );
- create table order_items (
- order_item_id int auto_increment primary key,
- order_id int,
- product_id int,
- quantity int not null,
- price decimal(10,2) not null,
- foreign key (order_id) references orders(order_id),
- foreign key (product_id) references products(product_id)
- );
- create table payments (
- payment_id int auto_increment primary key,
- order_id int,
- payment_date date not null,
- amount decimal(10,2) not null,
- method enum('cash','card','online') not null,
- foreign key (order_id) references orders(order_id)
- );
Advertisement
Add Comment
Please, Sign In to add comment