Consider the following scenario of a business data model and answer the following questions: – An Item booking is associated with one customer and a customer may be involved in more than one item bookings. Every Item booking is identified by item_booking_id, date_rented, date_returned, rental_amount_due, other_rental_details and customer details. Customer details include customer_id, customer_name, customer_email, customer_phone and customer_address. 1. a. Write an embedded Item booking document schema in MongoDB as per the item booking details given in the above scenario. Embed the customer details in the Item booking document (You can use any values for the fields). Explain the Schema in your words. b. List any 1 advantage and disadvantage of embedded data model in the context of the above embedded document schema. Explain. 2. a. Update the above embedded item booking document and describe the relationships in the document using references.  Explain your answer. b. List the advantages of using references to describe the related data in the context of the above scenario. Explain your answer.

1. a) Based on the item booking details provided, an embedded Item booking document schema in MongoDB can be defined as follows:

{
“_id”: ObjectId,
“item_booking_id”: string,
“date_rented”: date,
“date_returned”: date,
“rental_amount_due”: decimal,
“other_rental_details”: string,
“customer”: {
“customer_id”: string,
“customer_name”: string,
“customer_email”: string,
“customer_phone”: string,
“customer_address”: string
}
}

In this schema, the Item booking document contains fields such as item_booking_id, date_rented, date_returned, rental_amount_due, other_rental_details, and a sub-document named “customer” which includes customer details such as customer_id, customer_name, customer_email, customer_phone, and customer_address. The item_booking_id uniquely identifies each item booking, while the customer_id links the item booking to a specific customer.

b) One advantage of using an embedded data model is that it allows for better query performance. As the customer details are embedded within the item booking document, retrieving this information requires a single query to retrieve the entire document. This reduces the need for complex database joins and improves the overall efficiency of data retrieval.

However, one disadvantage of the embedded data model is that it can lead to data redundancy and potential inconsistency. For example, if a customer changes their phone number or address, all item booking documents associated with that customer would need to be updated to reflect the changes. This can be a time-consuming and error-prone process, especially when dealing with a large number of item bookings.

2. a) To update the above embedded item booking document and describe the relationships using references, we would modify the schema as follows:

{
“_id”: ObjectId,
“item_booking_id”: string,
“date_rented”: date,
“date_returned”: date,
“rental_amount_due”: decimal,
“other_rental_details”: string,
“customer_id”: string
}

In this updated schema, we have removed the sub-document “customer” and replaced it with a single field “customer_id” which refers to the unique identifier of the customer. This establishes a reference relationship between the item booking document and the customer.

By using references, we separate the customer details from the item booking document, reducing data redundancy and potential inconsistencies. When retrieving customer details for a specific item booking, a separate query can be executed to retrieve the customer document using the customer_id.

b) There are several advantages of using references to describe related data in the context of the above scenario. Firstly, it allows for better data organization and normalization. Customer details are stored in a separate collection, reducing duplication and ensuring data consistency across multiple item bookings.

Secondly, it simplifies updates to customer details. If a customer’s information changes, such as their phone number or address, it only needs to be updated in one place – the customer collection. All item bookings referencing that customer will automatically reflect the updated information.

Lastly, using references allows for better scalability. As the number of item bookings and customers grows, the size of the embedded documents may become large and impact performance. With references, the item booking document remains concise and efficient, while customer information can be easily accessed when needed.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer