0607 - 0613
0607
몽고DB 샤딩
Advantages of Sharing
- 읽기 및 쓰기
- 저장 용량
- 고가용성
Sharded and Non-Shared Collections
- A database can have mixture of sharded and unsharded collections
- Sharded collections are partitioned and distributed across the shards in the cluster
- Unsharded collections are stored on a primary shard that holds all the un-sharded collections.
Connecting to a Sharded Cluster
- You must connect to a mongos router to interact with any collections in the sharded cluster
- You can connect to a mongos via the mongo shell or a MongoDB driver
Two Sharding Strategies for distributing data across sharded clusters
- Ranged sharding
- devires data into several ranges based on the shard key values
- Each chunk is then assigned a range based on the shard key values
- Hashed sharding
- computing a hash of the shard key field’s value
- Each chunk is then assigned a range based on the hashed shard key values
0608
MongoDB 백업
백업을 위한 명령 mongodump
- dumps the entire data of your server into the dump directory
- 백업 단위 선택 가능 : 컬렉션 / 데이터베이서 / 전체 데이터베이스 단위
백업된 데이터의 복원 명령 mongorestore
- restores all of the data from the backup directory
- mongodump and mongorestore are not ideal for capturing backups of larger systems.
mongodb에서 데이터 모델링
- always consider the application usage of the data as well as the inherent structure of the data itself.
- flexible schema in MongoDB
- two types of data models in MongoDB
- embedded (de-normalized) data model
- referenced (normalized) data model
Embedded Relationships
- embeds all the related data in a single document, which makes it easy to retrieve and maintain
- stores the relationships between data by storing related data in a single document structure
Referenced Relationships
- stores the relationships between data by including links or references from one document to another
- both the user and address documents will be maintained separately but the user document will contain a field that will reference the address document’s id field.
0609
Database References
- For many use cases in MongoDB
- the denormalized data model where related data is stored within a single document will be optimal
- in some cases, it makes sense to store related information in separate documents, typically in different collections or databases
- two methods for relating documents in mongoDB applications
- manual references
- DBRefs
Using DBRefs
- 다음 3개의 필드를 포함하는 문서 형식으로 참조 관계를 명세해야 함
- $ref 필드 : 참조되는 문서가 속한 컬렉션 이름
- $id 필드 : 참조되는 문서의 _Id 필드
- $db 필드 : 참조되는 문서가 속한 데이터베이스 이름 (옵션)
- 필드 순서를 주의해서 사용해야 한다.
0610
covered query
- 인덱스만 이용해서도 처리가 가능한 질의 (데이터베이스 접근 없음)
- 질의 처리에 필요한 모든 데이터가 인덱스에 있을 때 ‘이 인덱스가 해당 질의를 커버한다’라고 함
- An index covers a query when all of the following apply:
- all the fields in the query are part of an index, and
- all the fields returned in the results are in the same index
- no fields in the query are equal to null
질의 분석
- Analyzing queries is a very important aspect of measuring how effective the database and indexing design is
- explain() 메소드
- provides information on the query, indexes used in a query and other statistics
- very useful when analyzing how well your indexes are optimized
- hint() 메소드
- forces the query optimizer to use the specified index to run a query
- particularly useful when you want to test performance of a query with different indexes
Advanced Indexing
- 배열의 각 요소 마다 인덱스 엔트리 유지 -> multikey Index로 구성
- 배열의 각 요소 마다 인덱스 엔트리 유지
- 서브 문서를 필드 값으로 갖는 인덱싱
- 서브 문서의 모든 필드들에 대한 인덱스 생성
0611
패스트캠퍼스 네카라쿠배 취업스쿨 1차 합격
2주 동안의 노력에 대한 결실을 맺었다.
글을 쓰는 재주가 없어 자기소개서에 대한 자신감이 없었기에 큰 기대를 하지 않았지만 통과를 했다.
기대를 하지 않았다고는 했지만 합격했다는 메세지를 봤을 때, 기쁘면서 자존감이 올라갔다.
2차 테스트는 향후 코딩테스트에 필요한 파이썬과 자료구조에 대한 내용으로 2주간 테스트를 진행한다고 한다.
파이썬은 익힐까말까 많이 고민했던 언어이고, 자료구조에 대한 학습은 필수적이었기에 이번 기회에 제대로 공부해보려고 한다.
1차테스트에 합격한만큼, 2차테스트는 더 열심히 준비해서 꼭 붙어야겠다는 욕심이 생겼다.
후회하지 않도록 최선을 다해서 꼭 통과해야겠다.
0612 ~ 0613
기말고사 기간