178k views
5 votes
Create a database KT1B, Collection MuaHang. Use KT1B. Switched to db KT1B. db.createCollection(MuaHang). { ok : 1 }

1 Answer

4 votes

Final answer:

The student is asking how to create a new database called KT1B and a collection named MuaHang in MongoDB. The commands provided are correct for achieving this, and the expected output is MongoDB's way of confirming the successful execution of the collection creation.

Step-by-step explanation:

The question asks how to create a database and a collection within that database using a NoSQL database, specifically MongoDB. The command sequence provided indicates the steps to create a new database named KT1B, then within that database, create a new collection called MuaHang. The output { ok : 1 } suggests that the operation to create the collection was successful. To complete these actions in MongoDB, you would open a MongoDB shell and enter these commands:

  • use KT1B - This switches the context to the KT1B database, creating it if it does not exist.
  • db.createCollection("MuaHang") - This creates a new collection named MuaHang within the KT1B database.

The output confirming the creation of the collection, { ok : 1 }, is a typical MongoDB response indicating that the operation was successful.

User Ben Marshall
by
6.7k points