Relational Databases
There are still many good reasons to use a traditional database with SQL, and Node interfaces with popular open source choices.
MySQL
MySQL has become the workhorse of the open source world for good reason: it provides many of the same capabilities as larger commercial databases for free. In its current form, MySQL is performant and feature-rich.
Using NodeDB
The node-db module provides a native code interface to popular database systems, including MySQL, using a common API that the module exposes to Node. Although node-db supports more than just MySQL, this section focuses on using MySQL in your application code. Since Oracle’s purchase of Sun Microsystems, the future of MySQL and its community has come under much speculation. Some groups advocate moving to a drop-in replacement such as MariaDB or switching to a different relational database management system (RDBMS) entirely. Although MySQL isn’t going away anytime soon, you need to decide for yourself whether it will be the right choice of software for your work.
Installation
The MySQL client development libraries are a prerequisite for the Node
database module. On Ubuntu, you can install the libraries using apt:
sudo apt-get install libmysqlclient-dev
Using npm, install a package named db-mysql:
npm install -g db-mysql
To run the examples in this
section, you will need to have a database called
upandrunning with a user
dev who has the password
dev. The following script will create the database table and basic schema: ...