MySQL - What is a Database
What is a Database?
A database is an organized collection of data that can be stored, managed, and retrieved efficiently.
Instead of keeping data in files, spreadsheets, or notebooks, databases are designed to handle large amounts of structured information with speed and accuracy.
In simple terms:
-
Database = Digital filing cabinet.
-
Database Management System (DBMS) = Software that manages that cabinet.
-
MySQL = A popular relational DBMS (RDBMS).
Key Characteristics of a Database
-
Organized structure → Data is stored in tables (rows & columns).
-
Easy access → You can quickly search, sort, and filter information.
-
Relationships → Data in one table can be linked to another.
-
Security → Access can be restricted with usernames & passwords.
-
Consistency → Prevents duplication and maintains data integrity.
Example (Library Database)
Imagine we are building a Library Management System.
We need to keep track of:
-
Books
-
Members
-
Borrowing records
Table 1: books
| book_id | title | author | year | available |
|---|---|---|---|---|
| 1 | Harry Potter | J.K. Rowling | 1997 | Yes |
| 2 | The Hobbit | J.R.R. Tolkien | 1937 | No |
| 3 | Clean Code | Robert C. Martin | 2008 | Yes |
Table 2: members
| member_id | name | join_date |
|---|---|---|
| 101 | Alice Smith | 2023-05-10 |
| 102 | Bob Jones | 2024-01-15 |
Table 3: borrowed_books
| borrow_id | member_id | book_id | borrow_date | return_date |
|---|---|---|---|---|
| 1 | 101 | 2 | 2024-06-01 | 2024-06-15 |
-
These tables together form a database.
-
We can use SQL (Structured Query Language) in MySQL to ask questions like:
-
Which books are available?
-
Which member borrowed "The Hobbit"?
-
How many books were borrowed in June?
-