SHARE
TWEET

Untitled

a guest Mar 26th, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE Sectii(
  2.     IdSectie INT PRIMARY KEY,
  3.     Nume VARCHAR(20) NOT NULL,
  4.     Buget INT NOT NULL
  5. );
  6.  
  7. CREATE TABLE Angajati(
  8.     IdAngajat INT PRIMARY KEY,
  9.     Nume VARCHAR(20) NOT NULL,
  10.     Prenume VARCHAR(50) NOT NULL,
  11.     DataNasterii DATE NOT NULL,
  12.     Adresa VARCHAR(20) NOT NULL,
  13.     Functie VARCHAR(25) NOT NULL,
  14.     Salariu INT NOT NULL,
  15.     IdSectie INT NOT NULL
  16. );
  17.  
  18. CREATE TABLE Furnizori(
  19.     IdFurnizor INT PRIMARY KEY,
  20.     Nume VARCHAR(20) NOT NULL,
  21.     Prenume VARCHAR(30) NOT NULL,
  22.     Adresa VARCHAR(50) NOT NULL
  23. );
  24.  
  25. CREATE TABLE Clienti(
  26.     IdClient INT PRIMARY KEY,
  27.     Nume VARCHAR(20) NOT NULL,
  28.     Prenume VARCHAR(30) NOT NULL,
  29.     Adresa VARCHAR(50) NOT NULL
  30. );
  31.  
  32. CREATE TABLE Produse(
  33.     IdProdus INT PRIMARY KEY,
  34.     Denumire VARCHAR(20) NOT NULL,
  35.     Descriere VARCHAR(50) NOT NULL,
  36. );
  37.  
  38. CREATE TABLE Componente(
  39.     IdComponenta INT PRIMARY KEY,
  40.     Denumire VARCHAR(20) NOT NULL,
  41.     Descriere VARCHAR(50) NOT NULL,
  42. );
  43.  
  44. CREATE TABLE Dependenti(
  45.     IdAngajat INT ,
  46.     Nume VARCHAR(20) PRIMARY KEY NOT NULL,
  47.     Prenume VARCHAR(30) NOT NULL,
  48.     DataNasterii DATE NOT NULL,
  49.     GradRudenie VARCHAR(20) NOT NULL
  50. );
  51.  
  52. CREATE TABLE Ingineri(
  53.     IdAngajat INT PRIMARY KEY NOT NULL,
  54.     Specialitate VARCHAR(20) NOT NULL,
  55. );
  56.  
  57. CREATE TABLE Secretare(
  58.     IdAngajat INT PRIMARY KEY NOT NULL,
  59.     VitezaRedactare INT NOT NULL,
  60. );
  61.  
  62. CREATE TABLE Achizitii(
  63.     IdAchizitie INT PRIMARY KEY,
  64.     IdAchizitor INT NOT NULL,
  65.     IdFurnizor INT NOT NULL,
  66.     IdComponenta INT NOT NULL,
  67.     DATA DATE NOT NULL,
  68.     NrComponente INT NOT NULL,
  69.     PretUnitar FLOAT NOT NULL,
  70.     IdAngajat INT NOT NULL
  71. );
  72.  
  73. CREATE TABLE Compozitii(
  74.     NrComponente INT NOT NULL,
  75.     IdComponenta INT NOT NULL,
  76.     IdProdus INT NOT NULL
  77. );
  78.  
  79. CREATE TABLE Vanzari(
  80.     IdVanzare INT PRIMARY KEY,
  81.     IdVanzator INT NOT NULL,
  82.     IdProdus INT NOT NULL,
  83.     IdClient INT NOT NULL,
  84.     DATA DATE NOT NULL,
  85.     NrProduse INT NOT NULL,
  86.     IdAngajat INT NOT NULL
  87. );
  88.  
  89. CREATE TABLE Activitati(
  90.     IdProiect INT NOT NULL,
  91.     IdAngajat INT NOT NULL,
  92.     Ore INT NOT NULL,
  93. );
  94.  
  95. CREATE TABLE Proiecte(
  96.     IdProiect INT PRIMARY KEY,
  97.     Denumire VARCHAR(50) NOT NULL,
  98.     Termen DATE NOT NULL,
  99.     Buget INT NOT NULL
  100. );
  101.  
  102. ALTER TABLE angajati ADD CONSTRAINT fk_angajati FOREIGN KEY (IdSectie) REFERENCES sectii (IdSectie)
  103. ALTER TABLE dependenti ADD CONSTRAINT fk_dependenti FOREIGN KEY (IdAngajat) REFERENCES angajati (IdAngajat)
  104. ALTER TABLE secretare ADD CONSTRAINT fk_secretare FOREIGN KEY (IdAngajat) REFERENCES angajati (IdAngajat)
  105. ALTER TABLE ingineri ADD CONSTRAINT fk_ingineri FOREIGN KEY (IdAngajat) REFERENCES angajati (IdAngajat)
  106. ALTER TABLE achizitii ADD CONSTRAINT fk_achizitii FOREIGN KEY (IdFurnizor) REFERENCES furnizori (IdFurnizor)
  107. ALTER TABLE achizitii ADD CONSTRAINT fks_achizitii FOREIGN KEY (IdComponenta) REFERENCES componente (IdComponenta)
  108. ALTER TABLE compozitii ADD CONSTRAINT fk_compozitii FOREIGN KEY (IdComponenta) REFERENCES componente (IdComponenta)
  109. ALTER TABLE compozitii ADD CONSTRAINT fks_compozitii FOREIGN KEY (IdProdus) REFERENCES produse (IdProdus)
  110. ALTER TABLE vanzari ADD CONSTRAINT fk_vanzari FOREIGN KEY (IdProdus) REFERENCES produse (IdProdus)
  111. ALTER TABLE vanzari ADD CONSTRAINT fks_vanzari FOREIGN KEY (IdClient) REFERENCES clienti (IdClient)
  112. ALTER TABLE activitati ADD CONSTRAINT fk_activitati FOREIGN KEY (IdAngajat) REFERENCES angajati (IdAngajat)
  113. ALTER TABLE activitati ADD CONSTRAINT fks_activitati FOREIGN KEY (IdProiect) REFERENCES proiecte (IdProiect)
  114. ALTER TABLE achizitii ADD CONSTRAINT fka_achizitii FOREIGN KEY (IdAngajat) REFERENCES angajati (IdAngajat)
  115. ALTER TABLE vanzari ADD CONSTRAINT fka_vanzari FOREIGN KEY (IdAngajat) REFERENCES angajati (IdAngajat)
  116.  
  117. INSERT INTO sectii VALUES(1,'Productie',500000);
  118. INSERT INTO sectii VALUES(2,'Motoare',10000000);
  119. INSERT INTO sectii VALUES(3,'Caroserie',750000);
  120. INSERT INTO sectii VALUES(4,'Asamblare',1250000);
  121. INSERT INTO sectii VALUES(5,'Testare',400000);
  122.  
  123. INSERT INTO angajati VALUES (1,'Popa','Mihai','10/02/1990','Craiova', 'Tester', 1500,1);
  124. INSERT INTO angajati VALUES (2,'Popescu','Andrei','02/10/1990','Bucuresti', 'Programator', 1700,2);
  125. INSERT INTO angajati VALUES (3, 'Ilie', 'Mihai', '10/02/1987', 'Ploiesti', 'Tester', 2100, 3);
  126. INSERT INTO angajati VALUES (4,'Mihai','Daniel','1989/12/21','Craiova', 'Muncitor', 1950,4);
  127. INSERT INTO angajati VALUES (5,'Ion','Razvan','1985/07/10','Bucuresti', 'Programator', 2250,5);
  128. INSERT INTO angajati VALUES (6,'Dumitru','Ion','1970/01/01','Brasov', 'Tester', 2500,1);
  129. INSERT INTO angajati VALUES (7,'Dinu','Andrei','02/10/1989','Timisoara', 'Tester', 1800,2);
  130. INSERT INTO angajati VALUES (8,'Andrei','Alin','12/05/1987','Bucuresti', 'Programator', 2300,3);
  131. INSERT INTO angajati VALUES (9,'Mihalcea','Daniela','1989/12/21','Craiova', 'Tester', 2150,4);
  132. INSERT INTO angajati VALUES (10,'Mihnea','Razvy','1989/12/21','Brasov', 'Muncitor', 1550,5);
  133. INSERT INTO angajati VALUES (11,'Mitatu','Robert','1989/12/21','Craiova', 'Muncitor', 60000,5);
  134.  
  135. INSERT INTO furnizori VALUES(1, 'Popescu', 'Razvan', 'Craiova');
  136. INSERT INTO furnizori VALUES(2, 'Danescu', 'Ovidiu', 'Constanta');
  137. INSERT INTO furnizori VALUES(3, 'Dancioiu', 'Andrei', 'Bucuresti');
  138. INSERT INTO furnizori VALUES(4, 'Popa', 'Alin', 'Pitesti');
  139.  
  140. INSERT INTO Clienti VALUES(1,'Alexandru','Lucian','Slatina');
  141. INSERT INTO Clienti VALUES(2,'Stefran','Marian','Bucuresti');
  142. INSERT INTO Clienti VALUES(3,'Andrei','Mihai','Rimisoara');
  143. INSERT INTO Clienti VALUES(4,'Lia','Virgy','Gorj');
  144. INSERT INTO Clienti VALUES(5,'Alexandru','Maria','Bucuresti');
  145. INSERT INTO Clienti VALUES(6,'Stefan','Ioana','Iasi');
  146. INSERT INTO Clienti VALUES(7,'Andrei','Alexa','Craiova');
  147. INSERT INTO Clienti VALUES(8,'Mihai','Andreea','Timisoara');
  148. INSERT INTO Clienti VALUES(9,'Liviu','Ics','Valcea');
  149. INSERT INTO Clienti VALUES(10,'Popa','Andrei','Constanta');
  150. INSERT INTO Clienti VALUES(11,'Marinescu','Ion','Bucuresti');
  151.  
  152.  
  153. INSERT INTO produse VALUES(1,'Monitor','ecran 15 inch');
  154. INSERT INTO produse VALUES(2,'Tastatura','---');
  155. INSERT INTO produse VALUES(3,'Mouse','---');
  156. INSERT INTO produse VALUES(4,'Unitate','---');
  157. INSERT INTO produse VALUES(5,'Sistem audio','---');
  158.  
  159. INSERT INTO componente VALUES(1,'rezistenta','rezistenta de caldura');
  160. INSERT INTO componente VALUES(2,'condensator','disp. electric');
  161. INSERT INTO componente VALUES(3,'tranzistor','-------');
  162. INSERT INTO componente VALUES(4,'circuit integrat','-------');
  163. INSERT INTO componente VALUES(5,'termistor','--?---');
  164.  
  165. INSERT INTO dependenti VALUES (10,'Andrei','Costinela','12/15/1989','fiica');
  166. INSERT INTO dependenti VALUES (8,'Boboc','Laura','05/17/1989','nepoata');
  167. INSERT INTO dependenti VALUES (6,'Rat','Andrey','05/12/1988','unchi');
  168. INSERT INTO dependenti VALUES (4,'Mirelus','Iulian','11/11/1969','strabunic');
  169. INSERT INTO dependenti VALUES (2,'Gheorghe','Constantin','01/01/1980','var');
  170. INSERT INTO dependenti VALUES (3,'Popescu','Ion','03/02/1980','fiu');
  171.  
  172. INSERT INTO ingineri VALUES (5, 'electronica');
  173. INSERT INTO ingineri VALUES (4, 'mecanica');
  174. INSERT INTO ingineri VALUES (3, 'elecrotehnica');
  175. INSERT INTO ingineri VALUES (2, 'chimie');
  176. INSERT INTO ingineri VALUES (1, 'informatica');
  177.  
  178. INSERT INTO secretare VALUES (9, 250);
  179. INSERT INTO secretare VALUES (8, 270);
  180. INSERT INTO secretare VALUES (7, 290);
  181. INSERT INTO secretare VALUES (6, 200);
  182. INSERT INTO secretare VALUES (10, 150);
  183.  
  184. INSERT INTO achizitii VALUES (1, 1, 1, 1, '01/01/2010', 100, 5, 8);
  185. INSERT INTO achizitii VALUES (2, 2, 2, 2, '01/01/2010', 200, 7, 9);
  186. INSERT INTO achizitii VALUES (3, 3, 3, 3, '01/01/2010', 300, 4, 5);
  187. INSERT INTO achizitii VALUES (4, 4, 4, 4, '01/01/2010', 400, 6, 1);
  188. INSERT INTO achizitii VALUES (5, 5, 3, 5, '01/01/2010', 400, 5, 6);
  189.  
  190. INSERT INTO Compozitii VALUES(30,1,2);
  191. INSERT INTO Compozitii VALUES(20,2,3);
  192. INSERT INTO Compozitii VALUES(10,3,5);
  193. INSERT INTO Compozitii VALUES(40,4,4);
  194. INSERT INTO Compozitii VALUES(50,5,1);
  195.  
  196. INSERT INTO vanzari VALUES(1,1,1,1,'01/01/2010',10,3);
  197. INSERT INTO vanzari VALUES(2,1,2,7,'01/01/2010',20,3);
  198. INSERT INTO vanzari VALUES(3,1,3,9,'01/01/2010',30,3);
  199. INSERT INTO vanzari VALUES(4,1,4,4,'01/01/2010',40,3);
  200. INSERT INTO vanzari VALUES(5,1,5,6,'01/01/2010',50,3);
  201. INSERT INTO vanzari VALUES(6,1,5,11,'01/01/2010',50,3);
  202.  
  203. INSERT INTO Proiecte VALUES(1,'Sistem de achizitie de date','02/12/2020',5000);
  204. INSERT INTO Proiecte VALUES(2,'Modul 2','07/12/2020',4500);
  205. INSERT INTO Proiecte VALUES(3,'Modul 3','10/12/2020',7000);
  206. INSERT INTO Proiecte VALUES(4,'Modul 4','09/12/2020',9000);
  207. INSERT INTO Proiecte VALUES(5,'Modul 5','05/12/2020',2500);
  208.  
  209. INSERT INTO activitati VALUES(1,1,5);
  210. INSERT INTO activitati VALUES(2,3,5);
  211. INSERT INTO activitati VALUES(3,5,5);
  212. INSERT INTO activitati VALUES(4,7,5);
  213. INSERT INTO activitati VALUES(5,9,5);
  214.  
  215. SELECT * FROM Proiecte
  216.  
  217. /*3.1*/
  218. SELECT Nume,Prenume FROM Furnizori WHERE Adresa = 'Bucuresti' UNION SELECT Nume,Prenume FROM Clienti WHERE Adresa = 'Bucuresti';
  219.  
  220. /*3.2*/
  221. SELECT * FROM Sectii,Angajati;
  222.  
  223. /*3.3*/
  224. SELECT Nume,Prenume FROM Furnizori,Achizitii WHERE EXISTS (SELECT NrComponente FROM Achizitii WHERE NrComponente>200) AND (Furnizori.IdFurnizor=Achizitii.IdFurnizor);
  225.  
  226. /*3.4*/
  227. SELECT IdAngajat FROM Achizitii WHERE IdComponenta=(SELECT IdComponenta FROM Componente WHERE Denumire='condensator')
  228. SELECT Nume,Prenume FROM Angajati,Achizitii,Componente WHERE (Componente.Denumire='condensator') AND (Angajati.IdAngajat=Achizitii.IdAngajat) AND (Achizitii.IdComponenta=Componente.IdComponenta)
  229. SELECT Angajati.Nume,Prenume,DataNasterii,Salariu FROM Sectii,Angajati WHERE Sectii.IdSectie=Angajati.IdSectie AND Sectii.Nume='Productie'
  230.  
  231. /*3.5*/
  232. SELECT Nume,Prenume,Adresa FROM Furnizori WHERE IdFurnizor=(SELECT IdFurnizor FROM Achizitii WHERE IdComponenta=(SELECT IdComponenta FROM Componente WHERE Denumire='Rezistenta'))
  233.  
  234. /*3.6*/
  235. SELECT Nume,Prenume,Adresa FROM Furnizori WHERE IdFurnizor=(SELECT IdFurnizor FROM Achizitii WHERE IdComponenta=(SELECT IdComponenta FROM Componente WHERE Denumire='Condensator')AND NrComponente>=150)
  236.  
  237. /*3.7*/
  238. SELECT Nume,Prenume,Adresa FROM Clienti,Vanzari,Produse WHERE (Produse.Denumire='Monitor') AND (Clienti.IdClient=Vanzari.IdClient) AND (Produse.IdProdus=Vanzari.IdProdus) AND (Vanzari.NrProduse>=10)
  239.  
  240. /*3.8*/
  241. SELECT Nume,Prenume FROM Angajati,Vanzari,Produse WHERE (Produse.Denumire='Monitor') AND (Vanzari.IdProdus=Produse.IdProdus) AND (Vanzari.IdAngajat=Angajati.IdAngajat)
  242.  
  243. /*3.9*/
  244. SELECT Nume,Prenume,DataNasterii FROM Angajati,Proiecte,Activitati WHERE (Proiecte.Denumire='Sistem de achizitie de date') AND (Proiecte.IdProiect=Activitati.IdProiect) AND (Angajati.IdAngajat=Activitati.IdAngajat)
  245.  
  246. /*3.10*/
  247. SELECT Sectii.Nume FROM Sectii,Proiecte,Angajati,Activitati WHERE (Angajati.IdAngajat=Activitati.IdAngajat) AND (Activitati.IdProiect=Proiecte.IdProiect) AND (Angajati.IdSectie=Sectii.IdSectie) AND (Proiecte.Denumire='Sistem de achizitie de date')
  248.  
  249. /*3.11*/
  250. SELECT Nume,Prenume,DataNasterii FROM Angajati,Ingineri WHERE (Angajati.IdAngajat=Ingineri.IdAngajat) AND (Ingineri.Specialitate='electronica')
  251.  
  252. /*3.12*/
  253. SELECT Angajati.Nume,Angajati.Prenume FROM Angajati,Sectii,Dependenti WHERE (Angajati.IdAngajat=Dependenti.IdAngajat) AND (Sectii.Nume='Productie') AND (Dependenti.Prenume='Ion') AND (Dependenti.GradRudenie='fiu')
  254.  
  255. /*3.13*/
  256. SELECT Angajati.Nume,Angajati.Prenume FROM Angajati,Sectii,Ingineri WHERE (Angajati.IdAngajat=Ingineri.IdAngajat) AND (Sectii.Nume='Productie') AND (Angajati.IdSectie=Sectii.IdSectie)
  257.  
  258. /*3.14*/
  259. SELECT Angajati.Nume,Angajati.Prenume FROM Angajati,Furnizori,Achizitii WHERE (Furnizori.Nume='Popescu') AND (Furnizori.Prenume='Razvan') AND (Furnizori.IdFurnizor=Achizitii.IdFurnizor) AND (Angajati.IdAngajat=Achizitii.IdAngajat)
  260.  
  261. /*3.15*/
  262. SELECT Angajati.Nume,Angajati.Prenume FROM Angajati,Clienti,Vanzari WHERE (Angajati.IdAngajat=Vanzari.IdAngajat) AND (Clienti.IdClient=Vanzari.IdClient) AND (Clienti.Nume='Marinescu') AND Clienti.Prenume='Ion'
  263.  
  264. /*3.16*/
  265. SELECT Produse.Denumire FROM Furnizori,Achizitii,Produse,Compozitii WHERE (Furnizori.IdFurnizor=Achizitii.IdFurnizor) AND Compozitii.IdProdus=Produse.IdProdus AND Compozitii.IdComponenta=Achizitii.IdComponenta AND Furnizori.Nume='Danescu' AND Furnizori.Prenume='Ovidiu'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top