1.9 KiB
1.9 KiB
SQLite Storage Adapter Schema Documentation
Tables Overview
1. storage (Primary Data Storage)
key_hash(TEXT, PRIMARY KEY): SHA-256 hash of the storage keyencrypted_value(BLOB): AES-256 encrypted data valuecreated_at(TIMESTAMP): When record was first createdupdated_at(TIMESTAMP): When record was last modifiedcreated_by(TEXT): User ID who created the record
2. access_log (Audit Trail)
id(INTEGER, PRIMARY KEY): Auto-incrementing log IDkey_hash(TEXT): Reference to storage.key_hashoperation(TEXT): CRUD operation performeduser_id(TEXT): Who performed the operationtimestamp(TIMESTAMP): When operation occurred
3. performance_metrics (New in v1.2)
id(INTEGER, PRIMARY KEY): Auto-incrementing metric IDoperation(TEXT): CRUD operation typeexecution_time_ms(INTEGER): Operation duration in millisecondstimestamp(TIMESTAMP): When operation occurreduser_id(TEXT): Who performed the operationkey_hash(TEXT): Optional reference to storage.key_hash
Relationships
erDiagram
storage ||--o{ access_log : "1:N"
storage ||--o{ performance_metrics : "1:N"
Example Queries
Get Slow Operations (>500ms)
SELECT operation, execution_time_ms, user_id
FROM performance_metrics
WHERE execution_time_ms > 500
ORDER BY execution_time_ms DESC;
Average Operation Times by Type
SELECT
operation,
AVG(execution_time_ms) as avg_time,
COUNT(*) as operation_count
FROM performance_metrics
GROUP BY operation;
Performance Metrics with Storage Metadata
SELECT
pm.operation,
pm.execution_time_ms,
s.created_at,
s.updated_at
FROM performance_metrics pm
LEFT JOIN storage s ON pm.key_hash = s.key_hash;
Version History
- v1.0: Initial schema (storage + access_log)
- v1.1: Added RBAC constraints
- v1.2: Added performance_metrics table