What does NPM stand for and what does it do?
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
What are DML statements?
Stands for data manipulation language. They are a subset of SQL used for managing data in a database
What are the 4 main DML statements?
What are DDL statements?
Stands for data definition language. They are a subset of SQL used for defining and managing the structure of a database and its objects
What are the 2 main DDL statements?
How can you connect to MySQL using node.js?
How can you create a database with the mysql package?
var con = mysql.createConnection({host: “”, user: “”, password: “”});
con.connect(function(err) {
con.query(create db statement,
callback function(err, result));
});
How can you create a table with the mysql package?
var con = mysql.createConnection({host: “”, user: “”, password: “”, database:””});
con.connect(function(err) {
con.query(create table statement,
callback function(err, result));
});
How can you insert a single record into a table with the mysql package?
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 can you insert multiple records into a table with the mysql package?
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 can you select data from a table with the mysql package?
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 can you delete data from a table with the mysql package?
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 can you update data in a table with the mysql package?
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));
});