I don’t have a background in coding & honestly, when I was first learning how to create a database, I struggled — and if I’m being more honest, I still struggle to this day. Does that give you confidence in reading this? Maybe not. But here’s what I will say, since I’m so fresh to relational databases, I know what you’re going through & I’m here to help. So let’s dig in!
First Up, What is a Database?
I googled ‘database’ & here’s what I found: a database is a structured set of data held in a computer. I was hoping for a little bit more, but in layman's terms, a database is a spreadsheet filled with information.
There are two things that come immediately to mind when I hear about coding — lots of zeros & ones, like they show in TV shows & well, just numbers in general. With that skewed perception of writing code, I also carried a different perception of what a database was. It’s an Excel Spreadsheet, or a Google Sheet for some of you folks. Seriously, that’s it. It can contain numbers, or words, or sentences, or dates & times, URLs, all sorts of different types of information!
Databases are made up of rows & columns used to relate information. Across a row, you might find various data points that describe one thing. Down a column, you’re likely to find multiple answers that relate back to the row's data point.
Let’s look at an example of a database about children in school:
Above, the database contains three student records & the same properties for each of them, namely their grade, age, GPA, Absences, & Tardies. This is a very common example of a database that you might see at the local high school (of course there would be lots more student records there)!
Broken down like this, databases become a little bit easier to understand. With the information above, I could sort by GPA, or perhaps filter by grade & those are two functionalities that come built-in to your database.
With that basic understanding of what a database is, why would you turn your database into an app? The short answer is because that can take a long time when simply every spreadsheet does not need to be an app. The longer answer is, there are many things that can be accomplished with spreadsheets but visually, the data may not be appealing & as you begin to add relationships between data collections, utilizing a spreadsheet is not the ideal way to communicate that information.
What Makes a Database Relational?
A relational database is a type of database that stores and provides access to data points that are related to one another. Much like rows & columns are related in a single spreadsheet, relational databases tie related information together through a single property — called a key.
Let’s add to the student example above. Using a school as an example, it might make sense that in a school district there are multiple high schools. So let’s make a database for high schools:
While this database stands along perfectly fine, in reality, the school has a relationship with a student.
The relationship in this example is a One-to-Many relationship from students.
A student belongs to one school.
One school has many students.
Connecting those database collections would look something like this:
The section highlighted in yellow demonstrates the relationship. In the School Collection, the Students property can have more than one student, whereas in the Student Collection, the School Name property can only contain one school name.
These two collections are related to each other & now when completing sorting or filtering, you’re able to use properties from either collection in order to segment your information. One of the benefits to separating this information into two different collections is the ability for your app to work quickly, as well as organize information to better display.
Four Types of Relationships
Within a Relational Database, there are four types of defined relationships. Selecting the proper relationship for your data is important to ensuring the proper data is displayed when it comes to setting up your app.
Let’s work through those relationship types.
One-to-One
In a one-to-one relationship, one row in one table belongs to one row, and only one row, in another table.
To use our school & student example, if we created a table for grades on the Science Exam, a student can only have one grade & that grade can only relate to one student.
In this example, the student is the key & it relates the grade on the Science Exam to the student even though the information exists in two database collections.
One-to-Many
In a one-to-many relationship, one row of information can relate to many records (read: rows) in a different collection.
To continue with the school & student example above — there are many science teachers within a school, however there are many more students. If we have a collection of teachers (and their associated information), we could create a one-to-many relationship to students.
In a one-to-many relationship:
One science teacher can have many students.
But a student has one science teacher.
Many-to-One
In a Many-to-One relationship, the same definition applies from a One-to-Many but it goes in the opposite direction.
To continue with the scenario, many students can belong to a lunch period, however A lunch period can only belong to one student.
Between the One-to-Many and the Many-to-One, it depends on which collection the relationship is starting with in order to define which type of relationship is correct while setting up that property.
Between the One-to-Many and the Many-to-One, it depends on which collection the relationship is starting with in order to define which type of relationship is correct while setting up that property.
Many-to-Many
In a Many-to-Many relationship, one row within a collection can relate to many rows in the second collection, while one row in the second collection can relate to many rows in the first collection.
A great example of this is class scheduling & teachers.
A teacher can have multiple class periods.
A class period can relate to multiple teachers.
This is apparent in most schools, where there are many classes taking place at one time & each class must be taught by at least one teacher. Let’s take a look at what these two collections might look like.
As you can see in the two collections above, each teacher works multiple class periods, while each class period belongs to multiple teachers.
To set up a relationship, there is a specific data type you select to signify you would like that property to be defined by an existing collection in Adalo. It is not a traditional property where you would select a data type like text, number, date & time, image, etc. Setting up relationships correctly will determine whether or not you are able to correctly display, sort, and filter data in a way that makes sense for your app.
Why are Relational Databases Important?
At this point you may be wondering why you have to use a relational database for all of this — wouldn’t it just be easier to make a huge spreadsheet that contains all this information?
I’m with you. Relational Databases can be tricky to understand at first & I won’t lie and say that there aren’t times when I have to process how a relationship might be set up to get the result I am looking for. But, there are so many advantages to mastering & employing relational databases for your app development.
Data Accuracy
Since relational databases are set up through the use of keys, there is little chance for duplication of data. If there are multiple records of the same information, it can be difficult to trust which source of information is correct. With relational databases, the elimination of duplicate entries ensures your data is the most accurate.
Access to Data
In other types of databases that rely on hierarchy of information or specific pathways to access information, it is difficult to search, filter, and sort the data in any way that you would like. Instead, in a relational database, pulling out the exact information you need is much simpler.
Flexibility
By creating a relational database, you will not be restricted when adding more data in the future. The database allows for the possibilities of being ever-growing & shifting to meet the needs of the information that will be stored.
Learning about Relational Databases can be a very daunting task especially for non-developers entering the no-code space. While there are lots of resources to check out about designing your database, as well as understanding how to set up a database, the best advice I can give is to play in a tool like Adalo or Airtable that allows you to make changes to your database & display the results in real time.
Another good practice is to begin looking at popular software or apps that you use and picture how they have set up their database to get a better understanding of how you might set up your database in the future. If you’re opting to play around for a little with relational databases, use an example that you’re familiar with & can think of multiple different types of relationships, similar to my school example from above.
The more familiar you become with this integral part to developing apps, even no-code ones, the more intricate & powerful your apps can become. With no-code freelancing on the rise, creating high-quality software has never been more accessible or affordable. This paradigm shift has leveled the playing field and enabled more people and agencies to meet the growing demand for software applications. Ready to join the revolution? Head to Adalo App Academy to learn how to build apps without coding and get ahead of the curve. And if you're already experienced with no-code tools, why not monetize your skills and become an Adalo Expert? Don't miss out on the chance to shape the future of software development!