Perhaps I am looking at my entities as a hierarchy rather than a set of relationships; for sake of an example I have three tables:
- Authors
- Books
- Content
Where Authors writes Books and Books contain content.
The rules for these entities is as follows:
- Content cannot stand alone without association to a Book
- a Book cannot stand alone without association to an Author
See below the following partial implementation:
CREATE TABLE authors( author_id integer, author_name varchar, author_age int, PRIMARY KEY (author_id) ); CREATE TABLE books( book_id integer, author_id integer, book_title varchar, book_published date, PRIMARY KEY (book_id, author_id), FOREIGN KEY (author_id) REFERENCES authors(author_id) );
From here I believe I have created a relationship where Books relies on Authors, should it decide to exist.
Arguably some may say that Content can simply just be part of Books, but say that Content has a hefty amount of columns in association to it and that a person would prefer to keep the more general Book data separate from its Content data for simplicity purposes.
In the event of the latter, how can I write a create statement that will make Content dependent on Books?