Challenge

Project 2

1. Design your ecommerce DATABASE IN MongoDB WITH the specifications provided below

a]test> USE ecommerceswebsite
switched TO db ecommerceswebsite
ecommerceswebsite> db
ecommerceswebsite
ecommerceswebsite> db.CreateCollection("Customers")
ecommerceswebsite> db.Customers.insert(
... {
... "CustomersID":1,
... "CustomersName":"venky",
... "CustomersDOB":6-11-2002,
... "CustomersContact":6666666666,
... "CustomersType":"premium"
... }
... )
DeprecationWarning: Collection.insert() IS deprecated. USE insertOne, insertMany, OR bulkWrite.
{
acknowledged: TRUE,
insertedIds: { '0': ObjectId("6386199c921ddd66edb9237d") }
}
b]

ecommerceswebsite> db.Customers.find({"CustomerType"})

c]

ecommerceswebsite> db.carts.insert({
... _id:"the_useres_session_id",
... STATUS:'active',
... quantity:4,
... total:2500,
... products:[]
... });
{ acknowledged: TRUE, insertedIds: { '0': 'the_useres_session_id' } }

d]

db.Products.insert(
... {
... "ProductName":"shampoo",
... "ProductID":3,
... "ProductSize":30,
... "ProductColor":"violet",
... tags:['silk','shik','clear'],
... categories:['soap','santoor']
... }
... )

e]

db.subcategories.insertMany(
... {
... item:'soap',
... NAME:'cinthol',
... cost:45,
... qty:20,
... likes:300
... },
... {
... item:'soap',
... NAME:'medimix',
... cost:28,
... qty:30,
... likes:600
... }
... )
f]
db.products.insert(
... {
... _id:2,
... "name":"teja",
... tag:['size','discount']
... }
... )
DeprecationWarning: Collection.insert() IS deprecated. USE insertOne, insertMany, OR bulkWrite.
{ acknowledged: TRUE, insertedIds: { '0': 2 } }
ecommercewebsite>
g]
db.Orders.insert({
... created_on:NEW ISOdate("2000-8-67y68:35:34.4578"),
... shipping:{
... customer:"mark",
... address:"tnagr 4/5/789",
... city:"chennai",
... region:"",
... state:"tn",
... country:"India"
... tracking:{
... company:"yyy",
... tracking_number:"17huidis6",
... STATUS:'shipped',
... estimated_delivery:NEW ISOdate("2000-8-67y68:35:34.4578")
... },
... },
... payment:{
... method:"card"
... transaction_id:"1677887727XXXTD"
...}
...products:{
...{quantity:300,sku:"soap",title:"cinthol",
...soap:unit_cost:300,currency:"inr"}
...}
...})
h]
db.seller.insert(
... {
... "SellerName":"ravi",
... "SellerID":65yu,
... "SellerContact":3454545454
... }
... )
ecommercewebsite> db.products.insert(
... [
... {_id:11,item:"bottle",qty:50,TYPE:"no.3"},
... {item:"pen",qty:20},
... {item:"lunch box",qty:3}
... ]
... )
ecommercewebsite> db.Admin.insert(
... {
... "AdminName":"ravi",
... "AdminID":6756,
... "AdminEmail":"[email protected]"
... }
... )
ecommercewebsite> db.products.insert(
... [
... {_id:11,item:"bottle",qty:50,TYPE:"no.3"},
... {item:"pen",qty:20},
... {item:"lunch box",qty:3}
... ]
... )
j]
db.Orders.insert({
... created_on:NEW ISOdate("2000-8-67y68:35:34.4578"),
... shipping:{
... customer:"mark",
... address:"tnagr 4/5/789",
... city:"chennai",
... region:"",
... state:"tn",
... country:"India"
... tracking:{
... company:"yyy",
... tracking_number:"17huidis6",
... STATUS:'shipped',
... estimated_delivery:NEW ISOdate("2000-8-67y68:35:34.4578")
k]
db.seller.insert(
... {
... "SellerName":"ravi",
... "SellerID":289,
... "SellerContact":5656576867
... }
... )
1.Create your collections FOR your ecommerce DATABASE IN MongoDB AND fill it WITH sample information
db.CreateCollection("SampleDatabase")
ecommercewebsite> db.SampleDatabase.insert(
... {
... CustName:"revi",
... _id:29,
... DOB:19-12-1990,
... contact:9999999999
... }
... )
{ acknowledged: TRUE, insertedIds: { '0': 27 } }
ecommercewebsite> db.Seller.insert(
... {
... NAME:"manoj",
... _id:980,
... contact:554446446,
... DOB:29-8-2010
... }
... )
{ acknowledged: TRUE, insertedIds: { '0': 88 } }
ecommercewebsite> db.Admin.insert(
... {
... NAME:"vamsi",
... _id:90,
... DOB:22-1-2004,
... contact:65756789
... }
... )
{ acknowledged: TRUE, insertedIds: { '0': 7 } }
ecommercewebsite> db.product.insert(
... {
... NAME:"box",
... dimensentions:['height','weidth','colour'],
... cost:50,
... qty:20%
... }
ecommercewebsite> db.cart.insert(
... {
... NAME:"box",
... dimensentions:['height','weidth','colour'],
... cost:50,
... qty:50,
... shipping:("nellore",9-9-123,"trunk road")
... }
... )
{
acknowledged: TRUE,
insertedIds: { '0': ObjectId("63899cd66ce34766fae7aa08") }
}
2.Submit ALL the queries used TO CREATE the DATABASE
db.CreateCollection("Customers")
ecommerceswebsite> db.Customers.insert(
... {
... "CustomersID":1,
... "CustomersName":"venky",
... "CustomersDOB":6-10-2002,
... "CustomersContact":677564767,
... "CustomersType":"premium"
... }
... )
DeprecationWarning: Collection.insert() IS deprecated. USE insertOne, insertMany, OR bulkWrite.
{
acknowledged: TRUE,
insertedIds: { '0': ObjectId("6386199c921ddd66edb9237d") }
}

ecommerceswebsite> db.Customers.find({"CustomerType"})


ecommerceswebsite> db.carts.insert({
... _id:"the_useres_session_id",
... STATUS:'active',
... quantity:2,
... total:2000,
... products:[]
... });
{ acknowledged: TRUE, insertedIds: { '0': 'the_useres_session_id' } }

db.Products.insert(
... {
... "ProductName":"Soaps",
... "ProductID":7,
... "ProductSize":20/10/14,
... "ProductColor":"red",
... tags:['santoor','rexona','xxx'],
... categories:['facewash','dermacara']
... }
... )

db.subcategories.insertMany(
... {
... item:'shampoo',
... NAME:'clinic plus',
... cost:5,
... qty:90,
... likes:200
... },
... {
... item:'shampoo',
... NAME:'clear',
... cost:10,
... qty:40,
... likes:150
... }
... )
db.products.insert(
... {
... _id:2,
... "name":"vamsi",
... tag:['size','discount']
... }
... )
DeprecationWarning: Collection.insert() IS deprecated. USE insertOne, insertMany, OR bulkWrite.
{ acknowledged: TRUE, insertedIds: { '0': 2 } }
ecommercewebsite>
db.Orders.insert({
... created_on:NEW ISOdate("2000-8-67y68:35:34.4578"),
... shipping:{
... customer:"mark",
... address:"tnagr 4/5/789",
... city:"chennai",
... region:"",
... state:"tn",
... country:"India"
... tracking:{
... company:"yyy",
... tracking_number:"17huidis6",
... STATUS:'shipped',
... estimated_delivery:NEW ISOdate("2000-8-67y68:35:34.4578")
... },
... },
... payment:{
... method:"card"
... transaction_id:"1677887727XXXTD"
...}
...products:{
...{quantity:300,sku:"soap",title:"cinthol",
...soap:unit_cost:300,currency:"inr"}
...}
...})
db.seller.insert(
... {
... "SellerName":"ravi",
... "SellerID":3tyk,
... "SellerContact":34345666666
... }
... )
ecommercewebsite> db.products.insert(
... [
... {_id:11,item:"shampoo",qty:500,TYPE:"no.10"},
... {item:"pen",qty:20},
... {item:"pencil",qty:250}
... ]
... )
ecommercewebsite> db.Admin.insert(
... {
... "AdminName":"valesh",
... "AdminID":2909,
... "AdminEmail":"[email protected]"
... }
... )
SIMPLE Queries TO perform ON ecommerce db
1]db.customer.aggregate({$AVG:"order_amt"})

2]db.customer.find({order_amt}).sort({"title":1}).limit(10)

3]db.order.aggregate({$SUM:order_amt})

4]db.customer.aggregate([ {$GROUP : {_id:"$city", COUNT:{$cust_id}} ])

5]
db.getCollection('customer').aggregate([{$lookup:
{FROM: 'seller',localField: 'city',AS: 'same_city'}
}]);

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.