Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
stephyzzz
Starting Member
2 Posts |
Posted - 2010-03-08 : 08:15:51
|
| hello guys i needed some help regarding thisi having this problem by the system saying"The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Register__semest__6991A7CB". The conflict occurred in database "master", table "dbo.Semester", column 'SemesterID'."The following is my tables CREATE Table Student ( stdNO Char(5) PRIMARY KEY, login Char(6), lastName VARCHAR (25), givenNames VARCHAR (50), programCode CHAR (4) ) CREATE Table Course ( courseID Char (8) PRIMARY KEY, cName VARCHAR (25), credits INT )CREATE Table Semester (SemesterID INT PRIMARY KEY,Semester INT,year INT )CREATE TABLE Register (stdNo CHAR(5),courseID CHAR(8),semesterID INT REFERENCES Semester ON UPDATE CASCADE ON DELETE NO ACTION,grade ChAR (2),mark DECIMAL(5,2) DEFAULT 0.0,PRIMARY KEY ( stdNO,courseID,semesterID),CONSTRAINT fkRegisterStd FOREIGN KEY(stdNo)REFERENCES Student(stdNo) ON UPDATE CASCADE ON DELETE NO ACTION,FOREIGN KEY(courseID)REFERENCES Course(courseID) ON UPDATE CASCADE ON DELETE NO ACTION ) i dun get it why the system dun allow me to insert values into the Register table..plus i dun understand this portion " CONSTRAINT fkRegisterStd FOREIGN KEY (stdNo) "what it mean?sorry needed some help |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-03-08 : 09:01:34
|
| The above error says that you are trying to insert a value into StdNo column in Register table which is not in StdNo column in Student table.In this case the above foreign key raises error. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-08 : 09:43:41
|
quote: Originally posted by raky The above error says that you are trying to insert a value into StdNo column in Register table which is not in StdNo column in Student table.In this case the above foreign key raises error.
Nope see error message once againThe INSERT statement conflicted with the FOREIGN KEY constraint "FK__Register__semest__6991A7CB". The conflict occurred in database "master", table "dbo.Semester", column 'SemesterID'so its actually caused by insertion of value of semesterID into table Register which is not present in master table Semester------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-03-08 : 09:48:33
|
quote: Originally posted by visakh16
quote: Originally posted by raky The above error says that you are trying to insert a value into StdNo column in Register table which is not in StdNo column in Student table.In this case the above foreign key raises error.
Nope see error message once againThe INSERT statement conflicted with the FOREIGN KEY constraint "FK__Register__semest__6991A7CB". The conflict occurred in database "master", table "dbo.Semester", column 'SemesterID'so its actually caused by insertion of value of semesterID into table Register which is not present in master table Semester------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
actually i explained the part i dun get it why the system dun allow me to insert values into the Register table..plus i dun understandthis portion" CONSTRAINT fkRegisterStd FOREIGN KEY (stdNo) "what it mean? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-08 : 09:52:16
|
quote: Originally posted by raky
quote: Originally posted by visakh16
quote: Originally posted by raky The above error says that you are trying to insert a value into StdNo column in Register table which is not in StdNo column in Student table.In this case the above foreign key raises error.
Nope see error message once againThe INSERT statement conflicted with the FOREIGN KEY constraint "FK__Register__semest__6991A7CB". The conflict occurred in database "master", table "dbo.Semester", column 'SemesterID'so its actually caused by insertion of value of semesterID into table Register which is not present in master table Semester------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
actually i explained the part i dun get it why the system dun allow me to insert values into the Register table..plus i dun understandthis portion" CONSTRAINT fkRegisterStd FOREIGN KEY (stdNo) "what it mean?
OP just wants to know the meaning of that statement. thats what he/she asked the error message posted is obvious to understand where exactly is problem------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
stephyzzz
Starting Member
2 Posts |
Posted - 2010-03-10 : 03:37:37
|
| hello..yap..i am confused over this "fkRegisterStd"??what it meants??and why semesterID so special, I declare this way?semesteriD Interger .....why i dun place it underConstraints together with courseID and stdNo?help pls thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-03-10 : 11:49:13
|
quote: Originally posted by stephyzzz hello..yap..i am confused over this "fkRegisterStd"??what it meants??and why semesterID so special, I declare this way?semesteriD Interger .....why i dun place it underConstraints together with courseID and stdNo?help pls thanks
Its the name given to FOREIGN KEY constraint that connects Register.stdNo to Student.stdNosorry didnt understand your second question------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|