пользователей: 30398
предметов: 12406
вопросов: 234839
Конспект-online
РЕГИСТРАЦИЯ ЭКСКУРСИЯ

magazine (database)

create database if not exists magazine;

 

use magazine;

 

create table if not exists clients(

id int primary key auto_increment,

clientsName varchar (20)

);

 

create table if not exists buy(

id int primary key auto_increment,

title varchar(40),

fk_c int

);

 

create table if not exists product(

id int primary key auto_increment,

title varchar(30),

price int not null,

fk_brand int

);

 

create table if not exists brand(

id int primary key auto_increment,

brandName varchar (30)

);

 

create table if not exists reviews(

id int primary key auto_increment,

review varchar(500),

fk_product int

);

 

create table if not exists b_p(

id int primary key auto_increment,

fk_b int,

fk_p int

);

 

alter table buy add constraint foreign key(fk_c) references clients(id);

alter table b_p add constraint foreign key(fk_b) references buy(id);

alter table b_p add constraint foreign key(fk_p) references product(id);

alter table product add constraint foreign key(fk_brand) references brand(id);

alter table reviews add constraint foreign key(fk_product) references product(id);

 

 

insert into cl (clientsName)

values

('Ivan'),

( 'Ira'),

( 'Igor');

 

insert into buy (title)

values

('1'),

('2'),

('3');

 

insert into  product(title, price)

values

('Car', '35000'),

('Solar battery', '5000'),

('Wheels', '500'); 

 

 

insert into brand (brandName)

values

('Tesla'),

('Shiny'),

('Michelin');

 

insert into reviews(review)

values

('It*s the best car'),

('Very fast delivery. I am satisfied'),

('Super');

create database if not exists magazine;
 
use magazine;
 
create table if not exists clients(
id int primary key auto_increment,
clientsName varchar (20)
);
 
create table if not exists buy(
id int primary key auto_increment,
title varchar(40),
fk_c int
);
 
create table if not exists product(
id int primary key auto_increment,
title varchar(30),
price int not null,
fk_brand int
);
 
create table if not exists brand(
id int primary key auto_increment,
brandName varchar (30)
);
 
create table if not exists reviews(
id int primary key auto_increment,
review varchar(500),
fk_product int
);
 
create table if not exists b_p(
id int primary key auto_increment,
fk_b int,
fk_p int
);
 
alter table buy add constraint foreign key(fk_c) references clients(id);
alter table b_p add constraint foreign key(fk_b) references buy(id);
alter table b_p add constraint foreign key(fk_p) references product(id);
alter table product add constraint foreign key(fk_brand) references brand(id);
alter table reviews add constraint foreign key(fk_product) references product(id);
 
 
insert into cl (clientsName)
values
('Ivan'),
( 'Ira'),
( 'Igor');
 
insert into buy (title)
values
('1'),
('2'),
('3');
 
insert into  product(title, price)
values
('Car', '35000'),
('Solar battery', '5000'),
('Wheels', '500'); 
 
 
insert into brand (brandName)
values
('Tesla'),
('Shiny'),
('Michelin');
 
insert into reviews(review)
values
('It*s the best car'),
('Very fast delivery. I am satisfied'),
('Super');

10.03.2017; 16:52
хиты: 214
рейтинг:0
для добавления комментариев необходимо авторизироваться.
  Copyright © 2013-2024. All Rights Reserved. помощь