Hi all

I have experience coding since I started hacking in python 5 years ago. Since Covid i’ve had more spare time and am working through the Node course by Jonas Schmedtmann, which I really like so far.

I am not using mongoose but have managed to use Postgres & Sequelize in place of it in his course, successfully to the end of the sections on MVC so far.

Now I want to take a break from learning and begin the backend for an idea of my own; a habit and goal tracking web app. The basic sketch is on my beautifully designed sitemap picture with this post. My question pertains to the CRUD part, specifically creating new habits (as tables).

Here are my question(s):

Say User wants to create new habit, say, practice major scale on piano twice a day. She decides on the types of data she’ll need to track and name them. To wit:

const pianoPractice ={ startTime: {type: Sequelize.DATE}, endTime : {type: Sequelize.DATE}, key : { type : Sequelize.STRING(1)}, bpm : {type: Sequelize.INTEGER}} 

So the user – probably using html inputs – can create new habits and that will determine the sequelize model and its data types.

Now i’m thinking that might not be best practice as i’m describing the user dynamically creating a model.

One solution is to have lots of predefined models and only allow user to use what’s already predefined on the server side in my MVC architecture. Then i’ll tweak as I go along or allow them to choose which fields within each habit to track/view.

Post image

Second, I am thinking each new habit will be a table in a database. I’m thinking I/User won’t be wanting to track more than 10 – 15 habits daily so speedwise i’m wanting to know if this many tables sounds ok (using the Heroku free tier to eventually deploy it – you get 10,000 rows; doesn’t seem to be a table limit).

Of course I can always finish the course but I want to get stuck in a bit. Can you please advise whether this sounds ok or provide some tips on how I should design it better. Many thanks.



Source link

Write A Comment