You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: module3-crud-and-data-models/r1-schema-and-data-models/README.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
-
##Introduction To Database Schemas
1
+
# Introduction To Database Schemas
2
2
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.
4
4
5
5
For example, this is a `customer` schema in MongoDB using Mongoose.
6
6
@@ -20,7 +20,7 @@ const customer = new mongoose.Schema({
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.
Copy file name to clipboardExpand all lines: module3-crud-and-data-models/r1.1-principles-of-setting-up-your-schema/README.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
##Principles Of Setting up Your Schema
1
+
# Principles Of Setting up Your Schema
2
2
3
3
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.
4
4
By defining categories of data and relationships between those categories, database schema design makes data much easier to retrieve, consume, manipulate, and interpret.
5
5
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.
6
6
7
-
###Type of database
7
+
## Type of database
8
8
9
9
Most developers don't see the difference between relational database schema and MongoDB schema, but in reality, it is not the same
10
10
@@ -59,7 +59,9 @@ Having a JOIN or `$lookup` means you are doing some kind of search in your datab
59
59
60
60
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.
61
61
62
-
## Resources
62
+
---
63
63
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/)
Copy file name to clipboardExpand all lines: module3-crud-and-data-models/r4-building-custom-methods-on-mongoose/README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
##Building Your Own Methods on Mongoose
1
+
# Building Your Own Methods on Mongoose
2
2
3
3
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.
4
4
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.
0 commit comments