Query Paradigms, Storage Architectures, and Data Pipelines
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- What data management is and why it matters — covered in Lecture 1
- The data–information–knowledge–wisdom hierarchy — covered in Lecture 1
- Data quality: what makes data good and how to fix it — covered in Lecture 1
- Data formats: structured, unstructured, and semi-structured — covered in Lecture 1
- Data models: relational, hierarchical, graph, document, and key-value — covered in Lecture 1
2.1 Data Management: What It Is and Why It Matters
2.1.1 What Data Management Is
The session opens with a short children's story read aloud — a tale about sharing. A little girl named Candace wants everything her brother has: his big bite becomes her bite, his storybooks become her books, and his birthday cake becomes their cake. The lesson of the story: nothing works in isolation.
Hook — why does a machine learning course open with a sharing story? Because a model is only as good as the whole chain around it. If you present very nicely in a meeting but your team does not perform well, you will not do well. The same holds for data: you can cover one part of your data nicely and still miss the dependent data. Everything is interconnected, and everything is important.
That idea maps directly onto data management. You can build a good data model and still fail because the machine learning code is poor. You can clean one table and still break the pipeline two steps later. If quality suffers anywhere, it drags down the machine learning program, the deep learning program, or any model you are trying to build. This is the garbage in, garbage out principle from the first session, restated: a model performs better when the data is good quality, the data model is good, the representation is good, and the format and pipeline are good.
Formalize — the definition. Data management is the practice of collecting, processing, storing, and securing data. The full chain works like this:
- Collect the data nicely — data acquisition, data processing, data pre-processing, data manipulation — whatever you do with the data.
- Build a clear pipeline — the connecting stages that move and shape the data from source to use.
- Store the data somewhere — in a database management system, or as a JSON file, an Excel file, a CSV, and so on.
- Secure the data — protect it from misuse, loss, and unauthorized access.
The point of building the pipeline properly is that the data can be used effectively for better decision making. This pipeline is the foundation for building any machine learning model and any futuristic model: if the data does not fit, if the data is scattered, dispersed, or not managed properly, every machine learning system will suffer in performance.
There is strong connectivity among data representation, data processing, and data pre-processing: the quality, structure, and reliability of the data directly shape the performance and accuracy of a machine learning model, whether it is a decision tree model, a Bayesian classifier, or anything else. A few ideas get repeated on purpose. Repeating key points is called repeated assertion, and it builds a strong foundation.
Assumption & Scope — when does the garbage-in logic bite hardest? The principle assumes that data quality, the data model, the representation, the format, and the pipeline all work together as one chain. The assumption fails quietly: you can fix one link — say, the storage — while the dependent data elsewhere is still broken, and the model still fails. Scope: this definition covers the whole lifecycle of data, not a single table or file; a fix that only covers part of the data misses the point.
Recap + Bridge. Data management = collecting, processing, storing, and securing data as one connected chain, because a model is only as strong as its weakest link. Next: why machine learning in particular leans so heavily on these systems.
2.1.2 Why Machine Learning Needs Data Management
The prerequisites and interrelated subjects for this course — a question someone asked in the previous session — are: basic databases, some data structures, and the query language SQL. Even a management person must know how to manage data and understand data formats (structured data, graph data, unstructured data, semi-structured data) and different data models. Data engineering, big data technology, and cloud computing systems are all connected to this subject.
Machine learning models depend completely on the data systems behind them — a database system, an ERP system, a legacy system — whatever storage you have. Poor data management leads to missing critical values, outdated data, and incorrect predictions; the ML model will not predict properly. Proper data management helps handle big data and different types of data, avoids data silos, and improves business outcomes.
Intuition — the model is the passenger, the data system is the road. A car (the model) cannot reach its destination on a broken road (the data pipeline). ML models do not generate their own inputs; they consume whatever the storage and the pipeline deliver. If the road has potholes — missing values, stale rows, wrong units — the car cannot steer around them, no matter how good the engine is.
Worked example — the fever detection model. Here is a concrete case: building a machine learning model that detects fever in a particular area or in one classroom.
- Start with raw data — temperature readings, patient details, dates, times, locations.
- Perform proper data management — clean the readings, fix wrong entries, fill gaps.
- Build a time-series model with a good data pipeline — the data flows in the order of date and time.
- Represent the data correctly — based on date, time, patient, and location, so each record says who was measured, where, and when.
- Train and predict — with that good representation and pipeline, the model learns the pattern and predicts well.
Now flip it: if the data is not clean — missing values, wrong readings, improper or incomplete data — the model may give a wrong prediction. With good data management, processing, pre-processing, and pipeline, the ML system becomes very accurate and reliable.
Sense-check: the same algorithm with the same settings gives two different outcomes; the only difference is the data quality. That is exactly why this subject exists.
Pitfalls.
- Blame the algorithm first. When predictions go wrong, beginners check the model; in industry the cause is usually upstream in the data.
- Clean one table and stop. The dependent data — the joins, the derived columns — is where problems hide.
- Store everything, document nothing. Missing values and outdated values pile up silently and disturb every later query.
Recap + Bridge. ML depends fully on the underlying data systems; the fever example shows good data management turning raw readings into reliable predictions. Next: what happens to data as it climbs from raw values to wisdom.
2.1.3 From Raw Data to Wisdom
Data becomes more corrected, more consistent, and more refined as it reaches a certain level of wisdom: raw data → context information → derived knowledge → extreme knowledge with multiple levels. This is the data, information, knowledge, wisdom ladder seen in the previous session. Each rung adds meaning: raw numbers become information when they gain context, information becomes knowledge when patterns are derived from it, and knowledge becomes wisdom when it supports decisions at many levels.
The common abbreviations and terms to know:
| Abbreviation | Full form |
|---|---|
| DB | database |
| DBMS | database management system |
| OLTP | online transaction processing |
| OLAP | online analytical processing |
| JSON | JavaScript Object Notation |
| CSV | comma separated values |
| SQL | Structured Query Language |
Data is everywhere: internal data, confidential data, external data, lots of nulls, failing source connections, broken pipes, different charts, different data models, different storage systems, different data architectures. Data management as a practice covers ingesting, processing, securing, and storing organizational data. There is also a split into primary data — the data that is really critical to the business — and secondary data — supporting data used for strategic decision making and improvement.
Intuition — data is not a tidy library, it is a busy market. Before it becomes wisdom, raw data arrives from many stalls: some vendors are missing (nulls), some connections fail (broken pipes), some sell in different currencies (different models and storage systems). Data management is the practice of turning that market into a usable pantry — ingesting, processing, securing, and storing organizational data. Primary data is the stock you cannot run the business without; secondary data is the supporting stock for strategy and improvement.
Why do we need data management at all? Because data is growing: the cloud has come, and so have IoT, sensors, web ops, edge computing — even a fridge generates data; everything generates data. Big data is growing exponentially, and data systems are all growing too, so you need to know how to manage data effectively. Priorities change: if data is not generated or handled properly, there is a problem. Data is used to construct models, and you need a pipeline that transforms data into a model — which is where the processes ETL and ELT come in. ML system success is hard to measure and the direction of failures is difficult to identify; it depends fully on the underlying data management systems in terms of structure. Data management teaches you to understand the structure, what data will give better performance, and it helps improve the accuracy and reliability of predictions.
Recap + Bridge. Data climbs a ladder — raw data, context, knowledge, wisdom — while the cloud, IoT, and sensors keep growing the pile, so management matters more every year. Next: a hands-on data quality check on a real sample table.
2.1.4 Industry Applications
Real-world: the fever detection model (time-series prediction over patient, date, time, and location data) is a daily-life use case of a data pipeline. Real-world: ERP systems, legacy systems, and cloud storage are the actual data systems ML models depend on in companies. Real-world: the exponential growth of big data from cloud, IoT, sensors, web ops, and edge computing — including a fridge generating data — is why organizations now invest in data management.
Where this fits in the field: data management is the foundation discipline under data engineering and machine learning operations. Every data scientist's notebook, every model registry, and every production recommendation system sits on top of the collect-process-store-secure chain described here. If that chain is weak, no amount of clever modeling recovers the lost accuracy.
2.2 Data Quality Check in Practice
2.2.1 The Data Quality Check Exercise
Before moving on, there is a quick data quality check for everyone. This is a preliminary or quick quality check, not a 100% full data quality check. Imagine you have been given a dataset that may arrive as a table, a CSV file, a JSON file, or any other file form, and it has come from multiple sources — source one might be a mobile device, source two an ERP system, source three a sensor. You are going to apply some data mining algorithm, a machine learning algorithm, or some modeling on it.
Hook — can you find five problems in one small table? Before any algorithm runs, the data itself must be questioned. The task: identify at least five data quality issues in the sample table, and explain how you would resolve these quality issues. Coding is not necessary — but you should know what sort of issues exist and, given the chance, how you would resolve them. One more rule from the professor: do not jump to conclusions quickly; do your own inference and your own quality check, without looking at what other people answered. The point is to train the eye, not to copy answers.
2.2.2 The Sample Table and Its Issues
A sample table was shown to the class, and the findings reported were:
| Row | Field | Issue |
|---|---|---|
| 3 | blood group | not the correct blood group |
| 5 | COVID result | coded as 1 and 0 instead of positive / negative |
| 7 | age | 150 years — an impossible value |
| 8 | weight | in pounds (LBS) while the other rows use kilograms |
| 9 | height | no height available at all (null / missing) |
| 9 | COVID result | coded as 0 instead of positive / negative |
| 10 | name | "system user 789" — not a proper name |
Notice what this table teaches: a dataset assembled from multiple sources rarely arrives clean. Each row above is a different family of problem — an encoding mismatch, a missing field, an impossible number, a mixed unit, an invalid name. The skill being trained here is spotting each family and knowing which tool fixes it.
2.2.3 How to Resolve the Issues
Taken together, these rows are the classic issues of a dataset assembled from multiple sources: inconsistent encoding, missing values, outliers, mismatched units, and inconsistent identity data. What skills must you have for this? At least some domain knowledge about the data — you should think like a doctor or a scientist and look at the data from the quality aspect — plus knowledge of different data representations and data scaling.
Worked example — fixing every row of the sample table.
Take the missing height of a 25-year-old person — the value was simply not filled in by mistake. It is a null value, a missing value. One approach is to set an acceptable range: the height must follow a criteria — for example, between a minimum of 145 and a maximum of 180 — then verify against it and, if needed, correct or even remove the record. Some people simply ignore the erroneous data, which is also acceptable — nothing wrong with it.
Another option: look at the range, then fill the missing value with the minimum value, the maximum value, or the mean value. Filling in missing, inaccurate, or incomplete data using various methods is called data imputation: you can use a constant (if the country is not filled, simply use India), or the low value, the upper value, the median value, or a boundary value. There are many techniques available.
For the age of 150: no person in India lives 150 years, so the value stands out as an outlier — an anomaly — and you handle it with an outlier method, for example by checking the range.
For the weight column: some values are in pounds (LB) and some in kilograms — this is a mismatched data type problem, and you fix it by normalizing the data, standardizing the data, converting the data, and putting it on the right scale. This is the duty of a data engineer or data management person.
For the name "system user 789": the record is not consistent with the other rows, a data consistency problem, solved by replacing the field with the right name.
For the COVID result coded as 1/0 instead of positive/negative: it is a mismatch in representation — the data can be replaced with the correct values or handled with an imputation-style technique.
Sense-check: after these fixes, every row of the table uses the same encoding, the same units, real values inside plausible ranges, and a real identity — the dataset is now safe to feed into a model.
Assumptions & Scope — where each fix has limits.
- The acceptable range is a domain decision. A 145–180 cm window fits this dataset's population; the same range is wrong for children or for other regions. The range is an assumption about the world, not a law of math.
- Imputation changes the statistics. Filling missing values with the mean pulls the column toward the mean, lowering the variance; filling with a constant or boundary value does something different. Choose the method by what the model needs.
- Deletion loses rows. Removing a bad record is acceptable, but if many rows are bad, you are quietly shrinking the training set — and for ML that has its own cost.
- Normalizing assumes a conversion exists. Pounds to kilograms is a fixed formula; not every unit mismatch has one.
Exam note: the binding technique (filling with boundary values) and the imputation methods (constant, min/max, mean, median) are referenced here and will be covered properly in a later session — pay attention to them, and be ready to say how you would resolve each of these issue types on an exam.
2.2.4 Student Questions and Answers
Q: A student reports the first round of findings: row 3 has a blood group that is not the correct blood group, rows 5 and 9 show the COVID result coded as 1 and 0 instead of positive and negative, row 9 has no height value, row 7 shows an age of 150, row 8 gives weight in pounds instead of kilograms, and row 10 has the name "system user 789".
A: Excellent inference. For the missing height, set an acceptable range — the height should follow the criteria between a minimum of 145 and a maximum of 180 — then verify and, if needed, correct or remove the record; some people simply ignore the erroneous data, which is okay. You can also fill the missing value with the minimum, the maximum, or the mean value — that is imputation, and you can use a constant, a median, or a boundary value. The age of 150 is an outlier, an anomaly — no person lives 150 years — so handle it with an outlier method. The pounds versus kilograms mismatch is a data type mismatch, fixed by normalizing, standardizing, and converting the data to the right scale — the duty of a data engineer. The name field is a data consistency problem, solved by replacing the field with the right name. The 1/0 versus positive/negative mismatch is a representation issue.
2.3 Data Formats and the Relational Model
2.3.1 Data Formats
Data comes in many formats, and the format determines how a pipeline must treat it. Structured data is the regular, tabular data — rows and columns like a spreadsheet. Unstructured data is things like text, audio, video, and images. Semi-structured data sits in between — email data, HTML data, XML data.
| Format | Shape | Examples |
|---|---|---|
| Structured | fixed rows and columns | spreadsheets, SQL tables, CSV files |
| Semi-structured | organized but flexible, self-describing | emails, HTML pages, XML and JSON documents |
| Unstructured | no fixed shape at all | text documents, audio, video, images |
Intuition — recognizing the format is half the job. A structured file can be loaded straight into a table; an image cannot, until it is turned into pixels and then numbers. The professor's point: each format needs different treatment in the pipeline — different parsers, different storage, different cleaning steps. If you misread the format, every downstream step inherits the mistake. Think of formats like luggage: a suitcase with a fixed frame (structured) packs into a cargo hold in one way; a loose duffel bag (semi-structured) keeps some order but shifts; a rolled-up hammock (unstructured) can be packed a hundred different ways, and the packer must choose.
2.3.2 The Relational Model and Normalization
The relational data model is the classic one — proposed by Edgar Codd in 1970, it organizes data into relations (called tables in SQL). In the relational model, everything is a tuple — and tuples are also called rows. A table is the visual representation of a relation, with rows and columns, and the data in it is unordered: the model makes no promise about which row comes first, so the database is free to store rows in any order that is efficient.
To keep such data healthy we use the normalization process: normalization removes anomalies and removes redundancies — we do not want redundancies, because they create data integrity problems. If the same customer address is stored in ten rows and one of them is corrected, which one is true? Redundancy is where contradictory data is born.
Formalize — the normal forms. The reference document shared in class walks through applying the first normal form (1NF), the second normal form (2NF), and the third normal form (3NF), plus BCNF. The professor's spoken "BNFCF" is the standard term BCNF — Boyce-Codd Normal Form, a stricter refinement of third normal form.
- 1NF — every cell holds a single value. No repeating groups, no lists hiding inside a column. If a phone column holds "home: 44... / work: 91...", split it.
- 2NF — 1NF plus: every non-key column depends on the whole candidate key. If the key is (order_id, product_id) but the customer name depends only on order_id, the name must move to the order table.
- 3NF — 2NF plus: no transitive dependencies. A non-key column must not depend on another non-key column — city depends on zip code, so keep zip and city in their own lookup table.
- BCNF — every determinant is a candidate key. In everyday terms, every column that determines another column must itself be a key; BCNF closes the rare gaps 3NF leaves open.
The result of each step: the same fact is stored in exactly one place, so an update changes one row instead of hundreds.
Assumptions & Scope — when normalization is not the answer.
- Normalization assumes the workload is transactional: many small updates to the same facts. It fights redundancy at the cost of joins — reading the same fact now requires combining several tables.
- Analytics workloads often denormalize on purpose: a wide table with repeated values scans faster than joining five tables per query. The professor's rule of thumb stands for transaction systems: no redundancies, because redundancies create data integrity problems — but recognize that data warehouses deliberately trade this away for speed.
Exam note: the normalization document (first, second, third normal form and BCNF) is shared material — be ready to apply the normal forms, not just name them. Expect a question that hands you a table and asks which normal form it violates and how to fix it.
2.3.3 Industry Applications
Real-world: Oracle, Informix, and Sybase are the relational DBMSs you will meet in companies — the instructor has worked with about 20 different databases in industry — and relational databases are still the default for most transactional business systems. Database systems are named based on the data model they follow, which is why the next topic matters: once you can name the model, you can guess the system's behavior, its strengths, and its limits.
2.4 Data Models: Hierarchical, Graph, Document, and Key-Value
2.4.1 Data Models as Skeleton Boxes
Hook — why do database systems come in so many shapes? Think of data models as boxes. If there are different boxes, a company that follows one model makes all its boxes square; another company makes all its boxes circular or elliptical. The box shape is decided before any item is packed, and it decides what can fit inside. The model is the skeleton representation of how data can be organized — it is the shape that all the data must fit.
The main families: the relational data model, the hierarchical model, the graph model, the document model, and the key-value model. Based on these models, database systems are called by the model they follow — a relational system, a graph system, a document system, and so on. Choosing the model is choosing the box shape, and that choice decides what questions the data can answer easily.
2.4.2 Hierarchical Model
The hierarchical model works with parent, child, sub-child relationships: everything starts with a parent — a root — and then goes to sub-levels, sub-sub-levels, like hierarchical directory structures on a computer. A directory contains folders, folders contain sub-folders, and sub-folders contain files; each node has exactly one parent, and the whole tree hangs from one root. This structure can be represented in XML — nested tags are a natural fit — and some organizations still use a hierarchical model. For fast lookup in such structures you need proper indexing structures: cluster indexes and non-cluster indexes.
Worked example — the organization chart. The professor's chain: a CEO at the top, below that a delivery director, and the director has a project manager, and so on.
CEO
└── Delivery Director
└── Project Manager
└── Team Lead
└── Engineer
Each arrow says "reports to" — every person has exactly one parent, and the whole chart hangs from the CEO as the root. A query that starts at the CEO walks the tree downward level by level; a query that needs "all managers under the director" is a simple subtree walk. The trade-off: anything that is not a strict tree — say, an engineer who reports to two managers — does not fit this model without duplicating the node.
Sense-check: the tree shape matches a directory structure, which is why this model is easy to picture and why XML represents it naturally.
2.4.3 Graph Model
The graph data model is what the world is highly using now — most people are moving into it. A graph consists of nodes and edges, where an edge represents a relationship between nodes: a customer purchases a product; a customer places an order. Instead of using an entity-relationship diagram, you can do a graph. Databases that store data using a graph structure are graph databases, and in a graph database the relationship is the priority — you can have multiple relationships, and each edge can carry its own label ("friend of", "worked at", "purchased").
Intuition — in a graph, the relationships are the data. A relational table answers "what things exist"; a graph answers "how things are connected". Where the hierarchical model forces a strict tree — one parent per node — the graph model allows any node to connect to any other, and a node can have many parents. That is why "friend-of-friend" queries, which mean joining a table to itself four times in SQL, become a short walk in a graph.
Real-world: Neo4j, Neptune, and Gephi are graph databases; LinkedIn uses them for the proper connectivity of people, tagging people, and friend-of-friend recommendations; Facebook uses graph structure for social connections — a single graph holding people, places, events, and comments all connected by labeled edges.
Assumptions & Scope — when the graph is the wrong box. The graph model shines when relationships are many-to-many, deep, and queried by traversal. It is the wrong tool when your data is a simple list or a strict tree, and when queries are mostly aggregations over one table — a relational or document model will serve those with far less machinery. The choice of box should follow the questions you ask, not fashion.
2.4.4 Document Model
In the document data model, anything and everything is stored as a document, and documents can be encoded in JSON or XML files. In a traditional database system we call a record a tuple; here we call it a document, and the set of documents is called a collection. The document is self-contained: all the facts about one entity travel together, so fetching one document gets everything in one read.
Worked example — the library of books. Book one — the title of the book, the author, the publisher — all stored as a single document:
{
"title": "Data Management for Machine Learning",
"author": "Data Management Team",
"publisher": "Academic Press"
}
Multiple books make a collection of documents — the collection holds book two, book three, and so on, and nothing forces book two to have the same fields as book one. One book may add a "price" field; the collection still accepts it. Sense-check: no schema is enforced, so the model tolerates variation between records — that is the point of the document model.
Real-world: Amazon DocumentDB, Apache CouchDB, Firebase, and Firestore are document databases. The document model is used for storing unstructured and semi-structured data: emails stored as evidence, logs, transaction logs, purchase logs, and all the event information — this date, this time, this event occurred, this error, this warning, what the source was. Each event is a document, and the collection of events is ready for later inspection.
2.4.5 Key-Value Model
The key-value model stores data as a collection of key-value pairs. Each pair is exactly two parts: a key that names the item and a value that holds the content. Key-value stores are used for caching data and in in-memory databases; JSON objects themselves can be used as key-value pairs.
Worked example — the product catalog. A product ID is the key with value P001; the next key has the value laptop.
| Key | Value |
|---|---|
| product_001 | P001 |
| product_002 | laptop |
| user_session_7 | {"cart": ["P001", "laptop"], "last_seen": "10:42"} |
Lookup is a single hop: give the key, get the value — there is nothing to scan or join. Sense-check: every operation is a key lookup, which is why key-value stores are so fast as caches.
There is a subtle difference between a document database and a key-value store: in a document database, anything can be stored — you do not have to follow a rigid structure — but in a key-value pair, you must follow the key and the value. The document is a rich, self-describing object that can be queried by its inner fields; the key-value pair is a plain lookup where the value is opaque to the store. If you need to search inside the content, you need a document store; if you only need "give me the value for this key, fast", a key-value store is enough.
2.4.6 SQL and NoSQL: Two Families
In general there are two types of data models: the SQL type model and the NoSQL type model — and you must know both. The SQL family covers relational systems (Oracle, MySQL, PostgreSQL) built around tables and joins; the NoSQL family covers the rest — document, key-value, graph, and column-oriented systems — that trade the fixed table for flexibility and scale.
Exam note: both model families are examinable, and a demonstration is planned around the midterm. For practical purposes, one demo will use an open-source SQL database, and another will show MongoDB — how to set up a Mongo cluster and build a simple repository. The Mongo cluster is AI-driven: even if you do not know how to write a MongoDB query, it will make the query for you — you give it a token ("I want this data related to this data"), it pre-processes and converts it into a Mongo or Oracle query, then performs it. That is where the world is going now.
2.4.7 Industry Applications
Real-world: Neo4j, Neptune, and Gephi power graph use cases at LinkedIn and Facebook. Real-world: Amazon DocumentDB, Apache CouchDB, Firebase, and Firestore handle document workloads such as logs, purchase logs, and event streams. Real-world: MongoDB clusters are increasingly AI-driven — the cluster writes the queries for you from a plain description. Across all of them, the pattern is the same: name the box, and you know what the system is good at.
2.5 Declarative and Imperative Query Languages
2.5.1 Two Ways to Ask for Data
Hook — how do you ask a database for data? There are two ways to go and pull data: declarative and imperative (or procedural). The same question can be asked two very different ways, and the choice decides how much work you do and how much the database does.
An imperative approach gives a declaration of every step, in order: open the door, go to the car parking, open the car, check if the bag is not empty, take the bag, finally bring the bag from the car to me if the bag is not empty. That is many expensive steps — and you, not the system, are responsible for each one. The declarative approach is a simple statement of the result you want: get all the animals where the family belongs to sharks — one condition, and you get all the values.
Worked example — the car-parking bag versus the one-line query.
Imperative (step by step):
- Open the door.
- Walk to the car parking.
- Open the car.
- Check if the bag is not empty.
- If the bag is not empty, take the bag.
- Bring the bag back from the car to me.
Every step is a command the caller must issue in the right order, with conditions evaluated by hand. Change the parking spot or reorder the checks and the whole sequence must be rewritten.
Declarative (state the result):
SELECT * FROM animals WHERE family = 'Sharks';
One condition — family equals Sharks — and the database returns every matching value. No loop, no index management, no step ordering; the system decides how to walk the data.
Sense-check: both approaches fetch the same result, but the imperative version carries the how, while the declarative version carries only the what.
You can relate this to prompt engineering: you can write a big story in ChatGPT and generate a one-line prompt that gets you so many things. The one-line prompt declares the outcome you want; the model figures out the steps.
2.5.2 The Declarative Advantage
Formalize — what each style is. An imperative language tells the system to perform certain operations in a certain order: step through the code line by line, evaluate conditions, update variables, decide whether to loop once more. A declarative language (SQL, relational algebra) specifies the pattern of the data you want — what conditions the results must meet, how you want them sorted, grouped, and aggregated — but not how to achieve it.
In the declarative approach you control how you want the data to be managed — it gives you a free form, and that is the power of the query language (SQL). The parts are not mentioned and the details are not mentioned: which step it is going to take and how it is going to do it is none of your business — that is handled by the database system. The imperative style defines everything in detail, step by step, evaluating conditions and doing so many things; the declarative style is just a simple story with the condition. That is all.
Assumptions & Scope — the hidden costs.
- Declarative hides the implementation, so you do not know which indexes, joins, or order of operations the system picked. The answer is always correct, but the cost can surprise you — that is exactly why the next topic (the optimizer) matters.
- Imperative code assumes the data keeps the order it was inserted in. A database may move records around while reclaiming disk space; if your code silently relied on ordering, it breaks. Declarative queries make no ordering promise, so the system is free to optimize.
- Declarative languages parallelize naturally; imperative step sequences are hard to split across machines because the steps must run in order.
Recap + Bridge. Ask for the result you want (declarative) and let the system find the path; spell out every step (imperative) only when you need fine control. That division of labor is what makes query languages so powerful — and it hands the heavy work to the database optimizer, the next topic.
2.6 Query Optimization and Storage Formats
2.6.1 The Database Optimizer
Instead of leaving the computational load to the user, give it to the database — specifically the optimizer. The database uses an optimizer, and the optimizer understands the data and the access paths. Think of how Google Maps works in deciding your traffic plan — sometimes it even changes your direction, because your brain optimizes your next step: when there is a slow-moving car, you automatically reduce your acceleration and your leg goes to the brake. That is optimization.
Intuition — the optimizer is the driver, not the passenger. When you type a query, the optimizer is the driver choosing the route: it knows the data (the traffic), it knows the access paths (the roads, the indexes), and it decides what to do — which path to take, which order to join, which index to use. That is why queries are very, very powerful: use the proper indexes and proper conditions, and you are done — easy to work with compared to imperative languages, because it hides the implementation details. You do not need to know how the storing or the creating happens; you just want the result — the end result matters.
In the database, the optimizer decides what access path to choose and what to do. The user never spells out the plan; the optimizer builds one, and it can rebuild a better one when the data changes.
2.6.2 Worked Example: Distributing Fruits into Bags
Worked example — why the optimizer matters: fruits into bags. The example used to show why the optimizer matters: keep 2 to the power 6 in your mind.
There are two fruits — apples and oranges. An apple has a weight of 1 kilogram, and the other fruit (the orange) has a weight of 500 grams, which is 0.5 kilograms. You want to distribute these fruits equally into five bags. How you do it depends purely on your brain — you do the optimization and the calculations yourself. Instead of loading that onto the user, let the database optimizer do it.
The professor's headline number — the scale of the search the optimizer would handle:
\[2^6 = 64\]
Building the count step by step: each binary choice doubles the number of possible arrangements.
\[2^1 = 2,\quad 2^2 = 4,\quad 2^3 = 8,\quad 2^4 = 16,\quad 2^5 = 32,\quad 2^6 = 64\]
With six yes/no decisions — six slots, six items, or six placement choices — there are 64 possible arrangements. That is the point: even a tiny problem spawns dozens of candidate plans, and the optimizer is the one that evaluates them, while you stay with one sentence — "distribute the fruits equally into five bags".
Sense-check: start at 2 (one choice, two outcomes) and double six times — 2, 4, 8, 16, 32, 64. The last number is 64, which matches \(2^6\).
2.6.3 Execution Plans That Learn
Once you run the task, the database produces an execution plan — the concrete route it chose: which indexes, which scans, which join order. The next day you do the same task, and the plan is remembered — like your brain: you took your bike or car to the office, saw a traffic jam or road construction on the way, changed your access path, changed your route, and the next day you automatically take the changed path. We always update the brain, update the optimizer, update the execution plan. That is very, very important: the optimizer is not a static thing — it learns from what it sees and revises the plan for the next run.
Recap + Bridge. The optimizer carries the thinking for you — it builds a plan, remembers it, and revises it, like a driver learning tomorrow's route from today's jam. The plan it produces depends on how the data is physically laid out, which is the next question: row format or column format.
2.6.4 Row vs Column Storage
Data is stored either in row format or column format. Row format stores and retrieves the data row by row; column format stores and retrieves it column by column.
Formalize — two layouts, two workloads. In row-oriented storage, all the values of one row sit together on disk: reading a customer record is one contiguous read. In column-oriented storage, all the values of one column sit together: a query that needs only three columns of a wide table reads three column files and never touches the rest. The professor's point: row format is very good for OLTP — and even for OLAP. Columnar databases like Amazon Redshift and Parquet use the column format and store everything directly in memory.
Why columnar wins for analytics: an analytics query scans millions of rows but touches only a few columns; row storage would load and discard the other 100 columns of every row. Columnar systems also compress well, because the same column repeats values — a country column with a handful of distinct values becomes tiny. That is why the biggest analytics systems — Amazon Redshift, and file formats like Parquet — are built on the column format.
Assumptions & Scope — when each layout breaks.
- Columnar layout shines for bulk scans and aggregations, but it is weak for point lookups — finding one row by key means assembling pieces from many column files.
- Row-oriented layout shines for the small, fast, read-one-row-write-one-row patterns of transaction systems; it degrades on wide analytical scans.
- Column-oriented systems store all values of a column together, which compresses well — but the layout assumes the workload is "few columns, many rows". Pick the layout for the workload, not for fashion.
Real-world: Amazon Redshift (a hosted columnar analytics system) and Parquet (the columnar file format used across Hadoop, data lakes, and warehouses) are the two names you will meet everywhere in analytics pipelines. Row-oriented MySQL and PostgreSQL remain the defaults for transactional applications.
2.7 Data Serialization
2.7.1 What Serialization Is
Hook — how do you fit a year's worth of gifts into one suitcase? Think of packing for travel: suppose you have a very big gift item, many gift items, and you cannot squeeze everything. So you unwrap all the gift items and only take the elements. Once, when the instructor's daughter traveled to the UK, there was a weight problem — so a lot of the boxes were removed, and then some shuffling, unshuffling, changing the dimensions, changing the format happened. The same idea applies to data.
Serialization is the process of converting an object or data structure into a format that can be stored — for example, in a database or a file — and later reconstructed back. In simple terms, it is converting one data form to another, for example from text to binary format.
Formalize — the definition. In memory, data lives as objects and structures that the program can walk with pointers. When you want to write that data to a file or send it over a network, you must translate it into a self-contained sequence of bytes — a format another process can read without your pointers. That translation is serialization (also called encoding or marshalling); the reverse — rebuilding the object from the bytes — is deserialization (also called decoding).
Why do it? To satisfy storage size constraints and transfer bandwidth constraints — and for securing, encoding, and decoding, among other things. One rule holds it all together: both serialization and deserialization use the same algorithm — otherwise you get confused: however you pack, you have to unpack the same way. If the packing and unpacking rules differ, the data comes out scrambled.
2.7.2 Why Serialize
Real-world scenario: someone works in a system dealing with local CSV files, but when the data has to go to Amazon, the cloud, or another customer's system, the customer does not want it in CSV format. So you convert it into some other format — maybe a text format, maybe XML, or you store it directly into their own format. That is where you use serialization: the two systems agree on one byte format, and the data travels in that shape instead of each side inventing its own.
Pitfalls.
- Serialization is not encryption. Encoding changes the shape of the data so it can be stored or transferred; it does not hide the content. Encrypt first if secrecy matters.
- Language-tied formats chain you to one language. Java's built-in serialization and Python's pickle are convenient, but reading them from another language is very hard, and decoding an arbitrary byte sequence can execute code on your machine — a known attack surface. Prefer shared formats (JSON, XML, binary encodings) for anything that crosses a system boundary.
- Size is a real cost. Text formats are human-readable but heavy; binary formats are compact but harder to inspect. At terabytes of data, the choice of format changes your bills.
2.7.3 Worked Example: Serializing a User Object
Worked example — Alice, 25, Chennai.
Setup: a users table with two columns — an ID column and a data column. The user object comes from the customer's web systems or portals, with a name (Alice), an age (25), and a city (Chennai).
- Take the object:
name = Alice, age = 25, city = Chennai. - To insert that data into the table: put the ID in the ID column, and everything else — name, age, city — is the data.
- The entire thing is stored as a serialized string: a single quote starts it and a single quote ends it.
'Alice|25|Chennai'
That is simple serialization: the object is flattened into one storable piece of text.
- To get the data back, you deserialize — you unwrap that code and put it back into an application: split on the separator, and the application receives Alice, 25, Chennai again.
Sense-check: the round trip works because the packer and the unpacker agree on the same format — separator and quoting — exactly the "pack and unpack the same way" rule.
2.7.4 Python and Java Serialization
In Python the same thing is done with the JSON module. A JSON file is a structured format — name: Alice, age: 25, and so on.
import json
user = {"name": "Alice", "age": 25, "city": "Chennai"}
serialized = json.dumps(user) # serializes: one long string
restored = json.loads(serialized) # deserializes: back to a dictionary
json.dumps(user) converts the data into a serialized string, printing the entire thing as one string; json.loads deserializes it back. So: dumps serializes, loads deserializes. In Java there is something called a Serializable interface: take the same example — a user class with Alice, 25, Chennai — implement the interface, and convert the object into a string; similarly you can deserialize it.
2.7.5 Formats, Tools, and Streams
The process overall: data is produced, data is consumed, and in between data is transferred — so you serialize the data, transfer it, and deserialize it. You can take any format to any format: text to CSV, binary, and so on. There is a stream of data, especially in sensors and IoT, where a lot of serialization tools are used: JSON files to BSON (the binary format), binary formats, text formats, and human-readable formats. Even Hadoop uses the Parquet format. There are a lot of tools, interfaces, and APIs available — no need to worry about which one: the pattern is the same everywhere, serialize on one side, transfer, deserialize on the other.
Recap + Bridge. Serialization flattens objects into bytes for storage and transfer, and deserialization rebuilds them with the same algorithm — pack and unpack the same way. This is the plumbing that every pipeline below the surface relies on; next, the two processing worlds that sit on top of it: OLTP and OLAP.
2.7.6 Student Questions and Answers
Q: A student connects serialization to structured data: when the data has predefined columns — student name, student class, age, and all those — there are keys and values, and that is structured. How do we serialize unstructured data, and where do we actually use it?
A: You need to use a tool or an API. For example, converting a document to JSON requires a bit of tokenization: the text is mapped into tokens and paragraphs, you create the entities and the words, you tokenize it, every token gets vectorized, and then you can store it. That is an NLP-type process, and examples and simple code can be shared and executed later.
2.8 OLTP and OLAP
2.8.1 OLTP: Real-Time Transactions
When data is processed, there are primarily two types of processing: OLTP and OLAP. OLTP (online transaction processing) is your traditional system: you go to withdraw money, you do a GPay payment, you transfer money to somebody — all done instantly, and every one of them generates a transaction. OLTP systems are built to provide real-time performance and real-time access to people, and they serve millions and millions of users. In a bank, for example, many operators are there taking care of the day-to-day work.
Formalize — what OLTP is for. An OLTP system handles small, fast operations: look up a few records by a key, insert one row, update one balance. The main read pattern is a small number of records per query, fetched by key; the main write pattern is random-access, low-latency writes from user input. The data represents the latest state — the current balance, the current order status. That is why the word transaction is the unit of work: each withdrawal, each payment, each transfer is one atomic transaction.
Intuition — every tap is a transaction. Each time you tap your phone for a payment, an OLTP system somewhere does a tiny, fast read-modify-write: check the balance, subtract the amount, write it back, all in one step, all in real time. Millions of such taps per day is the normal load — which is why OLTP systems are built for concurrency and speed on single records, not for heavy analysis.
2.8.2 OLAP: Historical Analysis
OLAP (online analytical processing) is when you look back at old data, historical data: for example, you want to know which payments you made to a person above 5,000 or above 6,000. In a bank, when you want a two-year bank statement, you have to give a request — they process it and go to another system. So normally OLTP systems and OLAP systems are separated, and OLAP has very, very minimal users compared to OLTP's millions: historical data, consolidated data, mostly read-only data.
Assumptions & Scope — why the two must be separated.
- An analytic query scans huge parts of the dataset; running it on the OLTP system would slow the transactions that the business runs on. Database administrators guard their OLTP databases and keep analysts away from them.
- OLAP assumes a separate, read-mostly copy of history, consolidated from the operational systems. If you force analytics onto live transactions, both workloads degrade — that is the scope boundary between the two.
The instructor has built five OLAP systems and three big OLTP systems in the US (Boston, over seven years), including mutual fund databases and portfolio administration applications. The lesson from those builds: the two kinds of systems answer different questions, and each needs its own home.
2.8.3 Worked Example: The OLAP Sales Cube
Worked example — Washington Berry Juice, USA, 1997.
The idea of this OLAP operation: you want to know the sales — find the sales per week in the year 1997 from country USA for a particular product.
- Pick the dimensions. Dimension one is the product Washington Berry Juice; another is the extended dimension of female customers; then the country dimension, USA; then the year, 1997; and then the week.
- Join the dimensions. The joining operator combines multiple dimensions — the product, the customer with gender female, the country USA.
- Group and aggregate. Then you do the grouping and you get the results: for each week of 1997, the total sales of Washington Berry Juice to female customers in the USA. It combines multiple facts and pulls them together.
That is basically OLAP.
Contrast with OLTP: in a typical OLTP operation, you just do a sale — that's all. One person purchased Washington Berry Juice in the year 1997 (or 2026) at some store location, in Velachery, Pune, or Noida, some place — they purchased it, male or female. That is OLTP: one row written, instantly. Doing the extended operation — grouping that sale with millions of others across the product, customer, country, year, and week dimensions — is OLAP.
Sense-check: OLTP answers "what just happened?" (one sale); OLAP answers "what happened over time, sliced any way we like?" — and you can even create charts from the OLAP query. The SQL file for this example was shared for reference.
2.8.4 OLAP Operations: Roll-Up, Drill-Down, Slice, Dice, Pivot
OLAP provides multiple operations and multi-dimensional analysis with multiple views. You can drill down, you can sum up, and you can rotate — rotate the cubes row by column or column by row. You can look at a particular category, say the electronics category, and drill down further. You can roll up, you can join multiple dimensions, and you can do a slice or a dice. A dice is like throwing two dice — with multiple dimensions you combine; a slice is taking one and cutting it further: suppose there is Greater Noida — Noida can be divided into two, Greater Noida and maybe suburban Noida. You can rotate, you can pivot, you can drill down, you can roll up.
| Operation | What it does | Everyday picture |
|---|---|---|
| Roll-up | aggregate up one dimension (week → month → year) | zoom out |
| Drill-down | break one value into finer detail | zoom in |
| Slice | fix one dimension and cut a single layer | one sheet of the cube |
| Dice | combine several dimensions into a sub-cube | a smaller cube inside |
| Pivot / rotate | swap which dimensions sit on rows and columns | turn the cube |
You already know this from Excel: in Excel you do a lot of group by, sum up, sum and average, and you want to do a drill down. The same operations exist as operators in Oracle, MySQL, MariaDB, and DB2 — operators for performing pivot operations, roll-up, combining, aggregating, joining, moving averages, growth, and all those things.
2.8.5 Architecture: From OLTP to Data Marts
The current systems are the real-time OLTP systems; the next generation systems are ODS (operational data stores), OLAP systems, and data warehouse systems. The picture, in order:
- Operational systems — OLTP systems, real-time systems, ERP systems, inventory systems, payment gateways — all give the information.
- The ETL process (extract, transform, load) takes that information into the warehouse system.
- The warehouse is split into sub-systems called data marts.
- In the data marts you do the online analytical processing — the roll-ups, drills, slices, and pivots of the previous part.
For all the reporting, OLAP queries, and data mining we do, we need a warehouse — warehouse systems are the home of OLAP, and they are where the historical, consolidated, read-mostly data lives. In a nutshell, the user numbers are very, very minimal for OLAP: a handful of analysts, exploring the same data that millions of users create every day through OLTP.
Recap + Bridge. OLTP records each real-time event for millions of users; OLAP lets a few analysts slice the accumulated history by product, customer, country, and time. The flow — operational systems → ETL → warehouse → data marts — is the spine of every analytics stack, and it leads straight into the next question: is data an asset or a liability?
2.9 Data as an Asset and as a Liability
2.9.1 Data as an Asset
Real-world: at Netflix, efficient and actionable data-informed perspectives help the company think critically and differently about its business and ultimately improve services. Data is an important asset. For a successful business model, data is a key — you need to transform data into a successful business.
Hook — is data always good news? One man's food is another man's poison: anything can be an asset or a liability based on the circumstances. Something that is good for one person may not be good for another, and the same holds for data. The truthful pain: it is not easy to collect the relevant data; customers will not give all their data. The same dataset that powers a recommendation engine for one company is a legal risk for another.
Formalize — what makes data an asset. Data becomes an asset when it is (1) relevant to the business question, (2) collected legally and with consent, and (3) turned into decisions — the Netflix pattern: understand what people watch, recommend better shows, and decide what content to produce. The professor's framing: for a successful business model, data is a key — but only when the whole chain of collection, quality, and use holds together.
2.9.2 Data as a Liability
How does data become a liability? If it goes into the wrong hands, if it is misused — for example, data being used for generating ads even though you did not consent. Beyond misuse: whoever passes on information is liable for it — if a wrong definition is passed on, boom, it can cause catastrophic failure and create damages. Exposure of unexpected shades of collected data can harm the provider as well as the end users. If medical records are exposed unnecessarily, they may create problems for the hospital: how come this hospital gave this medicine? How come this hospital charges this much money? It creates unnecessary questions.
Assumptions & Scope — the liability boundary. There are potential legal and ethical risks associated with storing and managing sensitive patient records — which is exactly why the HIPAA standard and the HL7 standard exist. These are healthcare-industry standards the instructor worked with directly as a healthcare product manager. The boundary: the moment data identifies a person, it stops being just a business input and becomes a duty — to consent, to accuracy, to secrecy, and to deletion on request.
2.9.3 The Biggest Myth: More Data Is Always Better
The biggest myth: more data, better. The other myth: this stuff is easy. There are challenges. When we collect data, the system should be liable and the sources should be liable — you must pick data from reliable sources. There are challenges when applying for something — all those agreements — and PII (personally identifiable information) is an explicit concern, along with deletion criteria. Nowadays all the people who send mail, including Google and all the advertisement companies, also send you an unsubscribe option — otherwise they cannot send advertisements anymore. When you are part of a subscription model, they should also give you an option to unsubscribe. Sometimes, if you are not careful, an app like Yathal will charge you a lot of money — you should know to go and look for the subscription and how to do the unsubscription and the deletion criteria.
Recap + Bridge. More data is not automatically better: more data means more liability, more PII, more deletion duties, and more sources to trust. The myth dies in two sentences — data is only as good as its sourcing and its governance. Next: the concrete restrictions and compliance rules that follow.
2.9.4 Restrictions and Compliance
There are restrictions in data collection — you need to ensure what you should get and what you shouldn't get, and that is a challenging part. We need to follow the compliances. Can an employer store all the employee data outside the location of the data origin? The European Union data cannot exit the region — it cannot move out of the region; that is why there is a green site concept: anyone working with UK or British people has a green site, and you have to log into their system only — you cannot have their data over here. There are data board restrictions: permissions to store data, how the storage happens, what type of permissions you have, access to the data provider — somebody providing your data through Google or Instagram — how it is provided, when, and why. There are rules: how the rules are imposed, how regulatory compliance is followed, what regulatory and industry practices are followed. All are important.
Formalize — the compliance checklist. Four questions every data collection must answer: (1) What am I allowed to collect? (2) Where may the data live — and can it cross the region it came from? (3) Who has permission to store, read, and provide it, and how was that permission recorded? (4) What happens at deletion time — when the data is no longer needed, how is it removed? The green site practice is the extreme form: some data may not leave its home region at all, and the worker must log into the customer's system instead of copying the data out.
2.9.5 Student Questions and Answers
Q: How does data become a liability? A student answers first: if it goes into the wrong hands, like if it is misused — for example, the data is used for generating ads even though you did not consent.
A: Perfect. Data becomes a liability in more ways. Whoever passes on information is liable for what they pass: if a wrong definition is passed on and causes catastrophic failure, it can create damages. Exposure of unexpected shades of collected data can harm the provider as well as the end users. If medical records are exposed unnecessarily, it may create problems for the hospital — people may question why this medicine was given or why this charge was made. Storing and managing sensitive patient records carries potential legal and ethical risks, which is why we have the HIPAA standard and the HL7 standard.
2.10 Access Control, Anonymization, and Data Recovery
2.10.1 Granular Access to Stored Data
There are challenges at the storing phase — restrictions. Should you have read access? Should you have write access? What access do you have? Consider an orders table with millions of orders from multiple locations — London, Chennai, Mumbai, Bangalore, Hyderabad. What sort of access privileges should people have? Should they have select access to all the orders data across locations, or only a particular location? Can Chennai people insert data into the London location? No. Insert, deletion, update — can they modify something? All those things are to be considered. So the storage space has access restrictions: we want to provide granular restrictions and logging to know who made the change.
Worked example — the multi-city orders table.
Setup: one orders table holding millions of rows from five cities — London, Chennai, Mumbai, Bangalore, and Hyderabad.
- Decide the read scope. Does the London team get select access to all orders across all locations, or only to London orders? The professor's answer: scope it — each team reads the rows it is responsible for.
- Decide the write scope. Can Chennai people insert data into the London location? No — writes are confined to your own location. Insert, deletion, and update follow the same rule.
- Log everything. Every change is recorded so that later you can know who made the change, when, and from where.
Sense-check: the same table serves five teams, but each team sees and touches only its own slice — granular restrictions make that possible, and logging makes it verifiable.
Intuition — access is like keys to rooms. The building has rooms for each city's data, and people get keys only for the rooms their job needs. Granular access control means the key ring is per-person and per-room — nobody gets a master key by default, and every time a door opens, the entry is logged.
2.10.2 DML Activity and Auditing
If everybody is given all access — insert, delete, update, modification — a person can go and delete all the order records of Mumbai, to show that Mumbai's orders are lesser than Pune's, and that creates a problem. How do you handle that? With logging, tracing back, and auditing. This is called DML activity — data manipulation activities. Every DML activity can be audited, tracked, and logged: every transaction is logged — from where, date, time, what, who intended, what objects they have access to — all those things are tracked.
Formalize — the audit trail. A DML activity is any data manipulation: insert, update, delete, or modify. The audit trail is a log of such activities with five fields: the source (from where), the moment (date and time), the operation (what), the actor (who intended it), and the scope (what objects they had access to). With the trail, the deleted-Mumbai-rows scenario ends differently: the log shows who ran the delete, when, and from which session — the change can be traced back and undone.
Assumptions & Scope — when there is no trail. Auditing only works if logging is on, complete, and protected: if users can edit or erase the log, the trail is worthless. And auditing records what happened, not whether it was allowed — access control (the previous part) decides permission; auditing only proves what was done. Both are needed.
2.10.3 Anonymization and Masking
Anonymization of data reduces the data access and auditing burden. Example: a shopper comes to a shopping mall and purchases something — you don't need to show that "Rahman came and purchased it"; you replace the private identifier with another. But how do you reverse it back?
Formalize — the three goals of anonymization.
- Protect the data from casual inspection by engineers along the pipeline — a developer debugging a pipeline sees a masked value, not a real name.
- Preserve the properties of data that are relevant to the model — the purchase amount, the time, the category still look real, because the model needs them.
- Remove the connections between the private data and the model data — no path from the model's rows back to the person.
Masking and anonymization often use sequence numbers or surrogate keys to identify particular things: they don't say "this was generated by X" — they put an autonomous value, they hide, they mask. Or you reduce: give only what is needed — that reduces risk.
Some data is personal, private data — so you restrict or you do masking: restrict at all levels, row level. The mantra is RBAC — role based access control: based on your role, you get the access control. There are also other discriminatory access controls, and single sign-on access.
Pitfalls.
- Anonymization is not deletion. A masked row still exists and still feeds models; masking only breaks the link to the person — and some combinations of fields (birth date, zip code, gender) can re-identify people even when names are gone.
- Casual masking is not enough. The goal is to keep the model's signal while removing identity; if masking also removes the signal (for example, rounding every purchase amount to zero), the model starves.
- Treat the reverse mapping as a secret. Whoever holds the surrogate-key mapping can undo the anonymization — restrict that mapping the same way you restrict the data itself.
2.10.4 Data Deletion and Recovery
When you delete the data, the user mentions a specific time period — when the organization no longer needs the data. A lot of portals retain your data for some time, say six months; after that you have to recreate your profile in the portal. Governing policies here include the GDPR. Real-world: when a system crashes, how does the database recover? It is not that easy. War story: the instructor has been to many data recoveries, in the US as well as Singapore, and once recovered about two days of transactions — it took a lot of time. Now it is easy: lots of advancements with replication and SAN (storage area network) technology — you can do block-level recovery quickly — but that was not the case ten years ago, when it was very difficult. So recovery is a big problem.
Recap + Bridge. Deletion has a policy — a retention period, then removal, governed by rules like GDPR — and recovery has a technology — replication and SAN make block-level recovery fast, but the discipline only works if the copies exist. Next: where all of this meets the machine learning model — the data pipeline.
2.10.5 Industry Applications
Real-world: GDPR governs deletion and data retention (six-month portal retention is a common practice). Real-world: RBAC and single sign-on are standard access-control practices in enterprise systems. Real-world: replication and SAN technology now make block-level database recovery fast — the same war story that once took days now takes minutes, because the recovery is built into the storage design.
2.11 Data Pipelines and ML Sensitivity
2.11.1 The Pipeline Picture
A pipeline is connectivity — a connector, with many connectors and many stages, something like a water pipeline: from your tank, water goes into the filter and then through pipes until it reaches your water bottle. The water comes from the Cauvery river or some other source, but finally it comes to your tank. The data pipeline works the same way: data comes from multiple sources and finally reaches the machine learning model, which processes it.
Intuition — the water pipeline. The river (the sources) feeds the tank (the raw data store); the filter and the pipes (the pipeline stages: cleaning, transforming, formatting) carry the water to your bottle (the model). Each connector does one job — one filters, one carries, one stores — and the whole chain only works when every pipe is connected. If a pipe is blocked or a source runs dry, the bottle never fills, no matter how good the filter is.
2.11.2 Scenario: Predicting New Year's Eve Sales
Here is the scenario to reason through. An e-commerce company wants to predict New Year's Eve sales — the sales on December 31st — from all the countries, regions, and languages. They also want to study trends based on language. Due to a technical or human error, they lost the data from a particular country, region, or language. Take the example of Apple: Apple phones are available everywhere — all countries, regional languages. Something has happened: the data pipeline was still executing normally, while the ML pipeline was behaving so differently. The data pipeline was still executing because it is just doing its work — but the ML can go wrong.
Worked example — the sales prediction that lost a region.
- Setup. An e-commerce company predicts New Year's Eve sales (December 31) across all countries, regions, and languages, and studies trends by language.
- The loss. Due to a technical or human error, the data for one country, region, or language disappears — think of Apple, whose phones are sold in every country and in every regional language.
- The symptom. The data pipeline keeps executing normally — it is just moving data, and nothing in its world changed. The ML pipeline, however, behaves very differently: the model's outputs shift, confidence drops, and errors grow.
- The question. Can you reason out why? The professor's rule for this exercise: take your time — any answer is welcome; no answer is perfect, and even the instructor's answer is not 100% correct.
Sense-check: the two pipelines reacted differently to the same loss — that asymmetry is the whole puzzle, and the answer follows next.
2.11.3 Why the ML Model Failed While the Data Pipeline Ran Fine
Q: The data pipeline was still executing normally while the machine learning pipeline behaved very differently. Why would the ML model — a classification, clustering, or some other model — behave differently? Any answer is welcome.
A: Because the prediction is not accurate due to the data. Correct. You are missing a lot of data — in India, a lot of people may have purchased Apple phones, and you missed those records. You trained for something like one lakh records, and now you are underfitting the data: the prediction accuracy may be fine for true positives, but you get a lot of false positives and false negatives. The data pipeline is not predicting anything, so it can work as usual. The ML pipeline includes a model, and that model consists of so many categories — including the language. If the right data is not supplied, the ML pipeline behaves abnormally, bringing down the performance as well as the accuracy of predictions. Omission results in incorrect prediction. In India or Korea or Iran, due to some network issue — say Iran could not send the data to the cloud due to the war — Iran and India had so many sales, and now we are unable to predict the New Year sales accurately.
The logic behind the answer: a data pipeline moves data, and moving a smaller volume of data is still normal work — the pipes never complained. An ML pipeline is different: it includes a model, and the model learned its patterns from the training data, including the language categories. When whole regions vanish from the input, the model must answer for people it never saw — Iran and India had huge sales, and the model was trained on a world without them. The result is an underfit model: accuracy on the familiar cases stays okay, while false positives and false negatives multiply. Omission results in incorrect prediction.
2.11.4 What ML Needs From Data
Here is the key statement — flagged as very, very, very important: normal data pipelines are sensitive to the volume of input data and the correctness of input data; ML pipelines are sensitive to changes to the distribution of data, the volume of input data, and the correctness of input data.
Formalize — the sensitivity split.
| What can go wrong | Data pipeline | ML pipeline |
|---|---|---|
| Change in the distribution of data | unaffected | breaks |
| Volume of input data too small | keeps running | underfits, accuracy drops |
| Correctness of input data | keeps running | errors propagate into predictions |
The model needs proper data, a proper distribution of data, and the correct volume of data; the pipeline needs the correct flow of data. Otherwise, things may not be correct — the accuracy of the results may go wrong. That is the importance of data management for machine learning, and that is why you are studying this subject.
Exam note: this asymmetry is the single most important statement of the lecture — a normal pipeline is sensitive to volume and correctness, while an ML pipeline is additionally sensitive to changes in the distribution of the data. Expect to be asked to explain why the pipeline in the New Year's Eve scenario kept running while the model failed.
2.11.5 Handling These Scenarios
How do you handle those scenarios? Can you create some buffer data? Can you do some masking? Can you do some extra filling? There is a process, and a couple of programs will be shown. Python knowledge helps — if you know Python it is going to be easy — but even if you do not, don't worry: a Google Colab notebook with a Gmail account will be used, code will be shared, and one complete data engineering process will be done together. Even without Python knowledge, you just follow the steps — it is very easy.
Recap + Bridge. The fixes are practical — buffer data, masking, filling — and will be worked hands-on in a Google Colab notebook. Before that, one more idea ties the volume story together: what sample size should you train on at all?
2.11.6 Sample Sizes, Underfit, and Overfit
To buy a shirt — for yourself, or to give to hundreds of friends — take the best sample: good sample sizes of height, weight, size — say five samples for 150 people — and as the good sample sizes increase, the volumes increase, and you get a better prediction. But if the sample size is very, very small — a very small shirt — it is going to be the underfit: it may not fit another person. If you wear one shirt which is extra-large, it may be an overfit. You need to have the best fit.
Intuition — the shirt. One tiny sample (a small shirt) describes only the person it was cut for — the model underfits: it cannot generalize to other people. One sample that is oddly huge (an extra-large shirt) describes the data so loosely that it fits nobody well — the model overfits: it memorizes noise instead of the pattern. The best fit sits in between — enough samples of height, weight, and size that the shirt fits most people.
When you train on more and more data, you can improve model performance. But the likelihood of data issues or problems starts low and rises with very large data sizes — meaning a bigger dataset increases the chance of data quality problems: noise, inconsistency. That is why you are studying this subject — what do I do about it?
2.11.7 Distributed Data Characteristics
Data is not in one place. Data at rest is in one place, but data is distributed across multiple places. Sometimes data is lost, so we need to make copies. Data changes frequently — how much time does the data take to travel, how fast should the data be available to get an accurate answer, is the data available as and when we need it? These lead to the characteristics of data: durability of data, consistency of data, version control — what version we need. We will study big data characteristics, performance, and availability: do we need all this data available 24 by 7? How fast should the data be available? What level of data do I want, when, at what time, what data to preserve? Do we need consistent data — the same data for all the copies? If one node goes wrong, do we have durability — is it distributed in other systems? Integrity issues arise because of varying version controls and consistency — the copies may be different, and you may get into integrity issues.
Recap + Bridge. A model only trusts data that is durable (copies survive node failure), consistent (all copies agree), version-controlled (you know which version you trained on), and available when needed — the four questions that will structure the big data topics ahead.
2.12 ETL, Data Warehouses, and Data Lakes
2.12.1 The ETL Process
Raw data comes from sources like web APIs, Instagram feeds, Twitter tweets, application APIs that give the number of clicks, mobile applications, IoT devices, forms, and surveys. Once ingested — can we use the data as such? No, not possible. We retrieve and verify data from various sources, process and organize, and extract the data so it is usable; then we transform — some massaging of the data, organization — and finally the data moves to a data repository.
Formalize — extract, transform, load. That is the ETL process, named after its three steps:
- Extract — pull out what you wanted to extract from the source systems.
- Transform — massage and organize it according to your business goals: clean, filter, join, aggregate, convert units, reshape.
- Load — push the result into a database, create a CSV file, or load it into a cloud database.
The order matters: transform happens before load, so what lands in the repository is already in the shape the business wants.
Worked example — ICICI customer churn.
ICICI bank wants to perform customer churn analysis — how many customers are leaving from ICICI at the regional level, the reasons, or they want to retain the customer; maybe specific customers in a particular location, or they want to attract only high-value users of credit cards — what kind of incentives can they perform?
- Extract only the relevant data. They don't need to take all the data; they want a target of customers with two lakh and more credit card usage, maybe only for some specific categories or types of credit cards.
- Transform based on the business goals — filter to the target segment, compute regional churn numbers, shape the rows for analysis.
- Load the result — push the data into a database, a CSV file, or a cloud database.
Sense-check: the bank did not copy its entire customer base; ETL delivered a small, purpose-built dataset — the churn segment — ready for whatever model or report follows.
There are a lot of ETL tools available: DataStage, Informatica, Cognos, and many more.
2.12.2 Why ETL Is Not Enough
Is data always structured? No. Can ETL cater to the growing velocity? No way — because big data comes into the picture. Data is coming at high speed, high velocity; there are seven characteristics of big data, which will be discussed shortly. Can ETL work with real-time data? Data streaming is happening, and the existing ETLs have shortcomings. That is why we need to build different models and pipelines — we need to get into big data systems like Hadoop and distributed systems. We need to filter the data, merge the data, and aggregate the data, depending on what model we are going to build: should we classify the data, predict new data, or cluster the data? Data can be stored before or after data processing. What is the type of the data? What was the purpose of the data? Do we want a data warehouse or a data lake?
Assumptions & Scope — where ETL breaks.
- ETL assumes batch-shaped, structured data that arrives on a schedule. It assumes you know the shape before you load.
- ETL cannot keep up with high velocity — streams of events arriving every second — because transform-before-load forces a wait.
- The seven characteristics of big data (velocity among them) are the reason the next-generation answer is distributed processing: Hadoop and distributed systems, which spread the work across many machines.
2.12.3 Data Warehouse and Star Schema
The data warehouse requires a defined schema — for example, the star schema (star model). The skeleton: four dimension tables — a product table, a customer table, a time/period table (the date and time information), and a location/city table — all connected to the facts. With the multi-dimensional connections you can do roll-up, slice, dice, pivot, rotate — anything and everything is possible, because it follows a schema and has a specific skeleton.
Formalize — the star schema. In the middle sits the fact table: one row per event (one purchase, one click, one call). Around it sit the dimension tables: product (what), customer (who), time (when), location (where). The fact table holds foreign keys pointing at the dimensions, plus the measured values. The name comes from the picture: the fact table in the center, dimension tables as the rays of a star. Every OLAP operation from the earlier lecture — roll-up, drill-down, slice, dice, pivot — works because the skeleton is fixed.
Real-world: PostgreSQL relational database systems (RDBMS) are used; the instructor has built data warehouses for a mutual fund business and for telecom accounts, optimized for high-performance analytics on structured data. Data analytics dashboards, business intelligence tasks, and data visualizations all use the warehouse.
2.12.4 Data Lake and Lake House
Many, many organizations are moving towards the data lake. Is a data lake and a data warehouse the same or different?
Intuition — the pond and the lake. Think of a pond and a lake: a warehouse is like one pond — that pond water is hard water; it follows certain rules and boundaries, it can have only certain things, and we know it will have them only at a certain time. A data lake has no confined perimeters and no diameter — it has to be huge, with no defined schema. A data lake comes in handy for semi-structured and unstructured data: hard water will come, soft water will come — everything.
Real-world example: a data lake built in Chennai gets water from a river, from some lake, from some pond, from the sea — put everything into the big lake that will be used for supplying to Chennai. A data lake is optimized for costs and multi-type sources, and it is useful for building a sandbox for innovative data projects — AI sandboxes included.
Assumptions & Scope — the lake is not a free-for-all.
- A common confusion: the lake is sometimes described as "a cleaner version of a warehouse" — that description belongs to the lake house, not the lake. The lake house stores data in the lake's object storage but adds warehouse-style features: schema support, updates and deletes, table history and rollback. The raw lake itself is the opposite of clean — it is deliberately ungoverned at write time.
- A lake with no schema and no governance quietly becomes a data swamp — data lands in, and no one can find or trust it. The answer is schema-on-read (interpret the data when you read it) plus metadata management.
- The warehouse predominantly supports structured data, while the lake handles a lot of streaming data, real-time streaming — and unstructured files the warehouse cannot hold at all.
That is sometimes called a data lake house — cleaner, but it supports the unstructured and streaming side: the warehouse predominantly supports structured data, while the lake handles a lot of streaming data, real-time streaming.
Recap + Bridge. ETL feeds the schema-bound warehouse (the pond), while the schema-less lake takes everything for later. The lake house converges the two. Next: who governs all of this, and what holds it together — governance, metadata, and platforms.
2.12.5 Industry Applications
Real-world: ETL tools DataStage, Informatica, and Cognos run enterprise data integration. Real-world: Hadoop and distributed systems handle big data that ETL cannot. Real-world: ICICI-style customer churn analysis is a standard ETL-driven business task, and warehouses built for mutual funds and telecom are typical industry use cases — the pond-or-lake choice comes down to whether the business needs governed structure or raw flexibility.
2.13 Data Governance, Metadata, and Data Platforms
2.13.1 Data Governance
Who does all of this? There are data governance councils: they align taxonomies — the structures that ensure what should go — and define metadata consistently across all the data sources. They define the roles and responsibilities. For data security, we define roles and responsibilities to help ensure that data access is provided appropriately — controlled access to protect the customer data, to ensure there are no threats, no cyber criminals, no data loss: more encryption, more data masking.
Intuition — governance is the rulebook, not the referee's whistle. A company can build a brilliant pipeline and still fail if nobody decides who may read what, which term means which thing, and who answers when something goes wrong. The governance council is the body that writes those rules — it aligns taxonomies (so "customer" means the same thing in every system), keeps metadata consistent, and assigns roles and responsibilities so that controlled access, encryption, and masking actually happen.
2.13.2 Data Architecture
Data architecture provides the infrastructure for the storage, integration, and use of data throughout the organization. The architectural-level components are defined here: am I going to use a particular vendor system for storage? Streaming storage? How am I going to do the integration layer — storage, big data, or something else? All those things are defined at the data architecture component level.
Formalize — what the architecture decides. The architecture is the blueprint of where data physically lives and how it moves: which vendor system holds the storage, whether streaming storage exists alongside batch storage, and how the integration layer connects them. Every downstream choice — which tools, which pipelines, which governance rules are enforceable — depends on this blueprint, because it fixes the shape of the land the data travels over.
2.13.3 Metadata
Metadata is data about the data. Suppose you have 20 tables: metadata holds the details about the 20 tables — what the table is, where it is stored, what columns it has, how many rows it has, what index it has. It is like a dictionary being maintained of all the critical attributes used in the entire systems.
Worked example — the dictionary of 20 tables.
You have 20 tables in the warehouse. The metadata for each one records:
| Table | Where stored | Columns | Row count | Index |
|---|---|---|---|---|
| customers | database node 2 | customer_id, name, city, phone | 1,240,000 | customer_id (clustered) |
| orders | database node 3 | order_id, customer_id, amount, date | 8,700,000 | order_id, customer_id |
| products | database node 1 | product_id, title, price | 52,000 | product_id |
| ... | ... | ... | ... | ... |
One page per table, all 20 pages collected in one dictionary. Sense-check: when someone asks "how many rows does the orders table have, and where does it live?", the answer comes from the metadata — not from scanning the data itself.
2.13.4 The Data Management Framework
A framework is basically a high-level structure. When we build any data management component, the component should have a proper framework: what process we are going to follow, what policies, what data stewardship mechanisms, what standards, what best practices. Data governance provides the overarching support to data management through stewardship policies, processes, standards, and adherence to leading practices. Data stewardship is part of it, and there is something called master data management (MDM) — a certification area (InfoSphere) that does a lot of stewardship.
Formalize — the framework components. A complete data management framework has these parts:
- Governance — the overarching support: stewardship policies, processes, standards, adherence to leading practices.
- Data architecture — the storage and integration blueprint.
- Metadata — the dictionary of what exists and where.
- Data quality mechanisms — the checks and fixes that keep data usable.
- Lifecycle of the data — how we are aging the data, when is the final deletion of the data.
- Analytics platform and visualization platform — because you store and do everything finally for business intelligence, for analytics, for better decision making.
- Data privacy mechanisms — kept in place internally and externally.
A data management person should have an idea about all of these.
Recap + Bridge. Governance provides the overarching support; the framework wraps architecture, metadata, quality, lifecycle, analytics, and privacy into one structure. The software that delivers this structure at scale is the next piece: the data platform.
2.13.5 Data Platforms
A data platform is basically a package — a software suite, built with Python, Java, and existing API tools — that an organization uses to process and manage large amounts of data quickly and efficiently. It manages the data, normalizes the data, transforms the data, and applies it to a given data product. It requires a central repository and a processing house, and it has lots and lots of data pipelines to collect, ingest, store, and transform the data — everything put together as a platform. In the olden days we called it front end and back end; now we have the data platform in between — earlier we had a middle tier — with delivery to a variety of destinations, and the data can be consumed by different enterprise groups. The tools require strong data and computing infrastructure that scales to meet demand without impacting performance.
Formalize — the key requirements of a data platform.
- Fast query processing — that is the key.
- Large storage capacity.
- Elastic computing — computing resources can be added as demand grows.
- In-memory caches instead of disk — hot data stays in memory.
- Massively parallel query processing — many workers on one query.
- Column-level storage.
- Large in-memory data grids and computing clusters.
Every one of these requirements traces back to the earlier lectures: column-level storage (row vs column), parallel processing (distributed systems), and in-memory caching (the key-value store pattern).
2.13.6 Big Data and the Road Ahead
Real-world: an IBM study asked CEOs about their top priorities: enhance security and risk management — and "who has the most advanced generative AI." If you want to take advantage of generative AI, consider the tool named AntiGravity: it generates customer data about transactions — electronic gadgets, mobiles, smart devices — and shows a simple data pipeline in Python to classify high-sale orders and no-sale orders. It uses models, data pipelines, and vector databases. CEOs want security, proper risk management, and better decision making, and they are thinking of using generative AI, because of the volume of data, data silos, different data type formats, and datasets that are always complex and inconsistent. Data management is the practice of collecting, processing, and using data securely and efficiently for a better business outcome, so a strong data management strategy — good data ingestion, data processing, data storage, data governance, and data security — is important.
Big data systems provide an ecosystem — a data management framework you can build your own company's data management framework from, using the technology.
Coming up: the phases in the data lifecycle — generation, ingestion — with examples, and a hands-on data engineering exercise in the class. It is an exhaustive portion, taken step by step. Think of the Eiffel Tower or the Burj Tower: now we are seeing the tower from afar; we will go one by one and slowly everything will come together — a top-down approach, not a bottom-up approach.
Recap + Bridge. The data platform packages everything into one suite — fast queries, elastic compute, in-memory caches, columnar storage — and big data systems supply the ecosystem to build on. The course now turns top-down: from the tower seen from afar to the data lifecycle — generation and ingestion — step by step.
2.13.7 Student Questions and Answers
Q: A student reads the data governance definition but is unable to get the meaning of the high-level words like "overarching stewardship" — what does that phrasing actually mean?
A: Overarching support basically means the framework. A framework consists of multiple structures and multiple components, and we need to ensure each component is entitled to perform certain activities — we don't want to lose that. It is a governance layer: we define the standards and operational processes — who does what, who sets the standard, because not everybody can define the standards. It is like a project charter: in a project you define the high level in the charter; here the CEO, CFO, or CKO (Chief Knowledge Officer) define the standards — this is what you have to do, this is what you have to follow. You will learn more later.
Exam Guidance Summary
- Data quality check question. Expect a question in the style of the in-class exercise: you must be able to identify at least five data quality issues in a sample table (missing values, outliers, mismatched units, inconsistent encoding, inconsistent names) and explain how to resolve them. Coding is not necessary, but you should know what sort of issues exist and how you would resolve them.
- Both data model families. The SQL type model and the NoSQL type model are both required material — you must know both. A MongoDB cluster demonstration (including the AI-driven query generation) is planned around the midterm.
- Normalization. The normalization document is shared material to study: first normal form, second normal form, and third normal form, and BCNF — be ready to apply the normal forms to a given table.
- Binding and imputation. The binding technique and data imputation (filling missing data with constants, min/max, mean, median, or boundary values) are flagged: they will be covered in a later session, and they are the core fixes for missing values.
- Pipeline versus model sensitivity. The statement that normal data pipelines are sensitive to the volume and correctness of input data, while ML pipelines are also sensitive to changes in the distribution of data, was flagged as very, very, very important — this is the key conceptual question of the lecture.
- Hands-on exercise. A hands-on data engineering exercise is planned in class using Google Colab with Python — even without Python knowledge you can follow the steps, so don't skip it.
- OLTP versus OLAP. Expect the OLTP versus OLAP contrast (real-time transactions versus historical analysis, user counts, warehouse dependency) and the data warehouse versus data lake contrast (defined schema versus no schema) as core conceptual material.
- The framework. The data management framework components — governance, architecture, metadata, data quality, lifecycle, analytics platform, privacy — are the framework for thinking about the whole subject.
Key Industry Applications
- GPay, bank withdrawals, and money transfers are everyday OLTP systems; two-year bank statements and payment histories above a threshold are OLAP queries over warehouses.
- Netflix uses data-informed perspectives to think critically about its business and improve services — data as an asset.
- LinkedIn and Facebook use graph databases (Neo4j, Neptune, Gephi) for connectivity, tagging people, and friend-of-friend recommendations.
- Amazon DocumentDB, Apache CouchDB, Firebase, and Firestore are document databases used for logs, purchase logs, and event information.
- Oracle, Informix, Sybase, and PostgreSQL are relational (SQL) systems; Amazon Redshift and Parquet are columnar formats used in analytics.
- MongoDB is the NoSQL demonstration system — its cluster is AI-driven and writes queries from a plain description.
- Google provides the unsubscribe option for ads (compliance), and Google Colab is used for the class data engineering exercise.
- Apple's global sales across countries, regions, and languages is the scenario for how losing one region's data breaks ML predictions.
- ICICI-style customer churn analysis is a classic ETL task; DataStage, Informatica, and Cognos are the ETL tools in use.
- IBM's CEO study links data management to security, risk management, and generative AI; the AntiGravity tool generates customer data and builds Python data pipelines with vector databases.
- Healthcare data is governed by HIPAA and HL7 standards; GDPR governs EU data (which cannot leave the region) and the green-site practice for UK data.
- Hadoop and distributed systems handle big data that ETL tools cannot, including Parquet format storage.
- Twitter and Instagram APIs, web APIs, IoT devices, forms, and surveys are the raw data sources feeding pipelines.
- Yathal is the cautionary example of a subscription app that charges if you don't unsubscribe in time.
DMML Lecture 2 notes · Query Paradigms, Storage Architectures, and Data Pipelines
Sections Breakdown
Defines data management as collecting, processing, storing, and securing data in one connected chain, and explains why ML models depend completely on these underlying data systems.
A preliminary data quality exercise on a multi-source sample table: identify at least five issues (bad blood group, 1/0 COVID encoding, impossible age, mixed units, missing height, invalid name) and resolve them with ranges, imputation, outlier handling, and normalization.
Covers structured, semi-structured, and unstructured data formats, then the relational model (relations, tables, tuples/rows) and normalization through 1NF, 2NF, 3NF, and BCNF to remove anomalies and redundancies.
Data models are the skeleton of data organization: hierarchical (parent-child trees), graph (nodes and edges with relationships as priority), document (self-contained documents in collections), and key-value (fast lookups), split into SQL and NoSQL families.
Two ways to ask for data: imperative spells out every step in order (the car-parking bag example), declarative states the result you want (one-line query with a condition), and the declarative style is the power of SQL because the database handles the how.
The database optimizer plans access paths like a driver choosing a route (Google Maps analogy), execution plans are remembered and revised, and data is laid out row-wise (OLTP) or column-wise (Amazon Redshift, Parquet) for analytics.
Serialization converts objects into storable/transferable byte formats and deserialization rebuilds them with the same algorithm; covers the packing analogy, the Alice/Chennai users-table example, Python json dumps/loads, Java Serializable, and tokenization for unstructured data.
OLTP handles real-time transactions for millions of users (withdrawals, GPay payments); OLAP analyzes historical, consolidated, mostly read-only data for a few analysts; the OLAP sales cube example, the roll-up/drill-down/slice/dice/pivot operations, and the OLTP to ETL to warehouse to data marts architecture.
Data is an asset when relevant, consented, and turned into decisions (Netflix), and a liability when misused or leaked (HIPAA/HL7 for medical records); the biggest myth is that more data is always better; collection faces restrictions, compliance, PII, deletion criteria, and regional rules like the green site.
Granular access restrictions and logging for the multi-city orders table; DML activity auditing (every transaction logged); anonymization and masking with surrogate keys and RBAC; deletion policies (GDPR, six-month retention) and recovery via replication and SAN.
Data pipelines are like water pipelines from sources to the model; losing a region's data (New Year's Eve sales, Apple example) underfits the model with false positives and negatives; ML pipelines are sensitive to distribution changes, volume, and correctness; sample sizes map to underfit/overfit (shirts); distributed data needs durability, consistency, version control, availability.
ETL extracts, transforms, and loads data (ICICI churn example); ETL fails on velocity and streaming so big data systems like Hadoop step in; the data warehouse uses a defined star schema (four dimensions around the facts), while the schema-less data lake takes everything and the lake house is the cleaner hybrid.
Data governance councils align taxonomies and roles; data architecture provides storage and integration infrastructure; metadata is the dictionary of data (20 tables example); the framework spans governance, architecture, metadata, quality, lifecycle, analytics, and privacy; data platforms package fast query processing, elastic computing, in-memory caches, and columnar storage.
Exam intel carried from the lecture: data quality check questions, SQL and NoSQL model families, normalization forms, binding and imputation, pipeline versus ML sensitivity, the Colab exercise, OLTP/OLAP contrasts, and the framework components.
Named industry applications carried from the lecture: OLTP/OLAP systems, Netflix data as asset, graph databases at LinkedIn and Facebook, document stores, columnar analytics, AI-driven MongoDB, compliance examples, Apple's regional-data scenario, ICICI ETL churn, IBM CEO study and AntiGravity, healthcare and GDPR standards, Hadoop, data sources, and the Yathal cautionary tale.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
Data Management: What It Is and Why It Matters
Must-know: Data management = collecting, processing, storing, securing data; garbage in, garbage out means a model performs better with good quality data, good data model, good representation, good format, and good pipeline
⚠️ Top pitfall: Cleaning one table while missing the dependent data; blaming the algorithm before checking data quality
Self-check: Name the four steps in the data management chain and the DIKW ladder order.
Connects to: 2.2, 2.11
Data Quality Check in Practice
Must-know: Classic data quality issues: inconsistent encoding, missing values, outliers, mismatched units, inconsistent identity data; fixes are acceptable ranges, imputation (constant/min/max/mean/median/boundary), outlier methods, normalization/standardization, replacement
⚠️ Top pitfall: Jumping to conclusions without a personal quality check; using one fix for every issue type
Self-check: A 25-year-old's height is missing and age 150 appears. Which two techniques do you apply and why?
Connects to: 2.1, 2.11
Data Formats and the Relational Model
Must-know: Relational model: relations are unordered collections of tuples (rows); normalization removes anomalies and redundancies; normal forms 1NF, 2NF, 3NF, BCNF must be applicable
⚠️ Top pitfall: Treating redundancy as harmless — contradictory copies of the same fact break data integrity
Self-check: Which normal form does a table violate if its city column depends on its zip code column?
Connects to: 2.4, 2.12
Data Models: Hierarchical, Graph, Document, and Key-Value
Must-know: Four model families (hierarchical, graph, document, key-value) plus relational; graph databases treat relationships as the priority; document stores anything in collections; key-value forces a key and a value; both SQL and NoSQL families are examinable
⚠️ Top pitfall: Using a graph model when data is a simple tree or a plain list; treating a document store as a key-value store or vice versa
Self-check: A customer places an order, and a friend-of-friend query is needed. Which model family fits best and why?
Connects to: 2.3, 2.5
Declarative and Imperative Query Languages
Must-know: Imperative = every step in order with conditions evaluated by hand; declarative = state the result (SQL), the database decides indexes, joins, and execution order; declarative hides implementation details and parallelizes better
⚠️ Top pitfall: Writing imperative-style thinking into SQL and assuming row order; believing the declarative query's cost is visible to you
Self-check: Write the declarative query that returns all animals whose family is Sharks.
Connects to: 2.4, 2.6
Query Optimization and Storage Formats
Must-know: 2^6 = 64 arrangements for six binary choices; the optimizer hides implementation details and learns execution plans; row format for OLTP, column format (Redshift, Parquet) for analytics scans
\[2^6 = 64\]
⚠️ Top pitfall: Forgetting that columnar layout is weak for point lookups and row layout is weak for wide scans
Self-check: Why does a columnar database read a 3-column query over a 100-column table faster than a row store?
Connects to: 2.5, 2.8
Data Serialization
Must-know: Serialization flattens an object into bytes for storage or transfer; deserialization reverses it; both must use the same algorithm; Python json.dumps serializes and json.loads deserializes; serialization is not encryption
⚠️ Top pitfall: Packing and unpacking with different rules; confusing serialization with encryption; relying on language-tied formats across systems
Self-check: In Python, which call serializes a dictionary into a string and which call restores it?
Connects to: 2.1, 2.3
OLTP and OLAP
Must-know: OLTP = small fast single-record transactions, real-time, millions of users, latest state; OLAP = aggregates over history, minimal users, warehouse-dependent; operations: roll-up, drill-down, slice, dice, pivot; architecture OLTP to ETL to warehouse to data marts
⚠️ Top pitfall: Running analytic scans on the OLTP system; confusing one OLTP sale with the multi-dimension OLAP grouping of it
Self-check: You want total weekly sales of one product in one country for one year. Which system and which operations do you use?
Connects to: 2.6, 2.12
Data as an Asset and as a Liability
Must-know: Data is a liability when it goes to the wrong hands, is misused, or exposes unexpected shades of collected data; whoever passes on information is liable for it; HIPAA and HL7 govern healthcare data; more data is not always better — PII and deletion criteria add duties
⚠️ Top pitfall: Believing the myth that more data is always better; ignoring deletion criteria and unsubscribe obligations
Self-check: Why can a European employee's data not be stored outside the region, and what is the green site practice?
Connects to: 2.1, 2.10
Access Control, Anonymization, and Data Recovery
Must-know: Granular access: per-role read/write scope with logging; DML activity audit trail records from where, date, time, what, who, and objects; anonymization has three goals (protect from inspection, preserve model properties, remove identity links); RBAC; recovery via replication and SAN block-level restore
⚠️ Top pitfall: Giving everyone all access (a person can delete another city's orders); treating anonymization as deletion
Self-check: What five pieces of information does a DML audit log capture for each transaction?
Connects to: 2.9, 2.11
Data Pipelines and ML Sensitivity
Must-know: Normal data pipelines are sensitive to volume and correctness of input data; ML pipelines are additionally sensitive to changes in data distribution — the model needs proper data, proper distribution, and correct volume; underfitting follows missing regions of data (false positives and negatives); bigger datasets raise data-quality risk
⚠️ Top pitfall: Expecting the data pipeline to warn you about missing data — it cannot, because it is not predicting anything
Self-check: Why did the New Year's Eve model fail when one region's data was lost, while the pipeline kept running?
Connects to: 2.1, 2.2
ETL, Data Warehouses, and Data Lakes
Must-know: ETL order is extract, transform, load; ETL cannot handle high velocity, streaming, or unstructured data; warehouse = defined schema (star schema: fact table + product/customer/time/location dimensions); lake = no defined schema, everything in; lake house = cleaner hybrid; warehouse is structured, lake handles streaming
⚠️ Top pitfall: Calling the lake 'a cleaner version of a warehouse' — that is the lake house; an ungoverned lake becomes a data swamp
Self-check: You must load a high-velocity event stream. Why does classic ETL fail here, and which systems take over?
Connects to: 2.8, 2.13
Data Governance, Metadata, and Data Platforms
Must-know: Framework components: governance (overarching support via stewardship policies, processes, standards), architecture, metadata, data quality, lifecycle (aging and final deletion), analytics/visualization platform, privacy; data platform = suite with fast query processing, large storage, elastic computing, in-memory caches, massively parallel queries, column-level storage
⚠️ Top pitfall: Treating governance as bureaucracy instead of the rulebook; building a platform without metadata or stewardship
Self-check: List the seven components of the data management framework.
Connects to: 2.9, 2.10
Exam Guidance Summary
Must-know: All eight exam-intel bullets: quality check style, both model families, normal forms, binding/imputation, sensitivity statement, Colab exercise, OLTP vs OLAP and warehouse vs lake contrasts, framework components
⚠️ Top pitfall: Skipping the hands-on Colab exercise — it is part of the expected skills even without Python background
Self-check: Which four normal forms must you be ready to apply?
Connects to: 2.2, 2.3, 2.4, 2.11, 2.12, 2.13
Key Industry Applications
Must-know: One named application per concept: GPay/OLTP, Netflix asset, Neo4j/Neptune/Gephi graphs, DocumentDB/CouchDB/Firebase/Firestore documents, Redshift/Parquet columnar, MongoDB cluster, ICICI churn with DataStage/Informatica/Cognos, HIPAA/HL7/GDPR compliance, Hadoop big data
⚠️ Top pitfall: Confusing which company uses which technology family (e.g., graph databases for LinkedIn connectivity versus document stores for logs)
Self-check: Which three graph databases power connectivity and friend-of-friend recommendations?
Connects to: 2.4, 2.8, 2.9, 2.10, 2.12