Enjoy Upto 50% off on all Your Assignments ORDER NOW
Download Free Sample Order New Solution

Database Programming

Use of NoSQL database

Scenic Rim Farm Box is a small business that has recently started up a farm box delivery business to connect farmers to customers.

The image below shows a screen shot from the Scenic Rim Farmbox website. You can see the sort of data (that customers see) that is stored for each item. You can find out more about the Scenic Rim Farmbox business at this link https://scenicrimfarmbox.com.au/.

The Scenic Rim Farm Box web site currently uses a MySQL database which was set up by one of the owner’s children. The system is functional, but it is starting to slow as the business grows at a rapid pace. The Scenic Rim Farm Box owner knows that customers will not be happy if the web site continues to run slowly and has asked you for your advice on how it could be redesigned using MongoDB to improve speed. 

The owners have provided you with the current relational schema so you can see the data that they need to store.

Assignment Requirements:

Part A – MongoDB

  1. Write code to insert five product sales on the Scenic Rim Farm Box web site – you will have to choose the attributes you want to store for each sale – remember this is a database rewrite. (10 marks)

Answer:
db.collection(‘orders’).insertMany([

{customer : {f_name : ‘some name, l_name : ‘some name’, address : ‘some address’ , state : ‘la’ , post_code : 2222 }, delivery_date : new Date() , order_date , product : {farmer: {f_name : ‘some name’ , l_name : ‘some name’} , stock : 1 , description : ‘some desc’ , weight : 1 , cost : 1 , name : ‘some name’ , type : ‘some type’}}

],[

{customer : {f_name : ‘some name, l_name : ‘some name’, address : ‘some address’ , state : ‘la’ , post_code : 2222 }, delivery_date : new Date() , order_date , product : {farmer: {f_name : ‘some name’ , l_name : ‘some name’} , stock : 1 , description : ‘some desc’ , weight : 1 , cost : 1 , name : ‘some name’ , type : ‘spme type’}}

],[

{customer : {f_name : ‘some name, l_name : ‘some name’, address : ‘some address’ , state : ‘la’ , post_code : 2222 }, delivery_date : new Date() , order_date , product : {farmer: {f_name : ‘some name’ , l_name : ‘some name’} , stock : 1 , description : ‘some desc’ , weight : 1 , cost : 1 , name : ‘some name’ , type : ‘spme type’}}

],[

{customer : {f_name : ‘some name, l_name : ‘some name’, address : ‘some address’ , state : ‘la’ , post_code : 2222 }, delivery_date : new Date() , order_date , product : {farmer: {f_name : ‘some name’ , l_name : ‘some name’} , stock : 1 , description : ‘some desc’ , weight : 1 , cost : 1 , name : ‘some name’ , type : ‘spme type’}}

],[

{customer : {f_name : ‘some name, l_name : ‘some name’, address : ‘some address’ , state : ‘la’ , post_code : 2222 }, delivery_date : new Date() , order_date , product : {farmer: {f_name : ‘some name’ , l_name : ‘some name’} , stock : 1 , description : ‘some desc’ , weight : 1 , cost : 1 , name : ‘some name’ , type : ‘spme type’}}

]);

  1. Justify your choices for the data structures you selected for each attribute in the sale (500 - 1000 words). Explain why you chose each of the data structures and justify these choices. (10 marks)

Answer:
customer object is selected to track the customer who placed the order. His first name and lst name to know his name.First name and last name will be inserted according to the users identity information. His address to know where to deliver. The address will be the orignal address as per user identity card. State to know the region e.g: LA, california , las vegas. postal code for delivery information according to the state. Delivery date to keep track of the time product must be delivered.if delivery date is near the admin will get a notification that an order is near its delivery date. Order date to know when the order was placed. Its mandatory to store the order date to keep record of how many days have past from the date when order was placed. Product is and embedded document which contains the product details. It has the stock variable to know the stock of the product available. Its mandatory to store the stock to know if the product is available or not. It has the description of the product to know more about it and what the product actually is. Description is necessary because in case a product isn’t available then using neo4j we can suggest a product with a similar database.Name of the product is stored. A product name will be its title and will be used to as a main enitity to identify a product.Its also can be used for recommendations. Its weight is stroed accordingly to know its weight. A product is mostly shipped and to know its actual weight is very essential. The cost of the prodcut is stored which tells us its price. Farmer object so we know who is the owner of this product. his name is divided into two fields first name and last name.

  1. Create the following queries (all output should be easily read) HINT use .pretty (20 marks total)
    1. List all the sales in the collection (including all fields) (2 marks)

Answer :

db.collection(‘orders’).find().pretty();

  1. List only the product names from each sale (2 marks)

Answer:

db.collection(‘orders’).find({},{“product.name”:1,

_id : 0 }).pretty()

  1. List only the product name and farmer’s name for every sale (2 marks)

Answer:

db.collection(‘orders’).find({},{“product.name”:1,

_id : 0 , “farmer.f_name” : 1 , “farmer.l_name” : 1}).pretty()

  1. List only the distinct name and details of every customer (2 marks)

Answer:

db.collection(‘orders’).distinct( "customer.f_name" );

  1. Count the number of sales in the collection (2 marks)

Answer :

db.collection(“orders”).count();

  1. List only the product name and price for products that are greater than $15. (2 marks)

Answer:

db.collection(‘orders’).find({“product.cost” : {$gt : 15} }).pretty();

  1. Return the average price each product type (eg Meat, Dairy, Veggies & Fruit) (2 marks)

Answer:

db.collection(‘orders’).aggregate([{$group:{_id:"$product.type",pop:{$avg:"$product.cost"} } }])

  1. Write code that updates the name and price of one of the products in one sale. (2 marks)

Answer:

db.collection(orders).update({_id : ObjectId(‘sssd33’)} , {“product.name” : ‘new name’ , cost: ‘new cost’});

  1. Add a new field to a sale to record to show who the sale was referred by. (2 marks)

Answer:

db.collection(orders).update({_id : ObjectId(‘sssd33’)} , {“sale_reffered_by” : ‘some person’});

  1. Return the sales that do not have any dairy products. (2 marks)

Answer:

db.collection(‘orders’).find({“product.type” : {$ne : “dairy”} }).pretty();

Part B – Neo4j (10 marks)

  1. The owner has also asked you to write about how Neo4j could be integrated to improve the product recommendations. At the moment, items are randomly selected from the product list to display to customers.

Write around 300-500 words on the way that you would develop a Neo4j database that could complement the MongoDB database so that real time recommendations could be made based on what other “similar” customers purchased.

Answer: :

Neo4j is a profoundly versatile local diagram information base, reason worked to use information as well as information connections.

Utilizing Neo4j, designers assemble clever applications that navigate the present enormous, interconnected datasets progressively. Fueled by a local chart stockpiling and handling data, Neo4j conveys an instinctive, adaptable and secure information base for special, noteworthy bits of knowledge.

In contrast to traditional databases, which orchestrate information in rows, columns and tables,Neo4j has a flexible structure defined by stored relationships between data records.

With Neo4j, every information record, or node, stores direct pointers to all the nodes it's associated with. Since Neo4j is planned around this straightforward, yet incredible enhancement, it performs questions with complex associations significant degrees quicker, and with more profundity, than different databases.

Constant recommendation engines are critical to the accomplishment of any online business. To make applicable suggestions continuously requires the capacity to correspond item, client, stock, provider, coordinations and even social notion information. In addition, a constant suggestion engine requires the capacity to in a split second catch any new interests appeared in the client's present visit – something that cluster preparing can't achieve. Coordinating authentic and meeting information is unimportant for a chart data set like Neo4j.

The key innovation in empowering constant suggestions is the graph database, an innovation that is quick abandoning customary social data sets. Diagram information bases effectively beat social and other NoSQL datastores for interfacing masses of purchaser and item data (and associated information by and large) to pick up knowledge into client needs and item drifts.

Regardless of whether you're utilizing announced social associations or drawing an obvious conclusion regarding apparently random realities to construe interests, charts offer a universe of new chance with regards to improving continuous suggestions for your clients. Associate individuals to items, administrations, data or others dependent on their client profile, inclinations and past online action, for example, item buys.

Remember, at the center of any academic work, lies clarity and evidence. Should you need further assistance, do look up to our Engineering Assignment Help

Upto 50% Off*
Get A Free Quote in 5 Mins*
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Why Us


Complete Confidentiality
All Time Assistance

Get 24x7 instant assistance whenever you need.

Student Friendly Prices
Student Friendly Prices

Get affordable prices for your every assignment.

Before Time Delivery
Before Time Delivery

Assure you to deliver the assignment before the deadline

No Plag No AI
No Plag No AI

Get Plagiarism and AI content free Assignment

Expert Consultation
Expert Consultation

Get direct communication with experts immediately.

Get
500 Words Free
on your assignment today

ezgif

It's Time To Find The Right Expert to Prepare Your Assignment!

Do not let assignment submission deadlines stress you out. Explore our professional assignment writing services with competitive rates today!

Secure Your Assignment!

Online Assignment Expert - Whatsapp Get Best OffersOn WhatsApp

refresh