Skip to content

Instantly share code, notes, and snippets.

@josecarneiro
Last active May 28, 2020 02:44
Show Gist options
  • Save josecarneiro/fca292918559f211c99d63d432ac7619 to your computer and use it in GitHub Desktop.
Save josecarneiro/fca292918559f211c99d63d432ac7619 to your computer and use it in GitHub Desktop.

SQL Database

Data is stored in tables. Every entry corresponds to a row.

SQL databases are usually relational.

Table: books

title author release_year rating pages
1984 George Orwell 1949 5 328
The Hitchhiker's Guide to the Galaxy Douglas Adams 1981 4.5 243

You query it with:

SELECT title, author FROM books WHERE title = 'The Hitchhiker's Guide to the Galaxy';

noSQL Database

Data is stored in a document store. Every entry is represented as a document.

noSQL databases are usually non-relational.

Collection: books

{
  "title": "1984",
  "author": "George Orwell",
  "release_year": 1949,
  "rating": 5,
  "pages": 328
}
{
  "title": "The Hitchhiker's Guide to the Galaxy",
  "author": "Douglas Adams",
  "release_year": 1981,
  "rating": 4.5,
  "pages": 243
}

To query the database, you can do the following.

// Query
{ title: 'The Hitchhiker\'s Guide to the Galaxy' }

// Options
{ select: 'title author' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment