Database.What is a “database”?

A database is an organized collection of data that can be easily accessed, managed, and updated. It’s designed to store, retrieve, and manipulate information efficiently.

Here are key points:

  • Structured: Data is usually organized into tables (rows and columns) in relational databases like MySQL or PostgreSQL, or into collections/documents in NoSQL databases like MongoDB.
  • Managed by DBMS: A Database Management System (DBMS) like Oracle, MySQL, or MongoDB handles operations like querying, inserting, updating, and deleting data.
  • Persistent: Data in a database is stored permanently (until explicitly removed), unlike temporary memory.
  • Multi-user: Databases support access by multiple users at the same time, often with controls to prevent conflicts.

🗃 Relational Databases (RDBMS)

  • Structure: Data is stored in tables (rows & columns).
  • Schema: Has a fixed schema – you must define the structure (e.g., column names, types) before inserting data.
  • Relationships: Uses primary keys and foreign keys to define relationships between tables.
  • Examples:
    • MySQL
    • PostgreSQL
    • Oracle
    • Microsoft SQL Server
  • Best for: Structured data with complex queries and relationships (e.g., banking, ERP systems).

Example:

SELECT * FROM users WHERE age > 30;

🌐 Non-relational Databases (NoSQL)

  • Structure: Stores data in flexible formats:
    • Document (e.g., MongoDB)
    • Key-Value (e.g., Redis)
    • Column-family (e.g., Cassandra)
    • Graph (e.g., Neo4j)
  • Schema: Schema-less – structure can change over time.
  • Relationships: Usually no joins; embedding or linking data instead.
  • Examples:
    • MongoDB (document)
    • Redis (key-value)
    • Cassandra (columnar)
    • Neo4j (graph)
  • Best for: Unstructured or semi-structured data, high scalability, rapid development.

Example (MongoDB):

{
  "name": "Alice",
  "age": 32,
  "hobbies": ["reading", "cycling"]
}

✅ Summary

FeatureRelational (SQL)Non-relational (NoSQL)
Data modelTablesDocuments, key-value, etc.
SchemaFixedDynamic / Flexible
RelationshipsStrong (joins)Weak or embedded
ScalabilityVerticalHorizontal
Use caseComplex queriesBig data, real-time apps
This entry was posted in Без рубрики. Bookmark the permalink.