Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 4.88 KB

301-class11.md

File metadata and controls

87 lines (62 loc) · 4.88 KB

Class 301.11

Notes

MongoDB

  • run it with mongod

Express server installation

  • npm install express cors dotenv mongoose nodemon
  • scripts add start args start: node server.js

React install

  • npm create vite@latest
  • npm install bootstrap axios react-bootstrap
  • atlas username/ password: sugaraspa/ 66SKR98f5kPTKujN
  • into my api to talk to mongoose:(in .env) MONGODB_URL=mongodb+srv://sugaraspa:<password>@cluster0.wlju2vn.mongodb.net/?retryWrites=true&w=majority

Readings

nosql vs sql(text)

  1. 5 Differences Between noSQL and SQL:
Feature SQL Databases NoSQL Databases
Data Model SQL databases are relational and table-based. NoSQL databases can be document-based, key-value pairs, graph databases, or wide-column stores. This means they don't adhere to a standard schema.
Scalability SQL databases are typically vertically scalable, meaning you increase the power of a single server. NoSQL databases are horizontally scalable, meaning you add more servers in the pool of resources to handle more traffic.
Query Language SQL databases use the structured query language (SQL), which is powerful and standardized. NoSQL databases often lack a standard query language, sometimes referred to as UnQL. Their query capabilities are not as powerful as SQL.
Complex Queries SQL is good for complex queries and is designed for environments where these are common. NoSQL databases are generally not suitable for complex queries. The interfaces for complex queries are not standardized.
Support SQL databases typically have robust vendor and community support, as well as a large number of independent consultants. Support for NoSQL databases might be less comprehensive, often relying on community support or fewer experts.
Here are the answers in markdown format:
  1. What kind of data is a good fit for an SQL database?

Data with structured schemas and relationships that can be represented in tables with rows and columns.

  1. Give a real world example.

Customer information for an ecommerce site, with structured data like name, address, order history etc that relate to each other through foreign keys.

  1. What kind of data is a good fit a NoSQL database?

Unstructured or semi-structured data without rigid schemas, such as documents, key-value pairs, graphs etc.

  1. Give a real world example.

Comments or posts on a social media site, which can have varied structures and fields depending on the content.

  1. Which type of database is best for hierarchical data storage?

NoSQL databases like MongoDB are good for hierarchical data storage as they can hold JSON-like documents with nested objects and arrays.

  1. Which type of database is best for scalability?

NoSQL databases are more horizontally scalable by adding servers to a cluster. SQL scaling vertically is limited by hardware.

sql vs nosql (Video)

  1. What does SQL stand for?

Structured Query Language

  1. What is a relational database?

a database that uses SQL and stores data in tables with rows and columns

  1. What type of structure does a relational database work with?

A relational database works with tables as the structure to store data

  1. What is a ‘schema’?

A schema defines the fields or columns that can exist in a database table. All rows in that table must adhere to the schema.

  1. What is a NoSQL database?

A NoSQL database is a non-relational database that does not use SQL. Examples are MongoDB, DynamoDB.

  1. How does it work?

NoSQL databases work with collections and documents rather than tables and rows. Documents can have varied, flexible structures.

  1. What is inside of a MongoDB database?

MongoDB databases contain collections which hold documents.

  1. Which is more flexible - SQL or MongoDB? and why.

MongoDB is more flexible since documents can have varying fields. SQL requires fixed schemas

  1. What is the disadvantage of a NoSQL database?

A disadvantage of NoSQL is potential for inconsistent data since documents vary. Joins between data are also harder.

Bookmark and Review

mongoose api React Router

Things I want to learn more about

References

  • Google Bard and ChatGPT