daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Mar 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP TABLE dependenti;
  2. CREATE TABLE dependenti(
  3. IdAngajat int NOT NULL,
  4. Nume varchar(20) NOT NULL,
  5. Prenume varchar(20) NOT NULL,
  6. DataN datetime,
  7. GradRudenie int NOT NULL
  8. );
  9.  
  10. DROP TABLE ingineri;
  11. CREATE TABLE ingineri(
  12. IdAngajat int NOT NULL PRIMARY KEY,
  13. Specialitatea varchar(30) NOT NULL
  14. );
  15.  
  16. DROP TABLE secretare;
  17. CREATE TABLE secretare(
  18. IdAngajat int NOT NULL PRIMARY KEY,
  19. VitezaRedactare int NOT NULL
  20. );
  21.  
  22. DROP TABLE sectii;
  23. CREATE TABLE sectii(
  24. IdSectie int NOT NULL PRIMARY KEY,
  25. Nume varchar(30) NOT NULL,
  26. Buget decimal
  27. );
  28.  
  29. DROP TABLE angajati;
  30. create table angajati(
  31. IDAngajat int NOT NULL PRIMARY KEY,
  32. Nume varchar(20) NOT NULL,
  33. Prenume varchar(20) NOT NULL,
  34. DataN datetime,
  35. Adresa varchar(50),
  36. Functie varchar(50),
  37. Salariu decimal DEFAULT 2800,
  38. IdSectie int
  39. );
  40.  
  41. DROP TABLE achizitii;
  42. CREATE TABLE achizitii(
  43. IdAchizitie int NOT NULL PRIMARY KEY,
  44. IdFurnizor int NOT NULL,
  45. IdComponenta int NOT NULL,
  46. IdAchizitor int NOT NULL,
  47. Data datetime,
  48. NrComponente int NOT NULL,
  49. PretUnitar float NOT NULL
  50. );
  51.  
  52. DROP TABLE compozitii;
  53. CREATE TABLE compozitii(
  54. IdComponenta int NOT NULL PRIMARY KEY,
  55. IdProdus int NOT NULL,
  56. NrComponente int NOT NULL
  57. );
  58.  
  59. DROP TABLE vanzari;
  60. CREATE TABLE vanzari(
  61. IdVanzare int NOT NULL PRIMARY KEY,
  62. IdProdus int NOT NULL,
  63. IdClient int NOT NULL,
  64. IdVanzator int NOT NULL,
  65. Data datetime,
  66. NrProduse int NOT NULL
  67. );
  68.  
  69. DROP TABLE activitati;
  70. CREATE TABLE activitati(
  71. IdProiect int NOT NULL PRIMARY KEY,
  72. IdAngajat int NOT NULL,
  73. Ore int NOT NULL
  74. );
  75.  
  76. DROP TABLE furnizori;
  77. CREATE TABLE furnizori(
  78. IdFurnizor int NOT NULL PRIMARY KEY,
  79. Nume varchar(30) NOT NULL,
  80. Prenume varchar(30) NOT NULL,
  81. Adresa varchar(30) NOT NULL
  82. );
  83.  
  84. DROP TABLE componente;
  85. CREATE TABLE componente(
  86. IDComponenta int NOT NULL PRIMARY KEY,
  87. Denumire varchar(30) NOT NULL,
  88. Descriere varchar(30) NOT NULL
  89. );
  90.  
  91. DROP TABLE produse;
  92. CREATE TABLE produse(
  93. IdProdus int NOT NULL PRIMARY KEY,
  94. Denumire varchar(30) NOT NULL,
  95. Descriere varchar(30) NOT NULL
  96. );
  97.  
  98. DROP TABLE clienti;
  99. CREATE TABLE clienti(
  100. IdClient int NOT NULL PRIMARY KEY,
  101. Nume varchar(30) NOT NULL,
  102. Prenume varchar(30) NOT NULL,
  103. Adresa varchar(30) NOT NULL
  104. );
  105.  
  106. DROP TABLE proiecte;
  107. CREATE TABLE proiecte(
  108. IdProduse int NOT NULL PRIMARY KEY,
  109. Denumire varchar(30) NOT NULL,
  110. Termen datetime,
  111. Buget decimal
  112. );
  113.  
  114.  
  115. ALTER TABLE dependenti ADD CONSTRAINT fk_angajati FOREIGN KEY(IdAngajat) REFERENCES angajati(IdAngajat);
  116. ALTER TABLE ingineri ADD CONSTRAINT fk_ingineri FOREIGN KEY(IdAngajat) REFERENCES ingineri(IdAngajat);
  117. ALTER TABLE secretare ADD CONSTRAINT fk_secretare FOREIGN KEY(IdAngajat)REFERENCES angajati(IdAngajat);
  118. ALTER TABLE angajati ADD CONSTRAINT fk_angajati FOREIGN KEY(IdSectie) REFERENCES sectii(IdSectie);
  119. ALTER TABLE achizitii ADD CONSTRAINT fk_achizitii FOREIGN KEY(IdAchizitor) REFERENCES angajati(IdAngajat);
  120. ALTER TABLE vanzari ADD CONSTRAINT fk_vanzari FOREIGN KEY(IdVanzator) REFERENCES angajati(IdAngajat);
  121. ALTER TABLE activitati ADD CONSTRAINT fk_activitati FOREIGN KEY(IdAngajat) REFERENCES angajati(IdAngajat);
  122. ALTER TABLE activitati ADD CONSTRAINT fk_activitati FOREIGN KEY(IdProiect) REFERENCES proiecte(IdProiect);
  123. ALTER TABLE vanzari ADD CONSTRAINT fk_vanzari FOREIGN KEY(IdVanzare) REFERENCES clienti(IdClient);
  124. ALTER TABLE vanzare ADD CONSTRAINT fk_vancare FOREIGN KEY(IdVanzare)REFERENCES produse(IdProdus);
  125. ALTER TABLE compozitii ADD CONSTRAINT fk_compozitii FOREIGN KEY(IdProdus) REFERENCES produse(IdProdus);
  126. ALTER TABLE compozitii ADD CONSTRAINT fk_compozitii FOREIGN KEY(IdComponenta) REFERENCES componente(IdComponenta);
  127. ALTER TABLE achizitii ADD CONSTRAINT fk_achizitii FOREIGN KEY(IdFurnizor) REFERENCES furnizori(IdFurnizor);
  128. ALTER TABLE achizitii ADD CONSTRAINT fk_achizitii FOREIGN KEY(IdComponenta) REFERENCES componente(IdComponenta);
  129.  
  130.  
  131. SELECT *FROM dependenti;
  132. SELECT *FROM ingineri;
  133. SELECT *FROM secretare;
  134. SELECT *FROM angajati;
  135. SELECT *FROM sectii;
  136. SELECT *FROM achizitii;
  137. SELECT *FROM compozitii;
  138. SELECT *FROM vanzari;
  139. SELECT *FROM activitati;
  140. SELECT *FROM furnizori;
  141. SELECT *FROM componente;
  142. SELECT *FROM produse;
  143. SELECT *FROM clienti;
  144. SELECT *FROM proiecte;
  145.  
  146.  
  147. INSERT INTO sectii VALUES(1,'Vanzari',1241);
  148. INSERT INTO sectii VALUES(2,'Contabilitate',43242);
  149. INSERT INTO sectii VALUES(3,'IT',99999);
  150.  
  151. INSERT INTO angajati VALUES(1,'Dan','George','05/12/1998','Slatina',5000,3);
  152. INSERT INTO angajati VALUES(2,'Ion','Alex','04/01/1974','Craiova',7000,2);
  153. INSERT INTO angajati VALUES(3,'Popescu','George','07/27/1985','Slatina',2000,1);
  154.  
  155. INSERT INTO secretare VALUES(1,55);
  156.  
  157. INSERT INTO ingineri VALUES(2,'Mecanica');
  158.  
  159. INSERT INTO dependenti VALUES(1,'Dan','Mihai','12/28/1987',2);
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