May a 6NF Table contain a foreign key?

270 views Asked by At

Does a table satisfy 6NF when it's domain is a foreign key? E.g.:

CREATE TABLE authors(
    author_id serial NOT NULL PRIMARY KEY
);

-- other author attributes

CREATE TABLE books(
    book_id serial NOT NULL PRIMARY KEY
);

CREATE TABLE books_author(
    book_id int NOT NULL PRIMARY KEY REFERENCES books (book_id),
    author_id int NOT NULL REFERENCES authors (author_id)
);

If no, how should the model handle the foreign key relationship?

And if the relation where M2M, how should that be handled? should the join table also be 6NF?

1

There are 1 answers

0
nvogel On BEST ANSWER

6NF means a relvar satisfies no non-trivial join dependencies, which means it has a candidate key and at-most one other attribute. There may or may not be foreign keys. All the normal forms are unrelated to whether foreign keys are defined.

Not sure what your question about M2M is. When and where you use 6NF depends on your motivation for using it in general. Its main use is for data warehouse and temporal data models.