H
H
HaruAtari2013-12-09 13:06:34
SQL
HaruAtari, 2013-12-09 13:06:34

Null value for foreign key?

There are two tables (schematic):
user
id - int not null pk
name - varchar(255) not null
title
id - int not null pk,
name - varchar(255) nit null
user_id - int
The title.user_id field refers to user.id as a foreign key. Question: Is null allowed in the title.user_id field?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
egor_nullptr, 2013-12-09
@HaruAtari

Permissible. Don't forget to add ON DELETE SET NULL in the FK description.

A
Andrey Simonov, 2013-12-09
@AntLogist

For MS SQL - yes,
probably depends on the DBMS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question