--inserted smoothley as it authorID present in author TABLE when inserting it in book TABLE
INSERTINTOBookVALUES(1,'Book1',1),(2,'Book2',2);
--Msg 547, Level 16, State 0, Line 127
--The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Book__AuthorID__76969D2E". The conflict occurred in database "Assignment1", TABLE "dbo.Author", COLUMN 'AuthorId'.
--here author with ID 3 is not present so Error occured.
INSERTINTOBookVALUES(3,'Book1',3);
--Try to INSERT the NULL VALUES INTO FOREIGN KEY TABLE
INSERTINTOBook(BookId,BookName)VALUES(3,'Book1');
INSERTINTOBook(BookId,BookName)VALUES(4,'Book1');
SELECT*FROMBook;
-- explicitly we need to mention NOT NULL for the FOREIGN KEY COLUMN
-- otherwise it accepts null VALUES meaning that book inserted without an author