Industry Trends in Full Stack

Chapter 5
Data Engineering and Contemporary Persistence

Bachelors Program in Full Stack Development
Industry Trends in Full Stack   •   Bachelor

Data Engineering and Contemporary Persistence

Introduction

Modern full-stack applications are data systems as much as they are user interfaces and APIs. A web application may record customers and orders in a relational database, store flexible product documents, cache sessions in a key-value store, search descriptions through an index, analyse events in a data warehouse, and generate recommendations using vector similarity. Selecting and integrating these technologies is therefore a central professional skill.

Data engineering concerns the reliable collection, transformation, storage, movement, governance and use of data. Contemporary persistence extends beyond choosing a single database: it involves matching data models and operational guarantees to business requirements. The central design question is not “Which database is best?” but “Which data characteristics and access patterns must this component support?”

Learning Objectives

By the end of this chapter, a student should be able to:

  • distinguish relational, document, key-value, graph, time-series and vector databases;
  • select persistence technologies using workload, consistency, scale and governance criteria;
  • design schemas, indexes, transactions, caches and replication strategies;
  • explain operational and analytical data pipelines;
  • apply search and vector retrieval appropriately;
  • manage data through retention, security, quality and deletion policies; and
  • evaluate a polyglot persistence architecture critically.

1. Data as an Engineering Resource

A data system has at least four dimensions:

  1. Structure: Is the data strongly tabular, hierarchical, connected, sequential or high-dimensional?
  2. Access pattern: Is it read by identifier, filtered, joined, traversed, aggregated or searched semantically?
  3. Guarantees: What consistency, durability, availability and latency are required?
  4. Lifecycle: How is data created, classified, retained, shared, transformed, archived and deleted?

A useful distinction is between operational data processing and analytical data processing. Operational systems support transactions such as placing an order. Analytical systems support questions such as identifying monthly customer retention. Operational databases are normally optimized for many small, concurrent reads and writes; analytical platforms are optimized for scans, aggregations and historical analysis.

The familiar ACID properties describe transaction behaviour:

  • Atomicity: a transaction is completed entirely or not applied.
  • Consistency: committed data satisfies defined constraints.
  • Isolation: concurrent transactions do not produce prohibited intermediate effects.
  • Durability: committed changes survive an accepted failure model.

ACID does not mean that a system is always globally consistent, nor does it remove the need for sound schema and failure design. Distributed systems may deliberately choose weaker or delayed consistency to improve availability and geographic performance.

2. Database Families and Their Appropriate Uses

Relational databases

Relational databases represent data in tables containing rows and columns. Primary keys identify rows; foreign keys express relationships; constraints enforce validity. SQL provides declarative querying, joins, grouping and transactions.

They are particularly suitable for orders, payments, inventory, enrolment and other domains where relationships and correctness are central. Normalization reduces update anomalies by separating concepts into related tables. However, excessive normalization can increase join complexity, so carefully justified denormalization may improve read performance.

A relational design might contain Customer(CustomerID, Name, Email) and Order(OrderID, CustomerID, OrderedAt, Status). A foreign key from Order.CustomerID to Customer.CustomerID prevents an order from referring to a nonexistent customer. An index on Order.CustomerID can accelerate customer-order queries, while an index on OrderedAt supports time-based retrieval.

Document databases

Document databases store records as JSON-like documents. Nested objects and arrays can represent an aggregate such as a product with embedded options. They are useful when records have variable attributes, evolve rapidly, or are usually read as complete aggregates.

Embedding avoids joins but duplicates data when the same fact is repeated in many documents. Referencing reduces duplication but requires additional reads or application-level joins. The decision should follow update frequency, document size, ownership and access patterns—not fashion.

Document databases commonly provide atomicity at a document or aggregate boundary, but multi-document transactions and query semantics vary. Developers must consult the specific product’s guarantees rather than assuming that all document stores behave alike.

Key-value databases

A key-value store maps a key to a value and is optimized for direct lookup. Typical uses include sessions, rate-limit counters, feature flags, shopping carts and caching. Values may be strings, serialized objects, sets or sorted collections, depending on the system.

Key design is crucial. A key should be unique, stable, appropriately scoped and compatible with expected access patterns. Expiration times, maximum memory policies and eviction behaviour must be understood. A key-value store is not automatically a durable system of record; persistence and backup settings require explicit configuration.

Graph databases

Graph databases represent vertices and edges, often with properties on both. They are appropriate for highly connected data: social relationships, identity links, dependency analysis, fraud networks and recommendation paths. Graph traversal can be more natural than repeated relational joins when the dominant question is “What is connected to this entity through these relationships?”

A graph model does not eliminate modelling choices. Direction, relationship meaning, traversal depth, cardinality and temporal validity must be defined. Graph databases may be a poor choice for simple tabular reporting or large scans dominated by independent records.

Time-series databases

Time-series databases optimize measurements indexed by time, such as temperature, CPU utilization, financial prices or application latency. Important design decisions include timestamp precision, ordering, late-arriving events, retention, downsampling and tag cardinality.

High-cardinality labels can consume substantial index and memory resources. A common lifecycle is to retain recent high-resolution data and store older data at a lower resolution. Aggregation must preserve the meaning of the measurement: averaging a gauge may be appropriate, whereas summing a cumulative counter requires careful treatment of resets and intervals.

Vector databases

Vector databases store numerical embeddings and support nearest-neighbour search. An embedding is a vector representation generated by a model; semantically similar items are expected to occupy nearby regions of the vector space. Applications include semantic search, recommendation, duplicate detection and retrieval-augmented generation.

Similarity functions must match the embedding model. Common measures include cosine similarity and Euclidean distance. For vectors x and y, cosine similarity is:

cos(θ) = (x · y) / (||x|| ||y||)

Here, x · y is the dot product, and ||x|| and ||y|| are Euclidean norms. The formula assumes non-zero vectors. If vectors are normalized to unit length, cosine similarity equals their dot product. Approximate nearest-neighbour indexes improve speed at the cost of possible recall loss. Vector retrieval should normally be combined with metadata filtering, access control and, where necessary, keyword search or reranking.

3. Data Modelling and Persistence Selection

A disciplined modelling process begins with business entities, events and invariants. An invariant is a condition that must remain true, such as “an invoice total equals the sum of its valid line items.” Identify ownership: which component is authoritative for each fact? Then list read and write patterns, expected volume, latency objectives, retention and failure consequences.

The following comparison is a starting point rather than a substitute for workload analysis.

Database familyStrengthTypical accessPrincipal risk
RelationalConstraints, joins, transactionsSQL queries and aggregatesScaling joins or writes may require careful design
DocumentFlexible aggregatesRetrieve or update a documentDuplication and inconsistent embedded data
Key-valueVery fast direct accessGet/set by keyWeak queryability and accidental cache dependence
GraphRelationship traversalPaths, neighbours, communitiesPoor fit for simple bulk tabulation
Time-seriesTime-window analysisRanges, rollups, ratesCardinality and retention problems
VectorSemantic similarityNearest-neighbour retrievalModel drift, false similarity and access-control risks

Polyglot persistence uses multiple data stores in one system. It can be effective when each store has a clear responsibility, but it increases operational cost, observability requirements, failure modes and data synchronization challenges. A team should avoid introducing a specialized database when a well-managed relational system satisfies the requirements.

4. Transactions, Concurrency and Consistency

A transaction groups changes that must be treated as one logical operation. Consider transferring 100 currency units from account A to account B. The debit and credit must either both occur or neither occur. A database transaction can enforce this atomicity while constraints prevent invalid balances where appropriate.

Isolation levels regulate what concurrent transactions may observe. Stronger isolation can reduce anomalies but may increase locking, waiting or aborts. Common anomalies include dirty reads, non-repeatable reads and phantom reads. Optimistic concurrency control instead detects conflicts, often through a version column:

UPDATE Account
SET balance = balance - 100, version = version + 1
WHERE account_id = A AND version = expected_version;

The application must verify that exactly one row was updated and retry or report a conflict otherwise. This pattern is useful when conflicts are uncommon, but retries must be bounded and operations must be designed to avoid harmful duplication.

Distributed transactions across independent databases are difficult. Alternatives include an outbox pattern, in which a business transaction writes both its primary change and an event record in one local transaction. A separate relay publishes the event reliably. Consumers should be idempotent: processing the same event twice should not produce an incorrect result. Idempotency keys are especially important for payments and externally retried requests.

5. Indexing, Caching, Replication and Search

An index is an auxiliary structure that accelerates selected queries but consumes storage and makes writes more expensive. Index design should follow real query predicates, sort orders and selectivity. Composite index column order matters; an index on (tenant_id, created_at) is often suitable for queries restricted to a tenant and ordered by creation time, but may not efficiently support queries using only an unrelated column.

Caching reduces repeated computation or database access. Common strategies include:

  • Cache-aside: the application reads the cache, loads the database on a miss and then populates the cache.
  • Write-through: writes update the cache and underlying store through a coordinated mechanism.
  • Write-behind: cache writes are propagated later, improving latency but risking data loss.

Every cache needs a freshness policy. Time-to-live expiration is simple but can serve stale data; explicit invalidation is more precise but difficult. Cache stampedes occur when many requests refill an expired item simultaneously. Jittered expiration, request coalescing and stale-while-revalidate strategies can reduce this problem. Sensitive information should not be cached without appropriate encryption, isolation and deletion controls.

Replication copies data across nodes or regions. Synchronous replication can provide stronger acknowledgement guarantees but adds latency and may reduce availability during network partition. Asynchronous replication improves performance and geographic reach but creates replication lag and possible data loss after a failure. A system should define its recovery point objective (maximum tolerable data loss) and recovery time objective (maximum tolerable restoration time), then test whether architecture and backups meet them.

Search engines usually build inverted indexes for terms and may support ranking, filtering, highlighting and faceting. Search indexes are often derived from a source-of-truth database. The system must handle indexing delay, failed events, reindexing and deletion propagation. Search relevance should be measured with representative queries rather than assumed from technical performance alone.

6. Data Engineering Pipelines

A pipeline moves data from producers to consumers through stages such as ingestion, validation, transformation, storage and serving. ETL transforms data before loading it into a destination; ELT loads data first and transforms it within the analytical platform. Streaming pipelines process events continuously, while batch pipelines process bounded collections on a schedule.

A robust pipeline addresses:

  • schema evolution and compatibility;
  • event ordering and duplicate delivery;
  • late and missing data;
  • validation and quarantine of invalid records;
  • lineage, observability and replay;
  • privacy classification and access control; and
  • reconciliation against authoritative totals.

A data warehouse generally uses structured, curated data for reporting. A data lake stores large volumes of raw or semi-structured data, while a lakehouse attempts to combine flexible storage with transactional tables and analytical management. These labels describe architectural patterns, not guaranteed product capabilities.

Pipeline quality can be assessed through completeness, validity, timeliness, uniqueness and consistency. For example, if 9,850 of 10,000 expected daily events arrive, completeness is 98.5%, assuming the expected count is reliable. Metrics should be accompanied by definitions, ownership and alert thresholds.

7. Responsible Data Lifecycle Management

Responsible persistence begins before data collection. Organizations should collect a justified minimum, document purpose, classify sensitivity and define lawful access. Personally identifiable information, credentials, financial data and health data require stronger controls than public catalogue information.

Essential practices include encryption in transit and at rest, centralized secrets management, least-privilege authorization, tenant isolation, audit logging, secure backups and tested restoration. Logs can themselves contain personal data, so observability systems require retention and redaction policies.

Retention should be based on business, legal and operational needs. A defensible lifecycle may be: collect → validate → use → archive or aggregate → delete securely. Deletion must include primary stores, replicas, caches, search indexes, vector indexes, exports and backups according to applicable policy and law. Legal holds may temporarily suspend deletion.

Data governance also covers provenance, quality, consent, access requests, correction, portability and responsible secondary use. Machine-learning embeddings are not automatically anonymous: they may encode sensitive information and must inherit appropriate access controls. Generated summaries and recommendations require monitoring for bias, leakage, hallucination and inappropriate disclosure.

8. Illustrative Case: A Multi-Channel Retail Platform

Background

Consider “Northstar Retail,” an illustrative online and physical retailer. It sells products through a web application, records stock movements in stores, provides product search and recommends related items.

Problem

The original system uses one relational database for all workloads. Checkout is reliable, but product search slows during campaigns, analytics queries interfere with transactions, and recommendation experiments require exporting sensitive customer records.

Analysis

The authoritative facts are orders, payments, inventory movements and customer permissions. These require constraints and transaction boundaries. Product descriptions contain flexible attributes and require full-text and semantic retrieval. Recent operational metrics require time-window queries. Sessions and short-lived carts require fast keyed access. Reporting should not compete with checkout.

Approach

Northstar retains a relational database as the system of record for orders, payments, inventory and customer permissions. A document-oriented read model stores product presentation data. A search index supports keyword retrieval, while a vector index stores product embeddings with product identifiers and permitted metadata filters. A key-value store holds sessions with short expiration times. Operational events are written through an outbox and delivered to an analytical platform. A time-series store receives service latency and stock telemetry.

The checkout transaction reserves inventory and records the order atomically in the relational store. An outbox event then updates search, analytics and recommendation projections. Consumers record event identifiers to achieve idempotent processing. If a projection fails, it is retried or rebuilt from the event history. Personal data is minimized in events; recommendation features use pseudonymous identifiers and documented retention limits.

Outcome

The architecture separates transactional correctness from read-heavy and analytical workloads. It does not eliminate complexity: operators must monitor lag, reconcile projections, secure multiple systems and test deletion propagation. The design is successful only because each additional store has a defined purpose and an owner.

Learning Points

First, the system of record should be selected according to invariants, not convenience. Second, derived stores must be rebuildable or reconcilable. Third, eventual consistency must be visible to users where it affects expectations. Finally, privacy and deletion requirements must be designed across the entire data graph, not added after deployment.

9. Contemporary Developments and Professional Practice

Current practice increasingly combines event-driven architecture, managed cloud databases, serverless data processing, lakehouse tables, real-time analytics and retrieval-augmented AI applications. These developments improve elasticity and developer productivity but can hide cost, vendor dependence and operational boundaries.

AI-assisted development can generate schemas, queries and migration scripts, but generated code must be reviewed for injection risks, missing authorization predicates, inefficient queries and destructive migrations. AI retrieval systems should use authoritative sources, filter results by user permissions and expose provenance where decisions matter.

A professional engineer should maintain migration scripts under version control, test rollback or forward-fix procedures, measure query plans, perform failure-injection exercises and document service-level objectives. Architecture decisions should be recorded with alternatives and assumptions. Observability should cover latency, errors, throughput, saturation, replication lag, cache hit rate, pipeline freshness and data-quality failures.

Challenges and Limitations

No database family solves every problem. Distributed systems face network delay, partial failure and inconsistent observations. Replication can create conflicts. Caches create freshness questions. Search and vector indexes can diverge from source data. Analytical pipelines can produce confident but incorrect results when definitions or lineage are weak. Polyglot architectures increase staffing and security demands. Finally, legal requirements differ by jurisdiction and sector, so technical controls must be reviewed with organizational policy and qualified legal or compliance personnel.

Chapter Summary

Contemporary full-stack persistence is a problem of matching data models, access patterns and guarantees to business needs. Relational databases provide strong constraints and transactions; document stores represent flexible aggregates; key-value systems support fast direct access; graph systems model relationships; time-series systems optimize temporal measurements; and vector databases enable semantic retrieval. Effective architectures may combine these technologies, but each derived store requires ownership, synchronization, observability and recovery planning.

Transactions, indexing, caching, replication and search determine operational behaviour. Event-driven pipelines connect operational systems with analytical and read-optimized stores, while validation, lineage and replay protect data quality. Responsible data engineering includes minimization, security, retention, deletion, access control and governance across replicas, caches, indexes, backups and embeddings. Sound professional practice treats database selection as an evidence-based engineering decision rather than a technology trend.

Key Terms

ACID: Transaction properties of atomicity, consistency, isolation and durability.

Aggregate: A related group of data treated as one unit for access or transaction purposes.

Cache-aside: A caching pattern in which the application loads missing data and populates the cache.

Consistency: The degree to which reads reflect accepted writes and defined constraints.

Data lineage: A record of where data originated and how it was transformed.

Document database: A database storing semi-structured, document-like records.

Eventual consistency: A model in which replicas may temporarily differ but converge after updates propagate.

Graph database: A database optimized for vertices, edges and relationship traversal.

Idempotency: The property that repeating an operation produces the same correct effect as performing it once.

Index: An auxiliary structure that accelerates selected data access operations.

Key-value database: A store optimized for retrieving values by keys.

Lakehouse: An architecture combining flexible data-lake storage with managed analytical table capabilities.

Outbox pattern: A technique that records a business change and its event in one local transaction.

Polyglot persistence: Use of multiple database technologies within one application or organization.

Replication: Copying data among nodes, regions or systems.

Retention: The policy determining how long data is kept.

Time-series database: A database optimized for timestamped measurements.

Vector database: A database supporting storage and similarity search over numerical embeddings.

System of record: The authoritative source for a particular business fact.

Review Questions

Short Answer Questions

  1. What distinguishes operational processing from analytical processing?
  2. State the four ACID properties.
  3. Give two suitable uses for a key-value database.
  4. Why can embedding data in a document create update problems?
  5. What is the purpose of an outbox pattern?

Long Answer Questions

  1. Compare relational, document and graph databases for a customer relationship application.
  2. Explain how cache freshness, expiration and cache stampedes affect system design.
  3. Discuss synchronous and asynchronous replication, including their trade-offs.
  4. Describe the stages and quality controls of a reliable analytical data pipeline.
  5. Explain why responsible deletion must include indexes, caches, replicas and backups.

Analytical / Application Questions

  1. Design a persistence architecture for a food-delivery platform. Justify the database family selected for orders, driver locations, sessions, search and analytics.
  2. A company’s search index is updated from database events but sometimes misses events. Propose an observability, retry, reconciliation and rebuild strategy.
  3. A recommendation system uses customer embeddings but must comply with strict privacy requirements. Analyse the risks and specify controls for collection, access, retention, deletion and model use.

Multiple Choice Questions with Answers

Question 1

Which database family is generally most appropriate when complex joins and strong integrity constraints are central?

A. Relational

B. Key-value

C. Vector

D. Time-series

Correct Answer: A. Relational

Question 2

What does atomicity require in a transaction?

A. All operations are completed, or none are applied

B. Every replica responds instantly

C. Queries always use an index

D. Data is permanently retained

Correct Answer: A. All operations are completed, or none are applied

Question 3

Which pattern records a business change and its event in one local transaction?

A. Cache-aside

B. Outbox

C. Sharding

D. Read-through

Correct Answer: B. Outbox

Question 4

What is a principal risk of embedding frequently changing shared data in many documents?

A. Loss of all primary keys

B. Update duplication and inconsistency

C. Automatic synchronous replication

D. Inability to store text

Correct Answer: B. Update duplication and inconsistency

Question 5

For non-zero vectors x and y, cosine similarity is calculated using which expression?

A. (x · y) ÷ (||x|| ||y||)

B. ||x|| + ||y||

C. x − y only

D. (x · y) × ||x|| × ||y||

Correct Answer: A. (x · y) ÷ (||x|| ||y||)

Question 6

Which database is specifically optimized for timestamped measurements and time-window queries?

A. Graph database

B. Document database

C. Time-series database

D. Key-value database

Correct Answer: C. Time-series database

Question 7

What is a common disadvantage of asynchronous replication?

A. It cannot copy any data

B. It may expose replication lag and recent data loss after failure

C. It always prevents geographic deployment

D. It eliminates backup requirements

Correct Answer: B. It may expose replication lag and recent data loss after failure

Question 8

Which property means that processing the same event twice does not create an incorrect additional effect?

A. Normalization

B. Idempotency

C. Cardinality

D. Durability

Correct Answer: B. Idempotency

Question 9

Which practice best reduces cache stampedes?

A. Making every item permanent

B. Using request coalescing or jittered expiration

C. Removing all cache keys after every read

D. Disabling database access

Correct Answer: B. Using request coalescing or jittered expiration

Question 10

Why should vector retrieval commonly include metadata access-control filtering?

A. Vectors cannot be stored without SQL

B. Semantic similarity alone does not prove that a user may access a result

C. Filtering makes all vectors identical

D. Access control applies only to relational tables

Correct Answer: B. Semantic similarity alone does not prove that a user may access a result

Industry Trends in Full Stack
Chapter 5 of 14