I am trying to design a movie ticket booking system in Java. I am stuck on this subjective problem, where there is are multiple cities, and inside each city are multiple theatres.
Now, while designing the class, should I do –
class Theatre {
}
class City {
List<Theatre> theatres;
}
or should I do –
class City {
}
class Theatre {
City city;
}
Which would be a better design? Will there be database design implications of one over the other? Will there be optimisation issues as we are accessing a list? Will it affect API design?
What is right? And what could go wrong? Any anti-patterns? Kindly include DB, optimisation, API related thoughts as well.