I would like to design a table named arguments
whose an attribute name
is linked to another attribute name
in a table called names
.
I see two ways to express it in SQL:
by creating a constraint on the table:
CREATE TABLE names ( name text UNIQUE, short text UNIQUE, comment text); CREATE TABLE arguments ( name text UNIQUE, comment text, FOREIGN KEY (name) REFERENCES names (name));
by qualifying the attribute on-the-fly:
CREATE TABLE names ( name text UNIQUE, short text UNIQUE, comment text); CREATE TABLE arguments ( name text UNIQUE REFERENCES names (name), comment text);
I would like to know:
- if one of the two is commonly known as better than the other, and
- if it can have consequences that I should be aware of.
Thank you for your help.