SQL in React + Express



I’m confused about how to integrate sql database with the front end/middlewares

  1. where do we create the database?
  • in the codestrips project, we had to db.run a CREATE TABLE function in a sql.js file that’s separate from the app.js. My questions are:
    1a. why don’t we create a table directly within app.js?
    1b. we never exported/imported sql.js into app.js. If we created the table in sql.js, how did app.js know about that table?
    1c. In both the app.js and sql.js files, we created a database called db with the new sqlite3.database() function. are these two ‘db’ unique, or is it a shared database (even though we never imported/exported them)?
    1d. when we run an app.get(’/path’…), what does path really represent? Must I create a folder called path that has an sql file inside? how do I create a path before I can actually mount a router on on it?
  1. This one is about express:
  • why use app.get when you can use $.ajax()?