Notes
Notes - notes.io |
DROP TRIGGER Množstvo_out,Množstvo_in;
CREATE table Biz.dodavatelia(
id_dodavatela int(8) not null auto_increment unique Primary KEY ,
Nazov varchar(45) not null,
ico int(8) not null unique,
stat varchar(2) not null,
telefon_s_predvolbou varchar(15)
);
CREATE table Biz.odoberatelia(
id_odoberatela int(8) not null auto_increment unique Primary Key ,
ico int(8) not null unique,
Nazov varchar(45) not null,
stat varchar(2) not null,
telefon_s_predvolbou varchar(15)
);
create table Biz.Tovar(
id_tovaru int(8) not null unique auto_increment Primary Key,
nazov_tovaru varchar(20) not null,
Cena_kilo float(8) not null,
mnozstvo int(12) DEFAULT 0,
Typ boolean
);
Create table Biz.UctyDodavatelov(
id_transakcie int(8) not null unique auto_increment,
id_dodavatela int(8),
id_tovaru int(8) not null,
mnozstvo int(15) not null,
Datum datetime,
foreign key (id_dodavatela) references Biz.dodavatelia(id_dodavatela),
foreign key (id_tovaru) references Biz.Tovar(id_tovaru)
);
Create table Biz.UctyOdoberatelov(
id_transakcie int(8) not null unique auto_increment,
id_odoberatela int(8),
id_tovaru int(8) not null,
mnozstvo int(15) not null,
Datum datetime,
foreign key (id_odoberatela) references Biz.odoberatelia(id_odoberatela),
foreign key (id_tovaru) references Biz.Tovar(id_tovaru)
);
CREATE TRIGGER Množstvo_in AFTER INSERT ON Biz.UctyDodavatelov
FOR EACH ROW
update Biz.Tovar set Biz.Tovar.mnozstvo = Biz.Tovar.mnozstvo + new.mnozstvo where Biz.Tovar.id_tovaru= new.id_tovaru ;
CREATE TRIGGER Množstvo_out AFTER INSERT ON Biz.UctyOdoberatelov
FOR EACH ROW
update Biz.Tovar set Biz.Tovar.mnozstvo = Biz.Tovar.mnozstvo - new.mnozstvo where Biz.Tovar.id_tovaru= new.id_tovaru ;
INSERT INTO Biz.dodavatelia(Nazov, ico, stat, telefon_s_predvolbou)
VALUES
('Explosm',50245045,'SK','+4219660025'),
('Gold_Touch',45678921,'DE','+421258456'),
('Pro_Star_Garden',12345687,'CZ','+4201584456'),
('Red_Bears',98564213,'SK','+4218456951'),
('Mannings_Cafeterias',75395146,'CZ','+4209456852');
INSERT INTO Biz.odoberatelia(Nazov, ico, stat, telefon_s_predvolbou)
VALUES
('OmniArchitectural',68517823,'SK','+42105848852'),
('Pomeroy',75369852,'SK','+4215475862'),
('GammaRealty',25864835,'CZ','+4201456421'),
('Sagebrush',75298546,'CZ','+4201234852'),
('Elek-Tek',45321785,'DE','+429852147');
INSERT INTO Biz.Tovar(nazov_tovaru, Cena_kilo,Typ)
VALUES
('Jablko',1.24,true),
('Hruška',1.41,true),
('Hrozno',0.84,true),
('Uhorka',0.62,false),
('Citron',1.65,true),
('Jahoda',1.74,true),
('Pomaranc',0.75,true),
('Cinska_kapusta',0.30,false),
('Kapusta',0.40,false),
('Fazula',2.11,false);
insert into Biz.UctyDodavatelov(id_dodavatela, id_tovaru, mnozstvo,Datum)
Values
(1,1,150,timestamp(now())),
(3,1,100,timestamp(now())),
(1,2,100,timestamp(now())),
(2,2,24,timestamp(now())),
(3,7,75,timestamp(now()));
insert into Biz.UctyOdoberatelov(id_odoberatela, id_tovaru, mnozstvo,Datum)
Values
(1,1,20,timestamp(now())),
(2,2,40,timestamp(now())),
(2,2,15,timestamp(now())),
(1,1,30,timestamp(now())),
(3,7,70,timestamp(now()));
/*Výpis vsetkých transakcii od jedneho dodavatela*/
/*
select Biz.odoberatelia.Nazov Názov, Biz.UctyOdoberatelov.Datum Datum, Biz.UctyOdoberatelov.id_tovaru ID_tovaru, Biz.Tovar.nazov_tovaru, Biz.UctyOdoberatelov.id_transakcie ID_Transakcie, Biz.UctyOdoberatelov.mnozstvo Množstvo
from Biz.UctyOdoberatelov
inner JOIN Biz.Tovar ON Biz.UctyOdoberatelov.id_odoberatela = Biz.Tovar.id_tovaru
inner JOIN Biz.odoberatelia ON Biz.odoberatelia.id_odoberatela = Biz.UctyOdoberatelov.id_odoberatela
where Biz.odoberatelia.id_odoberatela = 3;
*/
/*Výpis vŠetkého čo je na sklade nedostotok (<10)*/
/*
select `nazov_tovaru` 'Názov', `Cena_kilo` 'Cena/kilo', `mnozstvo` from Biz.Tovar where mnozstvo < 10;
*/
/*Zmazanie dodavatela*/ /*Nedokončené !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
/*
delete from Biz.UctyDodavatelov where id_dodavatela=1;
delete from Biz.dodavatelia where id_dodavatela=1;
*/
/*
select * from Biz.Tovar
*/
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team