SCRIPTDB
SCRIPTDB
------------------------------------------------Use UniversityDatabase;
----------------------------------------------create table StudentTable (ID
varchar(50) not null, Name varchar(100), FatherName varchar(100), DepartmentID int,
BID int, DOB date, Marks float, Status varchar(20));
--------------------------------------------select *from studenttable;
--------------------------------------------create table Kankor(BID int not null,
BName varchar(50), BAbr varchar(50));
--------------------------------------------create table Semester(SemesterID int
not null, SemesterName varchar(50), SemesterAbr nvarchar(50));
------------------------------------------create table MarksTable(ID varchar(50)
not null, SemesterID int not null, CourseID bigint, TotalObtained float);
----------------------------------------create table Departments(DepartmentID int
not null, DeptName varchar(100), DeptAbr varchar(50), Duration int);
--------------------------------------create table CourseTable(CourseID bigint
IDENTITY(1,1) not null, CourseCode varchar(20), CourseName varchar(150), Credits
int)
------------------------------------create table AttendanceTable(ID varchar(50) not
null, SemesterID int not null, CourseID bigint, HourNumber int, AttendanceStatus
bit)
--------------------------------Alter table Kankor Add Primary Key(BID);
------------------------------Alter table Departments Add Primary
Key(DepartmentID);
----------------------------Alter table CourseTable Add Primary Key(CourseID);
--------------------------Alter table StudentTable Add Foreign Key(DepartmentID)
--------------------------References Departments (DepartmentID);
------------------------Alter table StudentTable Add Foreign Key(BID)
------------------------References KANKOR (BID);
----------------------Alter table MarksTable Add Foreign Key(ID)
----------------------References StudentTable (ID);
--------------------Alter table MarksTable Add Foreign Key(SemesterID)
--------------------References Semester (SemesterID);
------------------Alter table MarksTable Add Foreign Key(CourseID)
------------------References CourseTable (CourseID);
----------------Alter table AttendanceTable Add Foreign Key(ID)
----------------References StudentTable (ID);
--------------Alter table AttendanceTable Add Foreign Key(SemesterID)
--------------References Semester (SemesterID);
------------Alter table AttendanceTable Add Foreign Key(CourseID)
------------References CourseTable (CourseID);
----------insert into Kankor(BID, BName, BAbr)
----------Values (1,'First','A1'), (2,'Second','A2'), (3,'Third','A3');
----INSERT INTO DEPARTMENTS(DEPARTMENTID, DEPTNAME, DEPTABR, DURATION)
----VALUES (1,'Computer Science','CS', 8), (2,'Engineering','EE', 8);
----INSERT INTO CourseTable(CourseCode, CourseName, Credits)
----VALUES ('DB101', 'Advanced Database', 4), ('SE101', 'Software Engineering', 3),
('OS101', 'Operating System', 4),
----('ED202', 'Engineering Drawing', 4), ('Ph202', 'Physics', 3);
----INSERT INTO Semester(SemesterID, SemesterName, SemesterAbr)
----VALUES (1,'First','I'), (2,'Second','II'), (3,'Third','III'),
(4,'Fourth','IV'), (5,'Fifth','V'), (6,'Sixth','VI'), (7,'Seventh','VII'),
(8,'Eighth','VIII');
----INSERT INTO StudentTable(ID, Name, FatherName, DepartmentID, BID, DOB, Marks,
Status)
----VALUES ('CS-1', 'Aimal', 'AbdulHadi', 1, 1, '1997-12-17', 100, 1), ('CS-2',
'Ajmal', 'AbdulHadi', 1, 1, '1995-12-17', 100, 1), ('CS-3', 'Faisal', 'AbdulHadi',
1, 1, '1998-12-17', 90, 1),
----('CS-4', 'Munir', 'Karim', 1, 1, '1997-12-17', 50, 0), ('CS-5', 'Ahmad',
'Khaliq', 1, 1, '1990-12-17', 80, 1), ('CS-6', 'Hasibullah', 'Janan', 1, 1, '1997-
12-17', 50, 0), ('CS-7', 'Qadershah', 'Momin', 1, 1, '1995-12-17', 50, 0), ('CS-8',
'Nasir', 'Muhib', 1, 1, '1997-12-19', 100, 1), ('EE-10', 'Anwar', 'AbdulHadi', 2,
2, '1997-12-17', 100, 1);
----INSERT INTO AttendanceTable(ID, SemesterID, CourseID, HourNumber,
AttendanceStatus)
----VALUES ('CS-1', 1, 1, 1, 1), ('CS-2', 1, 1, 1, 1), ('CS-3', 1, 1, 1, 1), ('CS-
4', 1, 1, 1, 1), ('CS-5', 1, 1, 1, 1), ('CS-6', 1, 1, 1, 1), ('CS-7', 1, 1, 1, 1),
('CS-8', 1, 1, 1, 1), ('EE-10', 1, 1, 1, 1);
----INSERT INTO StudentTable(ID, Name, FatherName, DepartmentID, BID, DOB, Marks,
Status)
----VALUES ('EE-11', 'Hanan', 'Ashraf', 1, 1, '1997-12-17', 50, 0);
----INSERT INTO AttendanceTable(ID, SemesterID, CourseID, HourNumber,
AttendanceStatus)
----VALUES ('EE-11', 1, 1, 1, 1);
----From View_CreditMultipliedMarks
----Group BY SemesterID, ID;
----GO
-------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------
--Declare @ID varchar(50);
--SET @ID = 'CS-3';
-------------------------------------------------------------------