How to write a sql query in a js.file?

Hello, in the skill path “create a back-end with javascript”, there are 2 capstone projects in which you have to write a sql query in your js file.(found here and here
I have read the solution code too and i don’t understand the logic behind some of it, as for as I know, this hasn’t been explained in the course either and I haven’t found my answers on google.

More specifically, i struggle with code like this:'CREATE TABLE IF NOT EXISTS `Employee` ( ' +
           '`id` INTEGER NOT NULL, ' +
           '`name` TEXT NOT NULL, ' +
           '`position` TEXT NOT NULL, ' +
           '`wage` INTEGER NOT NULL, ' +
           '`is_current_employee` INTEGER NOT NULL DEFAULT 1, ' +
           'PRIMARY KEY(`id`) )');

I understand from google that variables like Employee(your table name) need to be between backticks, what I don’t get is the part behind that.
The column names and datatypes look incredible messy with a lot of backticks, regular brackets and for some reason plus signs, trying to write it differently results in me getting a lot of error messages.
So I would be happy to hear why it’s written like that.

Thanks in advance.

1 Like

Hey! I didn’t understand why the it needs backticks. Could you link me to what you’ve found on google? I’m doing the Expresso project and when I run node migration, all tables do just fine without backticks but Employee scecifically gets only errors when running test. Since it’s almost a month you’ve been over this issue, I guess you might’ve figured it out!

Not sure if the content was revamped between when you did it and now when I did it, but in the DB creation step of the x-press capstone, I didn’t use any back-ticks at all since the query you pass to the sqlite database just needs to be a string, and doesn’t need field names to be interpolated,

For example:“CREATE TABLE IF NOT EXISTS Series (id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL, description TEXT NOT NULL)”, (err) => {
if(err) {
} else {
console.log(‘Series table created’);