Junior
What types of databases exist?
sobes.tech AI
Answer from AI
Databases are classified by several features, the main types:
-
Relational (SQL-oriented):
- Data is stored in tables with rows and columns.
- Relationships between tables are defined by primary and foreign keys.
- SQL language is used for queries.
- Examples: PostgreSQL, MySQL, Oracle, SQL Server.
-
Non-relational (NoSQL):
- Differ from relational with flexible schemas and horizontal scaling.
- There are different data models:
- Key-value: Redis, Memcached.
- Document-oriented: MongoDB, Couchbase.
- Wide-column: Cassandra, HBase.
- Graph: Neo4j, ArangoDB.
-
In-Memory:
- Data is stored directly in RAM for fast access.
- Can be relational or NoSQL.
- Examples: Redis, Memcached, SAP HANA.
-
Time Series:
- Optimized for storing and analyzing data arriving in chronological order.
- Examples: InfluxDB, TimescaleDB.
-
Multi-model:
- Supports multiple data models simultaneously (e.g., document and graph).
- Examples: ArangoDB, OrientDB.
-
Spatial:
- Optimized for storing and querying data with geographic coordinates.
- Often extensions of relational or NoSQL DBMS (e.g., PostGIS for PostgreSQL).
-
Master-Slave:
- Architectural pattern for data replication. One node (master) handles writes, others (slaves) only read and synchronize with master. Used for read scaling and fault tolerance.
-
Sharded:
- Data is distributed across multiple independent nodes (shards). Used for horizontal scaling and handling large data volumes.
Comparison table of relational and non-relational DBs (main differences):
| Characteristic | Relational (SQL) | Non-relational (NoSQL) |
|---|---|---|
| Schema | Rigid, predefined | Flexible, dynamic |
| Scaling | Vertical (more difficult horizontal) | Horizontal (easier) |
| Data integrity | ACID (usually) | BASE (more often) |
| Data model | Tables | Key-value, document, graph, etc. |
| Query language | SQL | Various (API, specific) |