Hello to all,
I am working on an API for a travel agency (it is a dummy project for my portfolio). The API is designed to manage reservations, including hotels, cars and transfers. I designed a schema for the DB (I use Mongoose). I am not sure if it is the good way to proceed.
There are many scenario possible for a given reservation :
i) a reservation can have up to 20 guests,
ii) each guest can have many reservations (between 0 and unlimited) of different products (hotel, car or transfer),
iii) guests won’t necessary have the same products at the same time (same/different product at the same/different date)
iv) we will assume all reservations are free, so the price is always 0 and has not to be stored in the DB,
I figured out this mongoDB schema for the reservations collection (the single one):
[{
reservationId,
clients: [{client_id, firstName, lastName}],
hotel:
[{
hotelId,
clients: [ client_id ],
hotel: {hotelName, hotelAddress, hotelCity, hotelCountry, hotelPhone},
hotelDetails: {checkInDate, checkOutDate, isBreakfast, roomCategory}
}],
transfert:[{
transfertId,
clients: [client_id],
transferDetails: {departureAddress, arrivalAddress, date, transfertCompanyName}
}],
car:[{
carId,
clients:[ client_id],
carDetails: {departureAddress, agency, pickupDate, returnDate}
}]
}]
I am not sure if it is a good way to store data. The front end will allow managers to show a given reservation without many details. When clicking a button, they will be able to access details about the reservation.
What do you think of this approach ? Is there any way to optimize it ?
Thank you in advance ! :)[quote=“Sam_N_A3, post:1, topic:266664, full:true”]
Hello to all,
I am working on an API for a travel agency (it is a dummy project for my portfolio). The API is designed to manage reservations, including hotels, cars and transfers. I designed a schema for the DB (I use Mongoose). I am not sure if it is the good way to proceed.
There are many scenario possible for a given reservation :
i) a reservation can have up to 20 guests,
ii) each guest can have many reservations (between 0 and unlimited) of different products (hotel, car or transfer),
iii) guests won’t necessary have the same products at the same time (same/different product at the same/different date)
iv) we will assume all reservations are free, so the price is always 0 and has not to be stored in the DB,
I figured out this mongoDB schema for the reservations collection (the single one):
[{
reservationId,
clients: [{client_id, firstName, lastName}],
hotel:
[{
hotelId,
clients: [ client_id ],
hotel: {hotelName, hotelAddress, hotelCity, hotelCountry, hotelPhone},
hotelDetails: {checkInDate, checkOutDate, isBreakfast, roomCategory}
}],
transfert:[{
transfertId,
clients: [client_id],
transferDetails: {departureAddress, arrivalAddress, date, transfertCompanyName}
}],
car:[{
carId,
clients:[ client_id],
carDetails: {departureAddress, agency, pickupDate, returnDate}
}]
}]
I am not sure if it is a good way to store data. The front end will allow managers to show a given reservation without many details. When clicking a button, they will be able to access details about the reservation.
What do you think of this approach ? Is there any way to optimize it ?
Thank you in advance !
[/quote]
Summary
This text will be hidden