I am a new MySQL
learner and like to use it within a NodeJS
application. From my previous knowledge with MongoDB
all the tables we need will be created by MongoDB automatically. We only needed to connect to the MongoDB and with create
or save
commands it could find the table and put something inside or create the table if it was not exist.
But from MySQL tutorials I have seen so far they create databases manually by executing SQL codes directly inside a MySQL shell/bash or by using applications like MySQL Workbench
.
So I want to make sure which way is correct? Should I create my tables before running my Node app or there is also a way, and it is a good way to create tables dynamically within the code when it's needed regarding the app usage by the user? If the second way is a better way, how can I do that? Is there a code sample for creating databases from inside a Node app?
Moreover the same question for databases. Can we or is it a good way creating them from inside our Node app?