Skip to content

Commit 2ea52ff

Browse files
committed
fix headers, add models definition
reference links
1 parent ee2b83b commit 2ea52ff

File tree

5 files changed

+35
-22
lines changed
  • module3-crud-and-data-models

5 files changed

+35
-22
lines changed

module3-crud-and-data-models/r1-schema-and-data-models/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Introduction To Database Schemas
1+
# Introduction To Database Schemas
22

3-
A database schema is a blueprint or architecture of how our data will look. It doesn’t hold data itself, but instead describes the shape of the data and how it might relate to other tables or models.
3+
A database schema is a blueprint or architecture of how our data will look. It doesn’t hold data itself, but instead describes the shape and structure of the data and how it might be related to other data.
44

55
For example, this is a `customer` schema in MongoDB using Mongoose.
66

@@ -20,7 +20,7 @@ const customer = new mongoose.Schema({
2020
module.exports = mongoose.model("customer", customer);
2121
```
2222

23-
The same `customer` schema in PostgreSQL database using sequelize.
23+
The same `customer` schema in PostgreSQL using [Sequelize](https://sequelize.org/).
2424

2525
```js
2626
const Sequelize = require("sequelize");
@@ -39,7 +39,10 @@ module.exports = (sequelize, DataTypes) => {
3939
};
4040
```
4141

42-
We can see that the schema definition for the `customer` has a `name` that is type `string` and a `zipcode` that is of type `number`.
42+
We can see that the schema definition for the `customer` has a `name` that is type `string` and a `zipcode` that is of type `number`. The `name` field is mandatory and cannot be empty.
43+
44+
Another concept that can be confused with the database schema is the "Model".
45+
Models are fancy constructors compiled from schema definitions. An instance of a model is called a document. Models are responsible for creating and reading documents from the underlying MongoDB database.
4346

4447
## Introduction to CRUD operations
4548

@@ -212,8 +215,10 @@ router.delete("/dishes/:id", async (req, res) => {
212215
});
213216
```
214217

215-
## Resources
218+
---
219+
220+
## References
216221

217-
- [What is REST](https://restfulapi.net/)
218-
- [See this](https://www.educative.io/blog/crud-operations#what) for more information on how CRUD operations are performed directly on `SQL` database.
219-
- [database schemas](https://www.educative.io/blog/what-are-database-schemas-examples#types)
222+
- https://restfulapi.net/
223+
- https://www.educative.io/blog/crud-operations#what
224+
- https://www.educative.io/blog/what-are-database-schemas-examples#types

module3-crud-and-data-models/r1.1-principles-of-setting-up-your-schema/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
## Principles Of Setting up Your Schema
1+
# Principles Of Setting up Your Schema
22

33
Poorly designed databases can cause many problems, including wasting resources, making maintenance difficult, and hindering performance. That's why having a great database schema design is a crucial part of effective data management.
44
By defining categories of data and relationships between those categories, database schema design makes data much easier to retrieve, consume, manipulate, and interpret.
55
Without a clean, efficient, consistent database schema, you’ll struggle to make the best use of your enterprise data. For example, the same data might be duplicated in multiple locations—or even worse, might be inconsistent between these locations.
66

7-
### Type of database
7+
## Type of database
88

99
Most developers don't see the difference between relational database schema and MongoDB schema, but in reality, it is not the same
1010

@@ -59,7 +59,9 @@ Having a JOIN or `$lookup` means you are doing some kind of search in your datab
5959

6060
This means that no matter what you read or watch, you may still need to make few changes to your schema based on your own use case and application.
6161

62-
## Resources
62+
---
6363

64-
- [Schema design best practices](https://www.mongodb.com/developer/article/mongodb-schema-design-best-practices/)
65-
- [Guide to database schema design](https://www.xplenty.com/blog/complete-guide-to-database-schema-design-guide/)
64+
## References
65+
66+
- https://www.mongodb.com/developer/article/mongodb-schema-design-best-practices/
67+
- https://www.xplenty.com/blog/complete-guide-to-database-schema-design-guide/

module3-crud-and-data-models/r3-model-view-controller/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ router.get('/posts', (req, res) => {
8888
});
8989
```
9090

91-
## Resources
91+
---
9292

93-
- [MVC Architecture with NodeJS and Mongoose](https://medium.com/geekculture/mvc-architecture-with-express-server-e35aedfe7889)
94-
- [Express MVC structure](https://codingstatus.com/express-mvc-structure/)
93+
## References
94+
95+
- https://medium.com/geekculture/mvc-architecture-with-express-server-e35aedfe7889
96+
- https://codingstatus.com/express-mvc-structure/

module3-crud-and-data-models/r3.2-models-and-controllers-in-mongoose/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Models and Controllers in Mongoose
1+
# Models and Controllers in Mongoose
22

33
Mongoose is one of the fundamental tools for manipulating data for a Node.js and MongoDB backend.
44

@@ -110,6 +110,8 @@ app.delete("/food/:id", async (request, response) => {
110110
// ...
111111
```
112112

113-
## Resources
113+
---
114114

115-
- [CRUD operations in Mongoose](https://mongoosejs.com/docs/models.html#Querying)
115+
## References
116+
117+
- https://mongoosejs.com/docs/models.html#Querying

module3-crud-and-data-models/r4-building-custom-methods-on-mongoose/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Building Your Own Methods on Mongoose
1+
# Building Your Own Methods on Mongoose
22

33
In Mongoose, instances of models are documents. Documents have many of their own built-in instance methods (called static methods). We may also define our own custom document instance methods.
44
We use instance methods to add new custom methods to our model that didn't exist before, that will help us reduce our code duplications if that method is used in multiple places, and, imporove the overall code structure.
@@ -26,6 +26,8 @@ dog.findSimilarTypes((err, dogs) => {
2626
});
2727
```
2828

29-
## Resources
29+
---
3030

31-
- [Instance methods in Mongoose](https://mongoosejs.com/docs/guide.html#methods)
31+
## References
32+
33+
- https://mongoosejs.com/docs/guide.html#methods

0 commit comments

Comments
 (0)