Skip to content

Instantly share code, notes, and snippets.

@MrSnyder
Created February 19, 2020 12:04
Show Gist options
  • Save MrSnyder/c495bc4b839676a568fdec80f29b4765 to your computer and use it in GitHub Desktop.
Save MrSnyder/c495bc4b839676a568fdec80f29b4765 to your computer and use it in GitHub Desktop.
Data Modelling cheatsheet

Data Modelling Cheatsheet

Identifying relations

A relation between two tables A and B where a foreign key of A is (part of) the primary key of B.

CREATE TABLE AuthoredBook (
  author_id INT NOT NULL,
  book_id INT NOT NULL,
  PRIMARY KEY (author_id, book_id),
  FOREIGN KEY (author_id) REFERENCES Authors(author_id),
  FOREIGN KEY (book_id) REFERENCES Books(book_id)
);

The relations Authors:AuthoredBook and Books:AuthoredBooks are identifying.

https://stackoverflow.com/questions/2814469/still-confused-about-identifying-vs-non-identifying-relationships/2814663#2814663

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment