+ 1
Constraint ?
what is constraint , I found that is the rule for the data type of the table, but i'm still confused , when I have to use it ? for example : CREATE TABLE Orders ( OrderID int NOT NULL, OrderNumber int NOT NULL, PersonID int, PRIMARY KEY (OrderID), CONSTRAINT FK_PersonOrder FOREIGNKEY (PersonID) REFERENCES Persons(PersonID) );
4 ответов
+ 2
It says that in order to INSERT a line, an entry with the same PersonID must be in table Persons.
+ 2
OK but why I have to put the constraint key , why I can't do just this ..... FK_PersonOrder FOREIGNKEY (PersonID) REFERENCES Persons(PersonID) ?
+ 2
Because you have to start with some keyword. Fk_PersonOrder is the name for the foreign key.
If the CONSTRAINT wasn't there the line would start with the name.
+ 2
AAA I get it now , thank you ,
it was really helpful , because I am going to pass an exam on it