/*Create College table */
Use SigmaUniversity;
GO
Create table College (
CollegeCode int not null,
CollegeName nvarchar(50) not null,
DeanFirstName nvarchar(50) not null,
DeanLastName nvarchar(50) not null,
DeanEmail nvarchar(50) not null,
Constraint CollegePK Primary key (CollegeCode),
Constraint CollegeNameValues check (CollegeName in ('College in Business', 'College of Engineering'))
);
/* Create table Department */
Create table Department (
DepartmentCode INT NOT NULL Primary Key,
DepartmentName NCHAR(50) NOT NULL,
CollegeCode INT not NULL,
CONSTRAINT FK_Department_College FOREIGN KEY (CollegeCode)
REFERENCES College,
Constraint DeptNameValue Check (DepartmentName in ('Accounting','Economics', 'Finance', 'Civil Engineering', 'Computer Engineering', 'Electronics Engineering'))
);
/*Create table Professor */
Create table Professor (
ProfessorCode INT NOT NULL Primary Key,
FirstName NCHAR (50) NOT NULL,
LastName NCHAR (50) NOT NULL,
Email NChar (50) NOT NULL,
DepartmentCode Int Not null,
CONSTRAINT FK_Prof_Dept FOREIGN KEY (DepartmentCode) REFERENCES Department
);
/*Create Student table */
Create table Student (
StudentCode int not null,
FirstName nvarchar(50) not null,
LastName nvarchar(50) not null,
Email nvarchar(50) not null,
RegisterDate date not null,
DepartmentCode int not null,
constraint StudentPK primary key (StudentCode),
constraint DepartmentFK2 foreign key (DepartmentCode)
references Department (DepartmentCode)
);
Error message:
There is already an object named 'College' in the database.