MariaDB Community

For beginners

Database, table, index, transaction — explained in plain English

What is a relational database, really?

Mental model:

ConceptLike...
DatabaseAn Excel file
TableA Sheet in that file
RowA row in the sheet
ColumnA typed column in the sheet
Primary keyThe row's unique ID
IndexA lookup table for fast queries
TransactionA group of changes that all happen or none do

MariaDB stores those "files", lets many programs read/write at once safely, survives power loss, and is queried with SQL.

Your first table

CREATE DATABASE blog;
USE blog;

CREATE TABLE posts (
  id          BIGINT AUTO_INCREMENT PRIMARY KEY,
  title       VARCHAR(200)  NOT NULL,
  body        TEXT,
  author      VARCHAR(64)   NOT NULL,
  created_at  DATETIME      DEFAULT CURRENT_TIMESTAMP,
  INDEX idx_author (author)
);

INSERT INTO posts (title, body, author)
VALUES ('Hello', 'First post', 'alice'),
       ('Another', 'Written by AI', 'bob');

SELECT * FROM posts WHERE author = 'alice';

Top beginner pitfalls

  1. Use utf8mb4, never utf8. The legacy utf8 only stores 3 bytes/char — no emoji, no rare Han glyphs.
  2. Primary keys: BIGINT AUTO_INCREMENT or UUID v7. Don't use business fields (email, phone) — they change.
  3. Don't index every column. Indexes speed reads but slow writes and take space.
  4. Don't forget COMMIT in transactions.
  5. Don't use MyISAM. No transactions, not crash-safe. Default to InnoDB.

Next

On this page