Mastering LPI WDE #5: Server-Side Programming with Databases and Node.js

LPI WDE #5: Server-Side Programming with Databases and Node.js

The previous article in this series talked about JavaScript, the front-end programming language that makes web pages dynamic and enables interaction with the end user. Over the years, JavaScript has also expanded its server-side capabilities, finding applications in back-end programming. And this is where Node.js comes into play.

Node.js for back-end programming

Node.js is a runtime environment that allows you to handle requests received on the web server by running programs written in JavaScript. Node.js is a full-fledged development platform that enables running JavaScript, originally a client-side language, outside the browser, just like any other programming language.

This is where the real revolution lies: a language that was originally intended to be executed only within the browser is now executed outside of it.

From this, numerous advantages arise, including:

  • Ease of learning: Developers who are already familiar with JavaScript and have been working on client-side programming don’t need to learn another programming language to develop their server-side applications. A front-end developer who already masters JavaScript can easily start working on the back-end part of an application without much effort.
  • Ability to create complete and functional applications: Even with knowledge of just one programming language, JavaScript, it is possible to work as a full-stack developer who has expertise in both client-side and server-side development. This enables the creation of comprehensive and fully functional applications.
  • Ability to create various types of applications: With an environment that allows the execution of JavaScript code, it is possible to create standalone programs that can run without the support of a web browser. This opens up possibilities for creating applications of different types and scenarios.

But why is Node.js so beloved by developers?

In addition to the aforementioned advantages, Node.js is an open source, cross-platform environment that boasts a large community of developers worldwide. Furthermore, it is based on an asynchronous, non-blocking, single-threaded, event-driven I/O model, ensuring high performance and excellent execution speed. It manages requests from clients efficiently.

The Linux Professional Institute’s (LPI) Web Development Essentials certificate, to which this series of content is dedicated, guides you step by step in creating simple Node.js applications. Moreover, if you have previously created web pages using HTML, CSS, and JavaScript, you can start building the backend logic of your application, defining how the server should respond to specific user requests.

How to enhance your applications

Within a Node.js project, you can exploit a range of free resources and tools created by other developers to incorporate additional functions, improve productivity, and facilitate your work.

npm, short for Node Package Manager, is the package manager for the Node.js platform. It allows you to install, remove, and manage packages —pre-built projects created by other developers that implement specific functionalities— through a command-line interface. Think of npm as a large online repository for Node.js packages, each with its own unique features.

Among the countless packages available, there are some dedicated to interacting with databases. As mentioned in the first article of this series, back-end programming encompasses all aspects that are not directly visible to the end user, including integration with a database. If an application needs access to external data, it will most likely do so through a database, where the data is stored for quick retrieval.

LPI’s Web Development Essentials specifically covers SQLite, a software library that implements a relational database management system (RDBMS). In this type of database, data can be stored in interconnected tables and queried using simple and intuitive queries.

Database interrogation

Having a relational database at your disposal, you may wonder how to perform operations on it. SQL, which stands for Structured Query Language, is the querying language that allows you to manipulate data within a relational database. It is an extremely popular and user-friendly language that enables you to:

  • Create and delete tables
  • Define the fields and types of data allowed in each table, known as its schema
  • Update data in tables
  • Insert and delete rows in tables
  • Retrieve information
  • Maintain and optimize databases

Now it becomes clear why a relational database is also called an SQL database, precisely because of its query language!

Developers use SQL because it integrates very well with different programming languages. For example, to use SQLite in Node.js, you simply need to install a module using the npm package manager mentioned earlier. Once it’s installed, you will have access to a set of functions that allow you to create and maintain a relational database.

In addition to relational databases, which store information in related tables, there are also non-relational databases, also known as NoSQL databases. These have more flexible schemas and can be equally used in back-end applications. Non-relational databases use storage models optimized for the specific application and data to be stored (for example, information can be stored as simple key-value pairs). Databases of this type are characterized by ease of development, high performance, and excellent flexibility and scalability.

The following table lists the most popular relational and non-relational databases commonly used in back-end applications:

SQL Database NoSQL Database
Microsoft SQL Server MongoDB
SQLite CouchDB
MySQL Redis
MariaDB
PostgreSQL

 

Once you become familiar with the SQL language and the SQLite database, you can then, with some practice, try manipulating data within a non-relational database, discovering the pros and cons of such a solution.

What Next?

In this and the previous articles of the series, we have analyzed the main technologies covered by the WDE certification – HTML, CSS, JavaScript, Node.js, and SQL – and the programming environments where you can start taking your first steps as a web developer.

What is yet to be explored is which learning resources can best prepare you for the actual certification exam. In the upcoming articles of this series, I will show you the essential study materials to pass the Web Development Essentials certification, along with supplementary materials, exam simulations, and some tricks that will surely help you in your learning journey.

<< Read the previous part of this series | Read the next part of this series >>

About Marco Colombo:

Marco Colombo graduated in Telecommunication Engineering at the Polytechnic University of Milan and has been dealing with network administration and IT service management for more than ten years. He is also a trainer, a writer, and the author of the simulation books to pass the Web Development Essentials and LPIC-1 certifications.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *