Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- USE master
- go
- if exists (select 'true' from sys.databases where name = 'Colegiu')
- begin
- ALTER DATABASE Colegiu
- SET SINGLE_USER
- WITH ROLLBACK IMMEDIATE;
- drop database Colegiu
- end
- GO
- set dateformat dmy
- GO
- create database Colegiu
- GO
- Use Colegiu
- GO
- exec sp_changedbowner 'sa'
- GO
- Create table Catedre
- (
- idcatedre int primary key
- ,nmcatedre Char(50) Unique
- ,idprofesor INT
- )
- Go
- -- Crearea tabelei Objstud
- Create table objstud
- (
- idobjstud int primary key
- ,mnobjstud Char(50) unique
- ,idcatedre INT Default 1
- )
- Go
- Create table Profesor
- (
- idprofesor INT PRIMARY KEY
- ,nmprofesor Char(50) Unique
- )
- GO
- Create table ObjStGr
- (
- idobjstgr INT primary key
- ,idgrupa INT
- ,idobjstud INT
- ,idprofesor INT
- )
- GO
- Create table grupa
- (
- idgrupa INT PRIMARY KEY
- ,nmgrupa Char(50)Unique
- ,anadm INT
- ,idprofesor INT
- ,idspec INT
- )
- GO
- Create table student
- (
- idstudent INT Primary key
- ,nmstud char(50)
- ,prenstud char(50)
- ,patrstud char(50)
- ,sexstud Char(1) Check (sexstud='m' or sexstud='f')
- ,Ncarnet char(10)
- ,DataNs Date
- ,GSM char(15)
- ,idgrupa INT
- ,idlocalit INt
- )
- GO
- Create table raion
- (
- idraion INT Primary key
- ,nmraion char(50) Unique
- )
- Go
- Create table spec
- (
- idspec INT primary key
- ,nmspec char(50) Unique
- )
- GO
- Create table localit
- (
- idlocalit INT Primary key
- ,nmlocalit char(50)Unique
- ,idraion INT
- )
- GO
- Create table notele
- (
- idnotele INT primary key
- ,idstudent INT
- ,Idobjstud INT
- ,data date
- ,nota decimal(4,2) Check(1<=nota and nota<=10)
- )
- Go
- Alter table catedre
- Add constraint Fk_Catedre_idprofesor
- Foreign key (idprofesor) references profesor (idprofesor)
- Alter table objstud
- Add constraint Fk_ObjStud_idcatedre
- Foreign key (idcatedre) references catedre (idcatedre)
- Alter table grupa
- Add constraint Fk_grupa_idprofesor
- Foreign key (idprofesor) references profesor (idprofesor)
- Alter table grupa
- Add constraint Fk_grupa_idspec
- Foreign key (idspec) references spec (idspec)
- Alter table objstgr
- Add constraint Fk_objstr_idprofesor
- Foreign key (idprofesor) references profesor (idprofesor)
- Alter table objstgr
- Add constraint Fk_objstr_idgrupa
- Foreign key (idgrupa) references grupa (idgrupa)
- Alter table objstgr
- Add constraint Fk_objstr_idobjstud
- Foreign key (idobjstud) references objstud (idobjstud)
- Alter table student
- Add constraint Fk_student_idgrupa
- Foreign key (idgrupa) references grupa (idgrupa)
- Alter table student
- Add constraint Fk_student_idlocalit
- Foreign key (idlocalit) references localit (idlocalit)
- Alter table localit
- Add constraint Fk_localit_idraion
- Foreign key (idraion) references raion (idraion)
- Alter table notele
- Add constraint Fk_notele_idstudent
- Foreign key (idstudent) references student (idstudent)
- Alter table notele
- Add constraint Fk_notele_idobjstud
- Foreign key (idobjstud) references objstud (idobjstud)
- GO
- --**************|| inserarile ||***********************
- Use Colegiu
- select *
- from raion
- go
- insert into profesor (idprofesor,nmprofesor)
- values (1,'Damaschin I.')
- ,(2,'Golub A.')
- ,(3,'Jalba R.')
- ,(4,'Gonta V.')
- ,(5,'Frunza O.')
- ,(6,'Pasecinic I.')
- ,(7,'Ciobanu A.')
- ,(8,'Melnic L.')
- ,(9,'Petrovshi A.')
- ,(10,'Botnariuc L.')
- ,(11,'Cotorcea C.')
- ,(12,'Polucci T.')
- ,(13,'Lisnic B.')
- ,(14,'Manea C.')
- ,(15,'Goreanu I.')
- ,(16,'Cosulean A.')
- ,(17,'Mihailov T.')
- ,(18,'Cuznetov A.')
- ,(19,'Talmaci N.')
- ,(20,'Bulat V.');
- go
- insert into raion (idraion,nmraion)
- values (1,'Anenii Noi')
- ,(2,'Basarabeasca')
- ,(3,'Balti')
- ,(4,'Briceni')
- ,(5,'Cahul')
- ,(6,'Cantemir')
- ,(7,'Calarasi')
- ,(8,'Causeni')
- ,(9,'Chisinau')
- ,(10,'Cimislia')
- ,(11,'Criuleni')
- ,(12,'Donduseni')
- ,(13,'Drochia')
- ,(14,'Dubasari')
- ,(15,'Edinet')
- ,(16,'Falesti')
- ,(17,'Floresti')
- ,(18,'Glodeni')
- ,(19,'Hincesti')
- ,(20,'Ialoveni')
- ,(21,'Leova')
- ,(22,'Nisporeni')
- ,(23,'Ocnita')
- ,(24,'Orhei')
- ,(25,'Rezina')
- ,(26,'Riscani')
- ,(27,'Singerei')
- ,(28,'Soroca')
- ,(29,'Straseni')
- ,(30,'Soldanesti')
- ,(31,'Stefan Voda')
- ,(32,'Taraclia')
- ,(33,'Telenesti')
- ,(34,'Ungheni')
- ,(35,'UTA Gagauzia')
- ,(36,'Transnistria');
- go
- insert into spec (idspec,nmspec)
- values (1,'Informatica')
- ,(2,'Contabilitate')
- ,(3,'Secretariat-birotica')
- ,(4,'Finante')
- ,(5,'Turism')
- ,(6,'Calculatoare')
- ,(7,'Administrarea aplicatiilor Web')
- ,(8,'Retele calculatoare')
- ,(9,'Servicii administrative si de secretariat')
- ,(10,'Operator pentru suportul tehnic al calculatoarelor');
- go
- insert into localit (idraion,nmlocalit,idlocalit)
- values (1 ,'Anenii Noi',1)
- ,(1 ,'Botnaresti',2)
- ,(1 ,'Calfa',3)
- ,(2 ,'Basarabeasca',4)
- ,(2 ,'Sadaclia',5)
- ,(2 ,'Carabetovca',6)
- ,(3 ,'Balti',7)
- ,(3 ,'Sadovoe',8)
- ,(3 ,'Elizaveta',9)
- ,(4 ,'Briceni',10)
- ,(4 ,'Balcauti',11)
- ,(4 ,'Bulboaca',12)
- ,(5 ,'Cahul',13)
- ,(5 ,'Borceag',14)
- ,(5 ,'Bucuria',15)
- ,(6 ,'Cantemir',16)
- ,(6 ,'Cirpesti',17)
- ,(6 ,'Baimaclia',18)
- ,(7 ,'Calarasi',19)
- ,(7 ,'Bahmut',20)
- ,(7 ,'Buda',21)
- ,(8 ,'Causeni',22)
- ,(8 ,'Cainari',23)
- ,(8 ,'Baurci',24)
- ,(9 ,'Chisinau',25)
- ,(9 ,'Singera',26)
- ,(9 ,'Codru',27)
- ,(10,'Cimislia',28)
- ,(10,'Batir',29)
- ,(10,'Mihailovca',30)
- ,(11,'Criuleni',31)
- ,(11,'Boscana',32)
- ,(11,'Cimiseni',33)
- ,(12,'Donduseni',34)
- ,(12,'Baraboi',35)
- ,(12,'Horodiste',36)
- ,(13,'Drochia',37)
- ,(13,'Chetrosu',38)
- ,(13,'Baroncea',39)
- ,(14,'Dubasari',40)
- ,(14,'Cosnita',41)
- ,(14,'Cocieri',42)
- ,(15,'Edinet',43)
- ,(15,'Buzdugeni',44)
- ,(15,'Blenesti',45)
- ,(16,'Falesti',46)
- ,(16,'Chetris',47)
- ,(16,'Bocsa',48)
- ,(17,'Floresti',49)
- ,(17,'Casunca',50)
- ,(17,'Capresti',51)
- ,(18,'Glodeni',52)
- ,(18,'Cajba',53)
- ,(18,'Camenca',54)
- ,(19,'Hincesti',55)
- ,(19,'Cioara',56)
- ,(19,'Carpineni',57)
- ,(20,'Ialoveni',58)
- ,(20,'Bardar',59)
- ,(20,'Alexandrovca',60)
- ,(21,'Leova',61)
- ,(21,'Ceadir',62)
- ,(21,'Cneazevca',63)
- ,(22,'Nisporeni',64)
- ,(22,'Cirnesti',65)
- ,(22,'Gaureni',66)
- ,(23,'Ocnita',67)
- ,(23,'Berezovca',68)
- ,(23,'Codreni',69)
- ,(24,'Orhei',70)
- ,(24,'Breanova',71)
- ,(24,'Cismea',72)
- ,(25,'Rezina',73)
- ,(25,'Buciusca',74)
- ,(25,'Ciorna',75)
- ,(26,'Riscani',76)
- ,(26,'Balanu Nou',77)
- ,(26,'Ciobanovca',78)
- ,(27,'Singerei',79)
- ,(27,'Bobletici',80)
- ,(27,'Chirileni',81)
- ,(28,'Soroca',82)
- ,(28,'Baliniti',83)
- ,(28,'Cerlina',84)
- ,(29,'Straseni',85)
- ,(29,'Ciobanca',86)
- ,(29,'Gornoe',87)
- ,(30,'Soldanesti',88)
- ,(30,'Cot',89)
- ,(30,'Cuselauca',90)
- ,(31,'Stefan Voda',91)
- ,(31,'Lazo',92)
- ,(31,'Olanesti',93)
- ,(32,'Taraclia',94)
- ,(32,'Ciumai',95)
- ,(32,'Chrilovca',96)
- ,(33,'Telenesti',97)
- ,(33,'Chersac',98)
- ,(33,'Ciofu',99)
- ,(34,'Ungheni',100)
- ,(34,'Bulhac',101)
- ,(34,'Cornesti',102)
- ,(35,'Comrat',103)
- ,(35,'Vulcanesti',104)
- ,(35,'Cazaclia',105)
- ,(36,'Bender',106)
- ,(36,'Ribnita',107)
- ,(36,'Tiraspol',108);
- go
- insert into Catedre(idcatedre,idprofesor,nmcatedre)
- values (1,5,'Informatica')
- ,(2,7,'Informatica Aplicata')
- ,(3,20,'Economii')
- ,(4,10,'Limba si literatura romana')
- ,(5,14,'Limbi straine')
- ,(6,9,'Matematica')
- ,(7,8,'Istorie si stiinte socioumane')
- ,(8,11,'Chimie, biologie si fizica')
- ,(9,16,'Educatia fizica');
- go
- insert into objstud (idcatedre,idobjstud,mnobjstud)
- values (4,1,'Limba Romana')
- ,(6,2,'Matematica')
- ,(1,3,'Informatica')
- ,(2,4,'Adm. Web')
- ,(9,16,'Educatia fizica')
- ,(8,5,'Chimia')
- ,(8,6,'Biologie')
- ,(8,7,'Fizica')
- ,(7,8,'Geografia')
- ,(7,9,'Istoria')
- ,(7,10,'Filozofia')
- ,(5,11,'Limba engleza')
- ,(5,12,'Limba franceza')
- ,(3,13,'Contabilitatea')
- ,(2,14,'Adm. BD')
- ,(1,15,'POO');
- go
- insert into grupa (idgrupa,idprofesor,idspec,nmgrupa,anadm)
- values (1,1,1,'I-1432',2014)
- ,(2,2,1,'I-1522',2015)
- ,(3,3,2,'C-1345',2013)
- ,(4,4,2,'C-1521',2015)
- ,(5,5,3,'SB-1612',2016)
- ,(6,6,3,'SB-1342',2013)
- ,(7,7,4,'F-1524',2015)
- ,(8,8,4,'F-1431',2014)
- ,(9,9,5,'T-1612',2016)
- ,(10,10,5,'T-1341',2013)
- ,(11,11,6,'K-1521',2015)
- ,(12,12,6,'K-1610',2016)
- ,(13,13,7,'W-1611',2016)
- ,(14,14,7,'W-1612',2016)
- ,(15,15,8,'R-1432',2014)
- ,(16,16,8,'R-1522',2015)
- ,(17,17,9,'S-1614',2016)
- ,(18,18,9,'S-1345',2013)
- ,(19,19,10,'O-1615',2016)
- ,(20,20,10,'O-1522',2015);
- go
- insert into student (idstudent,Ncarnet,idgrupa,idlocalit,nmstud,patrstud
- ,prenstud,DataNs,GSM,sexstud)
- values (1,101,1,1,'Iscanderov','Rustamovici','Ebraghim','16.04.1997','067985662','m'),
- (2,102,2,12,'Coliban','Eugen','Serghei','22.10.1998','029756897','m')
- ,(3,103,3,23,'Petrovschi','Andreea','Igor','06.06.1999','079634567','f')
- ,(4,104,4,34,'Sula','Valeriu','Dumitru','07.08.1996','069556789','m')
- ,(5,105,5,45,'Munteanu','Valeria','Valeriu','24.02.1996','079876895','f')
- ,(6,106,6,56,'Railean','Vitalie','Ion','13.04.1998','067987654','m')
- ,(7,107,7,67,'Gribov', 'Corina','Vladimir','14.06.1999','07986543','f')
- ,(8,108,8,78,'Morosan','Ion','Lilian','16.09.1996','0786912345','m')
- ,(9,109,9,89,'Cazacu','Cristian','Anatolie','08.09.1996','079546325','m')
- ,(10,110,10,100,'Organ','Igor','Igor','24.07.1998','067895436','m')
- ,(11,111,11,11,'Donoaga','Elena','Efim','05.07.1999','079856782','f')
- ,(12,112,12,22,'Prodan','Vladimir','Alexandru','06.09.1999','029456789','m')
- ,(13,113,13,33,'Cojocaru','Liviu','Igor','29.08.1996','079865743','m')
- ,(14,114,14,44,'Morari','Sandu','Alexandr','17.7.1997','079865456','m')
- ,(15,115,15,55,'Barba','Pavel','Fiodor','19.9.1998','067898769','m')
- ,(16,116,16,66,'Elenciuc','Anastasia','Anatolii','21.11.1999','076589709','f')
- ,(17,117,17,77,'Gubciac','Cristian','Mihail','28.12.1997','067891245','m')
- ,(18,118,18,88,'Sarmaniuc','Alexandrina','Mihail','05.05.1997','069878943','f')
- ,(19,119,19,98,'Gaulica','Vlad','Valeriu','06.11.1998','078965489','m')
- ,(20,120,20,108,'Bandalac','Sergiu','Sergiu','13.12.1999','027896456','m')
- ;
- go
- insert into ObjStGr(idgrupa,idobjstgr,idobjstud,idprofesor)
- values (1,1,4,1)
- ,(2,2,5,1)
- ,(3,3,4,5)
- ,(4,4,3,2);
- go
- insert into notele(idnotele,Idobjstud,idstudent,data,nota)
- values (1,1,1,'06.10.2016',10)
- ,(2,1,2,'07.09.2016',7)
- ,(3,2,3,'09.09.2016',6)
- ,(4,2,4,'10.09.2016',5)
- ,(5,3,5,'11.09.2016',4)
- ,(6,3,6,'12.10.2016',8)
- ,(7,4,7,'13.09.2016',9)
- ,(8,4,8,'14.09.2016',10)
- ,(9,5,9,'15.10.2016',10)
- ,(10,5,10,'16.09.2016',6)
- ,(11,6,11,'19.10.2016',5)
- ,(12,7,12,'20.10.2016',9)
- ,(13,7,13,'25.09.2016',8)
- ,(14,8,14,'26.10.2016',4)
- ,(15,8,15,'27.10.2016',5)
- ,(16,9,16,'26.09.2016',7)
- ,(17,9,17,'15.10.2016',9)
- ,(18,10,18,'16.09.2016',10)
- ,(19,10,19,'16.10.2016',9)
- ,(20,11,20,'25.10.2016',7)
- ,(21,11,19,'4.09.2016',8)
- ,(22,12,3,'14.10.2016',8)
- ,(23,12,4,'17.10.2016',8)
- ,(24,13,7,'06.09.2016',6)
- ,(25,13,9,'11.10.2016',5)
- ,(26,6,5,'05.10.2016',4)
- ,(27,14,6,'06.09.2016',9)
- ,(28,14,7,'16.10.2016',10)
- ,(29,15,15,'26.09.2016',10)
- ,(30,15,12,'19.10.2016',7);
- go
- use master
- go
Advertisement
Add Comment
Please, Sign In to add comment