Exercise 9: Music Festival
On this page
erDiagram
performer {
string name
string genre
datetime birth_date
int key PK "id_performer"
}
time_units {
string name
string label
string uuid
int key PK "id_time_units"
}
festival {
string title
datetime start_date
datetime end_date
decimal budget
decimal total_cost
string location
int key PK "id_festival"
int id_performer FK "id_performer"
int id_festival_state FK "id_festival_state"
}
performer_festival {
int duration
decimal cost
datetime moment_of_performance
int key PK "id_performer_festival"
int id_festival FK "id_festival"
int id_performer FK "id_performer"
int id_time_units FK "id_time_units"
}
customer {
string name
string phone
string email
decimal total_tax
int key PK "id_customer"
}
ticket {
string number
decimal price
datetime purchase_date
int key PK "id_ticket"
int id_festival FK "id_festival"
int id_customer FK "id_customer"
}
festival_state {
string name
string label
string uuid
int key PK "id_festival_state"
}
performer_festival one--many festival : has
time_units one--many performer_festival: has
performer_festival one--many performer : has
festival_state one--many festival : has
festival one--many ticket: has
customer one--many ticket: buy
Description
The property “name” in the table “performance_state” can have the values: “Scheduled”, “Ongoing”, “Completed” and “Canceled”.
The property “name” in the table “time_units” can have the values: “Minutes” and “Hours”.
In entities “time_units” and “performance_state”, name represents the state that will be displayed on the screen, label represents the value that programmer will use to filter the states, and the uuid represents a value to distinguish the states.
A performer performs at a festival in the time interval “start_date” and “end_date” of the festival.
The value of the field “total_cost” from the entity “festival” is the sum of the cost for every performer that performed in that festival.
OBS: The value of the field “uuid” is generated automatically.
Tasks
performer/performer_festival/time_units/festival_state/festival/ticket/customer: Add, Edit, Delete.
- When the performance is created, it will automatically become “Scheduled”.
- The field “Festival state” from entity “festival” will be read-only in edit view.
Create a catalog for entities: “festival_state”, “festival”, “performer”, “ticket”, “time_units”, and “customer”.
Create event listeners for tables that needs validations (e.g., adding a performer without a name, festival without title, etc., should not be allowed).
Check if the performer is occupied in the time interval of a festival (if he is at another festival in that interval), if he is → validation message.
- To calculate when the performer ends his performance at a festival, use datetime→plusMinutes(dateStart, duration) and datetime→plusHours(dateStart, duration).
Check if “total_cost” of the festival is higher than the sum of total tickets price and festival’s budget, if it is → validation message;
Add an entity action at the fesival level “Start festival”:
- First check if the festival has already been started (it already has the “Ongoing” state), if it was → validation message;
- It will change the status from “Scheduled” → “Ongoing”;
- A festival cannot start if it is in the “Canceled” or “Completed” state → validation message.
Add a new entity action at the festival level “Cancel festival”:
- It will change the festival status to “Canceled”;
- A festival cannot be canceled if it is in the “Ongoing” or “Completed” state → validation message;
- A festival cannot be canceled if it is already in the “Canceled” state → validation message.
Add a new entity action at the festival level “Complete festival”:
- It will change the festival status from “Ongoing” → “Completed”;
- It can’t be completed if it has the status “Scheduled” or “Canceled” → validation message;
- If it is already in “Completed” state → validation message.
Performer report: festival situation at performer level (total number of festivals, ticket value).
Ticket report: festival situation at ticket level (total number of festivals, ticket value, total number tickets).
Customer report: total number of festivals, ticket value.