Introduction to data modeling for a REST API

How to start designing a database schema

In previous articles we have implemented a few examples of simple applications written in Node.js and Express, that provide REST APIs based on some data.

We have seen how to connect to databases, how to retrieve data from them, and how to send the data back to the browser.

In our sample applications, we have assumed some existing data model that already had some pre-defined structure.

But, as application developers, we often need to design the database structure as well, also known as database schema. We need to look at the functionalities our application will have and we have to come up with tables, and columns, that represent entities in our application.

For example, if we have a concept of a User, in our domain, we need to figure out what attributes or properties this User has. Does it have a name? Would the name be split up into "first name" and "last name"? What about the middle initial?

Does the User have an address? Can we cram the full address into a database column or do we need to separate the various components of the address, that is: street, city, state, etc?

These are all decisions that need to be made before starting building an application. It's true that we can modify schema and update as we go along, so we don't need to know everything before we start designing the database.

But it's also true that we need to start somewhere, and if we don't have at least an initial idea of how our data is going to be structured, we risk having to modify our application too much, wasting time and development cycles.

Designing a database structure

Designing a database structure with tables and columns, can be quickly done with pen and paper. But there are also online tools that help us in the process, so we can make it more formal or in case we need to collaborate with other team members.

One such tool is DB Designer , which, in addition to paid plans, has a zero cost starter plan so we can get our feet wet with database design for free.

Once we sign up for the plan, and launch the application, we are shown a blank canvas where we can start designing our database schema.

DB Designer provides tools that help us visually design database tables, columns, and other elements of our schema.
It has a simple user interface and lets us collaborate with different team members on the internet, so we can work on a data model at the same time.

We can also export our designs and share links to our data models.

In the following articles we will give a little demonstration of the tools available by designing a schema for an application that keeps track of user points based on healthy choices they make during the day.

This would simply be an example for showing how we could go about working on data modeling.


Did you like this article? Share it with your friends.
I write daily about front-end and back-end web technologies.
You can receive all my articles in your inbox by subscribing to my newsletter. Just click the button below. No spam, just good, useful content. Guaranteed!

Follow me on Twitter