SHARE
TWEET

Untitled

a guest Mar 20th, 2019 51 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 PRIMARY KEY,
  4.     Nume varchar(32),
  5.     Prenume varchar(32),
  6.     DataN datetime,
  7.     GradRudenie varchar(27)
  8. );
  9.  DROP TABLE Ingineri;
  10. CREATE TABLE Ingineri(
  11.     IdAngajat int NOT NULL PRIMARY KEY,
  12.     Specialitate varchar(32)
  13. );
  14.  DROP TABLE Secretare;
  15. CREATE TABLE Secretare(
  16.     IdAngajat int NOT NULL PRIMARY KEY,
  17.     VitezaRedactare int
  18. );
  19.  
  20. DROP TABLE Sectii;
  21. CREATE TABLE Sectii(
  22.     IdSectii int NOT NULL PRIMARY KEY,
  23.     Nume varchar(32),
  24.     Buget decimal
  25. );
  26.  
  27. DROP TABLE Angajati;
  28. CREATE TABLE Angajati(
  29.     IdAngajat int NOT NULL PRIMARY KEY,
  30.     Nume varchar(32),
  31.     Prenume varchar(32),
  32.     DataNasterii datetime,
  33.     Adresa varchar(42),
  34.     Functie varchar(26),
  35.     Salariu decimal,
  36.     IdSectie int
  37. );
  38.  
  39. DROP TABLE Achizitii;
  40. CREATE TABLE Achizitii(
  41.     IdAchizite int NOT NULL PRIMARY KEY,
  42.     IdFurnizor int,
  43.     IdComponenta int,
  44.     IdAchizitor int,
  45.     Data datetime,
  46.     NrComponente int,
  47.     PretUnitar decimal
  48. );
  49. DROP TABLE Compozitii;
  50. CREATE TABLE Compozitii(
  51.     IdComponenta int NOT NULL PRIMARY KEY,
  52.     IdProdus int,
  53.     NrComponente int
  54. );
  55. DROP TABLE Vanzari;
  56. CREATE TABLE Vanzari(
  57.     IdVanzare int NOT NULL PRIMARY KEY,
  58.     IdProdus int,
  59.     IdClient int,
  60.     IdVanzator int,
  61.     Data datetime,
  62.     NrProduse int
  63. );
  64. DROP TABLE Activitati;
  65. CREATE TABLE Activitati(
  66.     IdProiect int NOT NULL PRIMARY KEY,
  67.     IdAngajat int,
  68.     Ore int
  69. );
  70. DROP TABLE Furnizori;
  71. CREATE TABLE Furnizori(
  72.     IdFurnizor int NOT NULL PRIMARY KEY,
  73.     Nume varchar(32),
  74.     Prenume varchar(32),
  75.     Adresa varchar(42)
  76. );
  77. DROP TABLE Componente;
  78. CREATE TABLE Componente(
  79.     IdComponenta int NOT NULL PRIMARY KEY,
  80.     Denumire varchar(32),
  81.     Descriere varchar(64)
  82. );
  83. DROP TABLE Produse;
  84. CREATE TABLE Produse(
  85.     IdProdus int NOT NULL PRIMARY KEY,
  86.     Denumire varchar(32),
  87.     Descriere varchar(64)
  88. );
  89. DROP TABLE Clienti;
  90. CREATE TABLE Clienti(
  91.     IdClient int NOT NULL PRIMARY KEY,
  92.     Nume varchar(32),
  93.     Prenume varchar(32),
  94.     Adresa varchar(42)
  95. );
  96. DROP TABLE Proiecte;
  97. CREATE TABLE Proiecte(
  98.     IdProiect int NOT NULL PRIMARY KEY,
  99.     Denumire varchar(32),
  100.     Termen datetime,
  101.     Buget decimal
  102. );
  103.  
  104. ALTER TABLE Dependenti ADD CONSTRAINT fk_dependenti FOREIGN KEY(IdAngajat) REFERENCES Angajati(IdAngajat);
  105. ALTER TABLE Angajati ADD CONSTRAINT fk_angajati FOREIGN KEY(IdSectie) REFERENCES Sectii(IdSectie);
  106. ALTER TABLE Ingineri ADD CONSTRAINT fk_ingineri FOREIGN KEY(IdAngajat) REFERENCES Angajati(IdAngajat);
  107. ALTER TABLE Secretare ADD CONSTRAINT fk_secretare FOREIGN KEY(IdAngajat) REFERENCES Angajati(IdAngajat);
  108. ALTER TABLE Achizitii ADD CONSTRAINT fk_achizitii FOREIGN KEY(IdAchizitor) REFERENCES Angajati(IdAngajat);
  109. ALTER TABLE Vanzari ADD CONSTRAINT fk_vanzari FOREIGN KEY(IdVanzator) REFERENCES Angajati(IdAngajat);
  110. ALTER TABLE Activitati ADD CONSTRAINT fk_activitati FOREIGN KEY(IdAngajat) REFERENCES Angajati(IdAngajat);
  111. ALTER TABLE Achizitii ADD CONSTRAINT fk_achizitii2 FOREIGN KEY(IdFurnizor) REFERENCES Furnizori(IdFurnizor);
  112. ALTER TABLE Achizitii ADD CONSTRAINT fk_achizitii3 FOREIGN KEY(IdComponenta) REFERENCES Componente(IdComponenta);
  113. ALTER TABLE Compozitii ADD CONSTRAINT fk_compozitii FOREIGN KEY(IdComponenta) REFERENCES Componente(IdComponenta);
  114. ALTER TABLE Compozitii ADD CONSTRAINT fk_compozitii2 FOREIGN KEY(IdProdus) REFERENCES Produse(IdProdus);
  115. ALTER TABLE Vanzari ADD CONSTRAINT fk_vanzari2 FOREIGN KEY(IdVanzare) REFERENCES Produse(IdProdus);
  116. ALTER TABLE Vanzari ADD CONSTRAINT fk_vanzari3 FOREIGN KEY(IdClient) REFERENCES Clienti(IdClient);
  117. ALTER TABLE Activitati ADD CONSTRAINT fk_activitati2 FOREIGN KEY(IdProiect) REFERENCES Proiecte(IdProiect);
  118.  
  119. INSERT INTO Sectii VALUES(1,'Vanzari',2300);
  120. INSERT INTO Sectii VALUES(2,'HR',2500);
  121. INSERT INTO Sectii VALUES(3,'Technical Support',1900);
  122.  
  123. INSERT INTO Angajati VALUES(1,'Alex','Ion','02/02/1998','Filiasi','Vanzator',800,1);
  124. INSERT INTO Angajati VALUES(2,'Marius','Bobel','04/08/1997','Catane','Resurse umane',1100,2);
  125. INSERT INTO Angajati VALUES(3,'Bobi','Mondialu','02/12/1988','Craiova','QA',120,3);
  126.  
  127. INSERT INTO Ingineri VALUES(2,'Inginer tehnic');
  128.  
  129. INSERT INTO Secretare VALUES(1,200);
  130.  
  131. SELECT * FROM Secretare;
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