BlackFriday 2024! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

MongoDB Exam C100DBA Topic 1 Question 81 Discussion

Actual exam question for MongoDB's C100DBA exam
Question #: 81
Topic #: 1
[All C100DBA Questions]

Write the command(s) are correct to enable sharding on a database "testdb" and shard a collection "testCollection" with _id as shard key.

Show Suggested Answer Hide Answer
Suggested Answer: A

Contribute your Thoughts:

Crista
5 months ago
Great, I feel more confident now about setting up sharding on this database
upvoted 0 times
...
Leonida
5 months ago
That makes sense, because we need to specify the collection name within the 'shardCollection' command
upvoted 0 times
...
Lawanda
5 months ago
I think the correct command is sh.enableSharding("testdb") followed by sh.shardCollection("testdb.testCollection", {"_id": 1})
upvoted 0 times
...
Crista
5 months ago
But don't we also need to enable sharding on the 'testCollection' collection with '_id' as the shard key?
upvoted 0 times
...
Leonida
6 months ago
No, I believe it should be sh.enableSharding("testdb")
upvoted 0 times
...
Crista
6 months ago
I think the correct command is sh.shardCollection("testdb", "testCollection", {"_id": "hashed"})
upvoted 0 times
...
Lashon
6 months ago
That makes sense. Enabling sharding on 'testdb' and sharding 'testCollection' with '_id' as shard key will help distribute data efficiently.
upvoted 0 times
...
Burma
6 months ago
Yes, I agree with Celestine. And to shard a collection with '_id' as shard key, the command should be 'sh.shardCollection('testdb.testCollection', {_id: 1})'.
upvoted 0 times
...
Celestine
7 months ago
I think the correct command to enable sharding on a database 'testdb' is 'sh.enableSharding('testdb')'.
upvoted 0 times
...

Save Cancel