Creation of Collections:
we use tables in the traditional databases, here we use collections, the columns are called as fields, and joins are embedded documents.
lets create a simple collection:
first create a database: use dataset
then check the db: db
create a simple collection:
command: db.createCollection("customers")
output : {ok:1}
we call record as documents here:
now insert a document in collection "dataset":
command:db.customers.insert({'name':'raj'})
to see the columns or data in tables we use select statement , here we use find() method.
command:db.customers.find()
output: ("_id":ObjectId(568cbca55685654adasda),"name":"raj")
here the id for each field is created automatically, it is index of the field.
if you want the structure formatted of the document: use the following command:
command: db.customers.find().pretty()
we use tables in the traditional databases, here we use collections, the columns are called as fields, and joins are embedded documents.
lets create a simple collection:
first create a database: use dataset
then check the db: db
create a simple collection:
command: db.createCollection("customers")
output : {ok:1}
we call record as documents here:
now insert a document in collection "dataset":
command:db.customers.insert({'name':'raj'})
to see the columns or data in tables we use select statement , here we use find() method.
command:db.customers.find()
output: ("_id":ObjectId(568cbca55685654adasda),"name":"raj")
here the id for each field is created automatically, it is index of the field.
if you want the structure formatted of the document: use the following command:
command: db.customers.find().pretty()
No comments:
Post a Comment