How should I design a database that has time tables? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How should I design a database that has time tables?

I'm working on a project in MERN stack. The project requires a database (Mongodb) that has - weekly time table that can be different for each week - a master time table that remains the same - a new time table is generated from master every week so that changes for that week can be made in it What should be the schema of this database that is efficient? I've never designed such a complex database before and have no idea about the steps I should follow to do this...could you help me out? The schema for a particular time slot in the table is {slotName: String, startTime: Integer, endTime: Integer}.

13th Apr 2021, 4:59 AM
Aditya Rana
3 Answers
+ 3
I don't know much about mongo, but to me this problem really looks like a better fit for a relational database. Any particular reason for choosing NoSQL? This might be a little help: https://www.reddit.com/r/mongodb/comments/7v822n/is_mongodb_appropriate_for_a_timesheet_app/
13th Apr 2021, 5:57 AM
Tibor Santa
Tibor Santa - avatar
+ 1
My idea is- Group the slots together into days. 0 for Monday, 1 for Tuesday and so on. 0: {slots}, 1: {slots}, etc. Then I group these days (from Monday to Friday) in a week. The key for the week would be offset of the week from now. 0: {days}, // current week 1: {days}, // next week 2: {days} // week after that and so on. But something tells me this isn't a good design. Is there something better I can do?
13th Apr 2021, 5:02 AM
Aditya Rana
+ 1
Tibor Santa no, there wasn't really any technical reason for choosing mongo. It's just that we had experience with it and knew the free cloud services we could use. I'll check out the link, thank you!!
13th Apr 2021, 7:17 AM
Aditya Rana