question

NurRohadatulAisyBteRozmin-9759 avatar image
0 Votes"
NurRohadatulAisyBteRozmin-9759 asked ·

how do i solve this?

/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.

qna-help-article
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

VaibhavChaudhari avatar image
1 Vote"
VaibhavChaudhari answered ·

Error message: There is already an object named 'College' in the database.

Looks like there is already a table named College in your database. Either rename it to Collect_bkp or drop it using query DROP TABLE College and then run your create table script


If the response helped, do "Accept Answer" and upvote it - Vaibhav

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

22209943 avatar image
0 Votes"
22209943 answered ·

Alt/Option+F10

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.