Why databases matter in web apps
Databases are what make interactive and personalized experiences possible. They allow your app to:- Remember who your users are
- Save data like messages, settings, or files
- Keep information secure and private
- Scale so that hundreds or thousands of people can use your app at the same time
How databases are structured
Databases organize information in a way that is easy to search and connect. The structure is a lot like a spreadsheet:- Tables are categories, such as “Users” or “Orders.”
- Rows represent individual items, such as a single user or order.
- Columns are the properties, such as a user’s name or an order date.
The main parts of the Bolt Database
Here are some of the key features you’ll see in your Bolt Database:- Data tables (like spreadsheets) Your database stores information in tables that resemble spreadsheets. Each row is a record (like a single user or order), and each column is a property (like name, email, or date).
- Authentication This handles sign-ups, logins, and secure access. In Bolt, authentication is integrated with the database so only the right people can access or modify their data.
- Server functions (also known as edge functions) These are instructions that run on the server to automate tasks. For example, sending a welcome email after a user signs up or updating inventory when someone places an order.
- Secrets These are sensitive details that your app uses to connect securely to other services, such as payment providers or third-party APIs. Secrets are stored securely alongside your database, so you don’t need to hard-code them or worry about them leaking.
- User management This is how the database tracks your users, their roles, and the actions they’re allowed to perform within your app.
When you need a database (and when you don’t)
- You don’t need one if your site is just showing information that rarely changes, such as a personal blog or a static landing page.
- You do need one if your app allows people to log in, save data, interact with each other, or make changes that should persist the next time they return.
- Social apps where people create profiles or post updates
- Marketplaces that track buyers, sellers, and listings
- Business dashboards that store and visualize company data
- Productivity tools like notes, tasks, or calendars
Connecting information together
Many apps need to link data. For example:- A user might have many posts.
- A customer might place many orders. These connections are called relationships, and they let your app tie different types of information together in meaningful ways.
Keeping data safe
Databases often store personal or sensitive information, so security is built in. Authentication protects accounts, permissions decide who can access or change data, and secrets keep private keys hidden. Even if you don’t manage these directly, it helps to know they are there working in the background.Creating a database in Bolt
With Bolt, you don’t need to set up a database from scratch. In fact, Bolt will typically automatically create one as soon as your project needs it. For example, if you add a login form or a feature where users can save information, Bolt will recognize that your app requires memory and set up a database for you in the background. You can also explicitly prompt Bolt to create a database using the chatbox.Example: When you might add a database
Let’s say you started with a simple personal recipe website where you list out your favorite dishes. At first, it’s just static content, like text and photos, so Bolt doesn’t need a database. But then you decide you want visitors to create their own accounts and save their favorite recipes. That means your site now needs to remember users, store their saved recipes, and let them log back in later. This is where Bolt Database comes in. Here’s an example of how you might prompt Bolt to make that change: Example prompt:I want people to be able to create accounts with email and password, log in, and save their favorite recipes. Set up an authentication and a database table for storing users and their saved recipes
Bolt will then recognize the need for a database, create it automatically, and connect it to your app so you don’t have to do the setup work yourself.
Real-time updates
With Bolt’s Postgres setup, changes can be sent to your app instantly, so when someone posts a new message or updates stock, for example, it shows up right away without refreshing. That means when something changes, such as a new chat message or a stock level in an online store, the change can appear immediately without needing to refresh the page.Growing with your app
A database might start small with just a few rows, but it can expand to handle thousands or even millions of records. This means your app can grow without you needing to rethink how data is stored.PostgreSQL: The type of database Bolt uses
Bolt Database is built on PostgreSQL (often called Postgres), which is a type of SQL database.What SQL means
SQL stands for Structured Query Language. It’s the standard way of interacting with relational databases, which are databases that organize data into tables with rows and columns, allowing you to connect that data through relationships. In practice, this means that your data in Bolt is stored in an organized and flexible way, capable of handling everything from a handful of users to thousands of records across multiple tables. SQL makes it easy to sort, filter, and connect data efficiently, which is why it has been the backbone of most web applications for decades.Why Postgres matters
Postgres is one of the most trusted SQL databases in the world. It’s:- Reliable: tested and stable for decades
- Scalable: works for small apps and large, enterprise-level systems
- Feature-rich: supports advanced data types, relationships, and real-time features
- Open source: widely supported by a large community of developers
Why Bolt chose Postgres
Bolt uses Postgres because it gives you the best of both worlds:- The reliability and structure of SQL
- Modern features like real-time updates
- Flexibility to scale as your project grows
- Wide compatibility with tools and standards in the industry