I am doing my first database project.
I would like to know why you should use NOT NULL
in the following query
...
TITLE nvarchar(60) NOT NULL
..
Context
CREATE TABLE Questions
(
USER_ID integer FOREIGN KEY
REFERENCES User_info(USER_ID)
PRIMARY KEY
CHECK (USER_ID>0),
QUESTION_ID integer FOREIGN KEY REFERENCES Tags(QUESTION_ID)
NOT NULL
CHECK (USER_ID>0),
QUESTION_BODY nvarchar(4000) NOT NULL,
TITLE nvarchar(60) NOT NULL, /////// HERE
MODERATOR_REMOVAL boolean NOT NULL,
SENT_TIME varchar(15) NOT NULL
)
I watched VPuml's tutorial. They put all values in Logical diagram nullable, while all the rest NOT NULL
. This suggests me that nullable should be used with logical diagrams.
Is there any other use of not null in databases?
I feel that we can check that the user gives value by JS, for instance, not at a database level.