What is the difference between Backend and Database? (simple explanation)

Hi Friends!

Web Dev can be super complicated, but most of the time it seems so complicated because we are starting to code to early and after a while we not see the forest for the trees, means we stuck in all the code.

When I try to really understand the concept before I start to code, it is often clearer, simpler and more fun. I concider myself still a beginner or maybe intermediate web dev. A lot of things are very confusing, there are a ton of ways to archive the same goals and when you ask 10 people you often get 10 answers and probably none of them is wrong.
.
.

However, I like to build up my first backend and before I do so, it would be great to get a clear understanding what actually happens when creating a backend/database or simply a login option.

Here is the description about the differnce between backend and database in my own words (please correct me when I am wrong!):

The backend is the communication between the frontend and the database, that means the backends job is to grab data (inputs) from the frontend and then send and save it to the database.

For example a user will register an account to get the option to login to a website to get access to additional services (communication with the company, buying a product, reading premium content etc.). When the user registers an account the backend will send the account registration data to the database and store it there. Then the backend will send a confirmation email (which the user needs to verify before he/she gets access to the login area). After confirmation is send the backend will approve the registration and the user can login to his/her account. After the login process the user will see a welcome message in the login area (Welcome back username!). The backend will grab the username from the database and displays it inside the welcome message. After login the user may also have the option to download a specific content (for example a video tutorial), so the backend will grab the content (video tutorial) from the database and offers a download inside the users login area.
.
.
Is this the correct explanation between backend and database ?
Do I understand something wrong ?
How would you describe the differnce?

Thanks for your answers ! :slight_smile:

I would say that the frontend/client is the portion of web site that runs on your computer, in your browser. It uses the HTML, CSS, and JS parsers that are built into your browser. Very simple web static pages can work like this, like the projects in the RWD section.

A web site has to reside somewhere. When you log onto a web site, you are talking the the server (backend). For a simple static web site (like mentioned above), it may be just “serving” back those files to the client. But when we talk about a backend, we’re talking about something more dynamic, where it has to interact. In some cases, those web pages might be build dynamically. In some cases data is requested and sent back and forth. Technically you can have a backend that is just APIs, for requesting and getting data.

Your database is just a part of your backend, where you store data that you want to persist. Your server has memory while it is running, but if you want data to survive having the server shut down and/or if the data is too large to store in the server’s active memory (especially with a lot of users, that would run out quickly) you can store it in the server. You’re going to access that server through the backend so you can control access.

Does that help?

1 Like

@kevinSmith Yes that helps, thanks for your participation :slight_smile:

Oh thats interesting… so when I am creating a backend I need to handle a lot of API requests? I already made some API requests to fetch data and display it in the frontend, so it seams like thats a similar concept?

Furthermore it becomes clearer to me that (nearly) every exchange is handled within JSON files. I mean the data which we can exchaneg in API requests are all stored inside a JSON file, so that there is a clear structure to handle the data. I guess thats the same concept with the exchange of data within the frontend and backend/database. Is that correct?

Now I need to decide which stack I like to choose to build a backend. I guess it would be the best option to use Node js (backend) and MongoDB (database). It seems like a solide and future proofed solution to most web applications. However there are a lot of people who use firebase or alternative solutions which seems easier and faster to setup. What would be your recommendation?

If I choose Node js and MongoDB, how much time I need to spend to build a simple backend (User can login and exchange data with me (text, image, zip files))?

Thanks! :santa:

An API is the interface via which you interact with a program or application programatically (rather than say via a user interface, or via physical buttons or whatever). That’s all it is, normally a set of commands that the application exposes to let you use it. So in this case, the API for a server might be something like:

https://example.com/api/users
https://example.com/api/user/1

On the application that lives on the server which has the URL “example dot com” registered to it, you program it so that when it receives a request that matches api/users it sends back some data that has some information about users. When it receives a request that matches api/user/1 it sends back some data that has some information about a user with the id of 1.

The “backend” here, for a web application, is going to mean something that has to live on one specific computer somewhere. Users can’t access that application directly.

The “frontend” is a set of files (some JS maybe, always some HTML) that also live on one specific computer. But a user can go and download them onto their computer using a browser. The browser can then render them as a web app. And that web app is the thing through which they call the API commands.

No, it just happens to be the most common. When data is sent, it can be in any format. It’s just easier if it’s in a format that’s really easy to deal with. Like with the fictional API above,

https://example.com/api/user/1

Could just return

The user you're asking about is called Wallace, he's 42 and he loves cheese and inventing things!

But it’s more useful, from a programmers perspective if it returns

{ "id": "1", "name": "Wallace", "age": 42, "likes": ["inventing", "cheese"] }

There are loads of other data formats, JSON just happens to be popular because it’s very simple and easily understandable to both humans and computers

1 Like

Thank you so much for this kind answer. I highly apprechiate the support in this forum and it becomes much clearer to me, what a backend actually is. I am not afraid to build my own one anymore :slight_smile:

I would like to ask another question:

When there is the need to build a secure backend, for example to login to financial services (banks, stock exchanges etc) what is important to concider?

I read that some of these backends use a high-end 2048-bit encryption to protect the data from there users. Is it much more difficult to develop such an encrypted and secure backend or is it just different algorithms that are used for it?

Can a standard backend with 2 factor authentication also guarantee that the data is secure and cannot be hacked?

How is that actually with the responsibility, as programmers we carry nevertheless also a high responsibility that data cannot be stolen, right?

Thanks for help!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.