Data Access & Delivery
Data access and delivery is the whole point of what we’re trying to do here. Making data available could mean that it’s able to power analytics, like a BI tool, or maybe serve machine learning models in production.
This Lesson Will Cover
- 🔗 Data Access & Delivery through APIs
- 🏢 Data Warehouses and their characteristics
- 🔐 Data Access Controls and Security
- 🛡️ Implementation of security measures
- 🌍 Real-world examples of data delivery systems
API Integration
What Is an API?
An API (Application Programming Interface) allows applications to interact with data programmatically.
For example, APIs can deliver data to machine learning models and return the predicted response.
REST APIs use HTTP protocols to deliver data in JSON or XML format. Ideal for lightweight, stateless communication.
Example: Using an API to Access Data
Imagine an API endpoint for accessing customer metrics:
Endpoint: GET /api/customer_summary
Response:
{
"CustomerID": 123,
"Name": "Jane Doe",
"TotalSpent": 500.75,
"TotalOrders": 8
}
This endpoint can be consumed by services like frontend applications or AI pipelines.
If the source data is available in a MySQL database, then a FastAPI backend for this API could look something like this:
from fastapi import FastAPI, HTTPException
from sqlalchemy import create_engine
from pydantic import BaseModel
import os
app = FastAPI()
# Database connection
DB_URL = os.getenv("DATABASE_URL", "mysql://user:pass@localhost/db")
engine = create_engine(DB_URL)
class CustomerSummary(BaseModel):
CustomerID: int
Name: str
TotalSpent: float
TotalOrders: int
@app.get("/api/customer_summary/{customer_id}", response_model=CustomerSummary)
async def get_customer_summary(customer_id: int):
query = """
SELECT
c.customer_id as CustomerID,
c.name as Name,
SUM(o.total_amount) as TotalSpent,
COUNT(o.order_id) as TotalOrders
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE c.customer_id = :customer_id
GROUP BY c.customer_id, c.name
"""
try:
with engine.connect() as conn:
result = conn.execute(query, {"customer_id": customer_id}).first()
if not result:
raise HTTPException(status_code=404, detail="Customer not found")
return CustomerSummary(
CustomerID=result.CustomerID,
Name=result.Name,
TotalSpent=result.TotalSpent,
TotalOrders=result.TotalOrders
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
Data Warehouses
What Is a Data Warehouse?
A data warehouse is a centralized repository designed for fast query performance on structured data. It integrates data from multiple sources and organizes it into schemas optimized for analysis.
Key Characteristics
- Columnar Storage: Data warehouses use columnar storage for efficient analytical queries.
- Optimized for OLAP: Designed for OLAP (Online Analytical Processing), enabling complex queries on large datasets.
- Batch and Real-Time Support: Supports both historical batch data and real-time data ingestion.
Popular Tools
- Cloud Solutions: Snowflake, Google BigQuery, Amazon Redshift.
- On-Premise: Apache Hive, Microsoft SQL Server.
Example Use Case
Imagine an AI team building a recommendation engine.
They need quick access to:
- Historical sales
- User interactions
- Product details
Having these data sources available in a centralized data warehouse would allow for quick experimentation of feature extraction for model training.
Data Access Controls: Ensuring Security and Compliance
Why Are Access Controls Important?
Data access controls ensure that only authorized users or applications can access specific datasets.
This is necessary for obvious reasons—like protecting sensitive information and complying with regulations (e.g. GDPR).
It’s so important that it’s actually a full-time job[1], e.g.
- Data Security Engineer: Focuses on implementing and maintaining data security controls
- Data Compliance Officer: Ensures data handling meets regulatory requirements
- Data Privacy Manager: Oversees data privacy policies and procedures
- Access Control Administrator: Manages user permissions and access rights
- Data Governance Manager: Develops and enforces data access policies
Common Access Control Mechanisms
-
Role-Based Access Control:
- Assign permissions based on roles (e.g., admin, analyst, viewer).
- Example: Only data engineers can access raw data; analysts access pre-aggregated views.
- Typically implemented through IAM (Identity and Access Management) systems.
-
Row-Level Security:
- Restrict access to specific rows in a table based on user attributes.
- Example: A sales manager can only view data for their region.
- Often combined with IAM policies for granular control.
-
Column-Level Security:
- Control access to specific columns within tables.
- Example: Masking sensitive PII data for certain user roles.
- Often implemented through database views and IAM policies.
-
Attribute-Based Access Control:
- Dynamic permissions based on user attributes and context.
- Considers factors like time, location, device, and security clearance.
- Flexible but complex to implement.
Identity and Access Management (IAM)
- Centralized system for managing digital identities and access rights.
- Provides authentication (who you are) and authorization (what you can do).
- Features include:
- SSO (Single Sign-On) integration
- Multi-Factor Authentication (MFA)
- Audit logging and compliance reporting
- Policy management and enforcement
- Popular solutions: AWS IAM, Google Cloud IAM, Azure Active Directory.
Common Security Considerations for Data Delivery
-
Data Encryption:
- In Transit: Use TLS/SSL for API communications and data transfers
- At Rest: Encrypt stored data using industry-standard algorithms
- Key Management: Implement secure key rotation and storage practices
-
API Security:
- Authentication: Require API keys or OAuth tokens
- Rate Limiting: Prevent abuse through request throttling
- Input Validation: Sanitize all incoming data
- HTTPS Only: Enforce secure connections
- API Versioning: Maintain backward compatibility securely
-
Network Security:
- Firewalls: Restrict access to specific IP ranges
- VPNs: Secure remote access to data resources
- Network Segmentation: Isolate sensitive data systems
- Load Balancing: Distribute traffic securely
-
Monitoring and Logging:
- Access Logs: Track all data access attempts
- Audit Trails: Maintain detailed activity records
- Alerting: Set up notifications for suspicious activities
- Regular Reviews: Analyze security logs periodically
-
Compliance Requirements:
- Data Residency: Store data in approved geographic locations
- Data Retention: Follow required retention periods
- Privacy Laws: Adhere to GDPR, CCPA, and other regulations
- Industry Standards: Maintain compliance with SOC 2, HIPAA, etc.
-
Error Handling:
- Secure Error Messages: Avoid exposing sensitive information
- Graceful Failures: Handle errors without compromising security
- Logging: Record errors for analysis without exposing sensitive data
-
Access Management:
- Principle of Least Privilege: Grant minimal required access
- Regular Reviews: Audit access permissions periodically
- Automated Provisioning: Standardize access management
- Deprovisioning: Quick removal of access when needed
Real-World Workflow: Controlled Access for AI Teams
Here’s an example that illustrates more concretely how difficult data access can be.
Imagine your AI team needs transaction data to build fraud detection models, but customer personal information (PII) must remain restricted.
Solution Architecture:
-
Database Access Layer:
- Create masked database views that hash/anonymize PII fields.
- Implement row-level security based on team roles.
- Set up column-level encryption for sensitive fields.
- Configure geographic data residency rules.
-
API Security:
- Use HTTPS for all communications.
- Deploy behind API gateway with rate limiting.
- Implement request validation and sanitization.
- Set up allowed IPs for specific environments.
-
Monitoring & Compliance:
- Track all data access in audit logs.
- Set up real-time alerts for suspicious patterns.
- Generate automated compliance reports.
- Maintain audit trails for regulatory requirements.
Implementation Example:
-- Create secure view for AI team
CREATE VIEW ai_fraud_detection AS
SELECT
SHA256(customer_id) as hashed_customer_id,
transaction_date,
amount,
merchant_category,
CASE
WHEN is_authorized_ai_user() THEN zip_code
ELSE NULL
END as location_data,
fraud_flag
FROM transactions
WHERE current_role() IN ('AI_RESEARCHER', 'DATA_SCIENTIST')
AND transaction_date >= DATEADD(month, -12, CURRENT_DATE());
- Data Governance:
- Document all data access patterns
- Regular access reviews every 90 days
- Data retention policies enforcement
- Privacy impact assessments
Conclusion
Considering that last example, it’s no wonder there’s so much “red tape” around all these data projects that we’re trying to get done.
And luckily, there are people willing to make a career out of handling that red tape for us, so that we can build cool stuff. Or maybe you’re one of those people. God bless you!
Key Takeaways
🔌 APIs provide programmatic access to data, enabling integration with various applications and services.
🏢 Data warehouses centralize and optimize data for analytical queries and complex data processing.
🔒 Security and access controls are critical components of data delivery systems.
📜 Proper data governance and compliance frameworks are essential for managing data access.
⚖️ Real-world data delivery systems need to balance accessibility with security requirements.
Next: Databases
Next up are databases.
YES, we’ve already talked about them a bit.
NO, you can never talk about databases enough.
They are seriously so cool.
Footnotes
I covered this category of jobs (data regulation) in my Data Jobs in 2025 YouTube video. ↩︎
Comments (0)
No comments yet.