Last active
April 26, 2019 12:57
-
-
Save thamaraiselvam/392ff550795ab78053ec8aa8c4d18dfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MongoDB Design patterns based on application usage perspective: | |
The scheme depends on your application use case | |
Data Access Patterns | |
Number of reading vs update | |
what is the size of expected documents | |
Performance issues in MongoDB: | |
Schema Design: | |
{ | |
Inherently slow operation | |
Blocked waiting for a slow operation | |
} | |
Insufficient or poorly tuned hardware | |
Design for : | |
Simplicity | |
Performance | |
Scalability | |
Index makes faster = Effiecenit execution | |
many indexes extra memory and slow down | |
do not change index field because has to rebuild indexing again | |
Aggregation is a pipeline until output comes out stage by stage- 25 stages | |
$match - get results | |
$unwind - create separate documents from array | |
$group - group data | |
$project -> rename fields | |
$lookup - join | |
$indexState - index status | |
$out - storing result into new collection | |
$sort | |
$limit | |
$skip | |
Advantages: | |
Faster because of No join at run time and less code | |
Flexible schema structure | |
Scalable | |
Handle messy Data | |
Combine different data from a different source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Database Normalization | |
1. Avoid data redundancy - repeative data | |
2. Ensure data integrity - Should able to CURD without negative affect on other data | |
Normalization: | |
Process of organizing database to avoid data redundancy and ensure data integrity. | |
1NF | |
1.each record represent one primary key | |
2.one columns should have single value ( atomic values) | |
3. no repeating groups - example class1, class2 ,class3 | |
2NF | |
no partial dependacies - non primary columns should depeding only on primary column | |
Problem: lead to data redundancy | |
student_id class_id teacher | |
1 1 Smith | |
1 2 Jackson | |
2 3 James | |
2 2 Jackson | |
teacher is not depending on one primary key | |
3NF | |
There are no transitive dependencies. | |
Problem: lead to data redundancy | |
A determines B | |
B does not determine A | |
B determines C | |
id class_name teacher office | |
1 Math Smith A107 | |
2 Programming Jackson B205 | |
3 History James A100 | |
4 Science Jackson B205 | |
teach is not determine id and class so create them into separate table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment