Concept Flow - Elasticsearch vs relational databases
Data Input
Schema defined
SQL Queries
Joins, ACID
Choose based on needs
Shows how data flows differently in relational databases and Elasticsearch, highlighting schema, query style, and features.
SELECT * FROM users WHERE age > 30; GET /users/_search { "query": { "range": {"age": {"gt": 30}} } }
| Step | System | Input Query | Processing | Output Result |
|---|---|---|---|---|
| 1 | Relational DB | SELECT * FROM users WHERE age > 30; | Parse SQL, check schema, scan 'users' table, filter rows with age > 30 | Rows with age > 30 |
| 2 | Elasticsearch | GET /users/_search {"query": {"range": {"age": {"gt": 30}}}} | Parse JSON query, search index 'users', filter documents with age > 30 | Documents with age > 30 |
| 3 | Relational DB | Joins possible | Combine data from multiple tables | Joined rows |
| 4 | Elasticsearch | No joins | Denormalized data, no join support | Single documents only |
| 5 | Relational DB | ACID transactions | Ensure atomicity, consistency, isolation, durability | Reliable transactions |
| 6 | Elasticsearch | Eventual consistency | Distributed system, data may be temporarily inconsistent | Fast but eventual consistency |
| 7 | Relational DB | Schema fixed | Tables and columns predefined | Structured data |
| 8 | Elasticsearch | Schema flexible | Documents can have varying fields | Flexible data |
| 9 | Exit | N/A | Query processing ends | Results returned to user |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | Final |
|---|---|---|---|---|---|---|
| Query | N/A | SELECT * FROM users WHERE age > 30; | GET /users/_search {"query": {"range": {"age": {"gt": 30}}}} | Joins possible | No joins | Query processed |
| Data | Raw tables/documents | Filtered rows with age > 30 | Filtered documents with age > 30 | Joined rows | Single documents | Results ready |
| Consistency | N/A | ACID guaranteed | Eventual consistency | ACID guaranteed | Eventual consistency | Consistency state noted |
Elasticsearch vs Relational DBs: - Relational DBs use fixed schema tables and SQL queries. - Elasticsearch stores flexible JSON documents and uses JSON queries. - Relational DBs support joins and ACID transactions. - Elasticsearch offers full-text search, scalability, and eventual consistency. - Choose based on data structure and query needs.