JavaScript Set 7 Flashcards

1
Q

What does NPM stand for and what does it do?

A

Stands for Node.js package manager
It is the default package manager for Node.js runtime
It is the world’s largest software registry and is used by developers to share software

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are DML statements?

A

Stands for data manipulation language. They are a subset of SQL used for managing data in a database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the 4 main DML statements?

A
  1. SELECT to retrieve data from a table
  2. INSERT to put data in a table
  3. UPDATE to update data in a table
  4. DELETE to remove data from a table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are DDL statements?

A

Stands for data definition language. They are a subset of SQL used for defining and managing the structure of a database and its objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 2 main DDL statements?

A
  1. CREATE DATABASE
  2. CREATE TABLE
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you connect to MySQL using node.js?

A
  1. Install mysql package with npm
    npm install mysql
  2. Include the mysql package in the JS code
    require(‘mysql’);
  3. Create a mysql connection object
    var con = mysql.createConnection({host: “”, user: “”, password: “”});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you create a database with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”});
con.connect(function(err) {
con.query(create db statement,
callback function(err, result));
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you create a table with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”, database:””});
con.connect(function(err) {
con.query(create table statement,
callback function(err, result));
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you insert a single record into a table with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”, database: “”});
con.connect(function(err) {
var sql = “INSERT INTO table…”;
con.query(sql, callback function(err,
result));
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you insert multiple records into a table with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”, database: “”});
con.connect(function(err) {
var sql = “INSERT INTO table
(columns) VALUES ?”
var values = [[record 1], [record 2],
…];
con.query(sql, [values], callback
function (err, result));
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you select data from a table with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”, database: “”});
con.connect(function(err) {
var sql = “SELECT * FROM table”;
con.query(sql, callback function(err,
result, fields));
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you delete data from a table with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”, database: “”});
con.connect(function(err) {
var sql = “DELETE FROM table
WHERE…”;
con.query(sql, callback function(err,
result, fields);
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you update data in a table with the mysql package?

A

var con = mysql.createConnection({host: “”, user: “”, password: “”, database: “”});
con.connect(function(err) {
var SQL = “UPDATE table SET
field=value WHERE condition”;
con.query(sql, function(err, result,
fields));
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly