|
| 1 | +# 13 - Enterprise Sample Schemas (MSSQL + Orion + DPA) |
| 2 | +Home: [README](./README.md) |
| 3 | + |
| 4 | +These sample schemas are templates for your learning projects and capstones. |
| 5 | +Adjust names and data types for your production standards. |
| 6 | + |
| 7 | +## Schema conventions |
| 8 | +- Use UTC timestamps. |
| 9 | +- Keep source-system metadata in each table. |
| 10 | +- Add unique keys for idempotent loads. |
| 11 | +- Separate raw staging from curated reporting tables. |
| 12 | + |
| 13 | +## Example: staging table for Excel ingest |
| 14 | +```sql |
| 15 | +CREATE TABLE dbo.staging_alerts ( |
| 16 | + staging_id BIGINT IDENTITY(1,1) PRIMARY KEY, |
| 17 | + load_batch_id UNIQUEIDENTIFIER NOT NULL, |
| 18 | + source_file NVARCHAR(260) NOT NULL, |
| 19 | + source_row_num INT NULL, |
| 20 | + customer_name NVARCHAR(200) NULL, |
| 21 | + site_name NVARCHAR(200) NULL, |
| 22 | + ticket_id NVARCHAR(100) NULL, |
| 23 | + status_text NVARCHAR(100) NULL, |
| 24 | + opened_at_raw NVARCHAR(100) NULL, |
| 25 | + payload_hash CHAR(64) NOT NULL, |
| 26 | + ingested_at_utc DATETIME2(0) NOT NULL, |
| 27 | + ingest_error NVARCHAR(500) NULL |
| 28 | +); |
| 29 | +``` |
| 30 | + |
| 31 | +## Example: curated reporting table |
| 32 | +```sql |
| 33 | +CREATE TABLE dbo.alerts_reporting ( |
| 34 | + alert_id BIGINT IDENTITY(1,1) PRIMARY KEY, |
| 35 | + idempotency_key CHAR(64) NOT NULL UNIQUE, |
| 36 | + customer_name NVARCHAR(200) NOT NULL, |
| 37 | + site_name NVARCHAR(200) NOT NULL, |
| 38 | + ticket_id NVARCHAR(100) NOT NULL, |
| 39 | + severity NVARCHAR(50) NOT NULL, |
| 40 | + opened_at_utc DATETIME2(0) NOT NULL, |
| 41 | + source_system NVARCHAR(50) NOT NULL, |
| 42 | + source_entity_key NVARCHAR(200) NULL, |
| 43 | + collected_at_utc DATETIME2(0) NOT NULL, |
| 44 | + loaded_at_utc DATETIME2(0) NOT NULL |
| 45 | +); |
| 46 | +``` |
| 47 | + |
| 48 | +## Example: Orion cache table |
| 49 | +```sql |
| 50 | +CREATE TABLE dbo.cache_orion_alerts ( |
| 51 | + cache_id BIGINT IDENTITY(1,1) PRIMARY KEY, |
| 52 | + source_system NVARCHAR(20) NOT NULL DEFAULT 'orion', |
| 53 | + entity_key NVARCHAR(200) NOT NULL, |
| 54 | + alert_name NVARCHAR(300) NULL, |
| 55 | + severity NVARCHAR(50) NULL, |
| 56 | + node_caption NVARCHAR(300) NULL, |
| 57 | + is_active BIT NOT NULL, |
| 58 | + payload_hash CHAR(64) NOT NULL, |
| 59 | + collected_at_utc DATETIME2(0) NOT NULL, |
| 60 | + UNIQUE (source_system, entity_key, collected_at_utc) |
| 61 | +); |
| 62 | +``` |
| 63 | + |
| 64 | +## Example: DPA cache table |
| 65 | +```sql |
| 66 | +CREATE TABLE dbo.cache_dpa_instances ( |
| 67 | + cache_id BIGINT IDENTITY(1,1) PRIMARY KEY, |
| 68 | + source_system NVARCHAR(20) NOT NULL DEFAULT 'dpa', |
| 69 | + entity_key NVARCHAR(200) NOT NULL, |
| 70 | + instance_name NVARCHAR(300) NULL, |
| 71 | + health_status NVARCHAR(100) NULL, |
| 72 | + wait_category NVARCHAR(200) NULL, |
| 73 | + payload_hash CHAR(64) NOT NULL, |
| 74 | + collected_at_utc DATETIME2(0) NOT NULL, |
| 75 | + UNIQUE (source_system, entity_key, collected_at_utc) |
| 76 | +); |
| 77 | +``` |
| 78 | + |
| 79 | +## Example: dashboard mart view |
| 80 | +```sql |
| 81 | +CREATE VIEW dbo.vw_ops_dashboard_daily AS |
| 82 | +SELECT |
| 83 | + CAST(collected_at_utc AS DATE) AS snapshot_date, |
| 84 | + severity, |
| 85 | + COUNT(*) AS alert_count |
| 86 | +FROM dbo.cache_orion_alerts |
| 87 | +WHERE is_active = 1 |
| 88 | +GROUP BY CAST(collected_at_utc AS DATE), severity; |
| 89 | +``` |
| 90 | + |
| 91 | +## Example index strategy |
| 92 | +```sql |
| 93 | +CREATE INDEX IX_alerts_reporting_opened_severity |
| 94 | +ON dbo.alerts_reporting (opened_at_utc, severity); |
| 95 | + |
| 96 | +CREATE INDEX IX_cache_orion_alerts_collected |
| 97 | +ON dbo.cache_orion_alerts (collected_at_utc); |
| 98 | + |
| 99 | +CREATE INDEX IX_cache_dpa_instances_collected |
| 100 | +ON dbo.cache_dpa_instances (collected_at_utc); |
| 101 | +``` |
| 102 | + |
| 103 | +## Data governance notes |
| 104 | +- Prefer service accounts over personal credentials for scheduled jobs. |
| 105 | +- Log source endpoint and load batch for auditability. |
| 106 | +- Mask or exclude sensitive payload fields before persistence. |
| 107 | +- Validate schema drift and alert on missing critical fields. |
| 108 | + |
| 109 | +## Primary Sources |
| 110 | +- [SQL Server Python drivers overview](https://learn.microsoft.com/en-gb/sql/connect/python/python-driver-for-sql-server) |
| 111 | +- [MSSQL Python quickstart](https://learn.microsoft.com/en-us/sql/connect/python/mssql-python/python-sql-driver-mssql-python-quickstart?view=sql-server-ver17) |
| 112 | +- [ODBC connection string keywords](https://learn.microsoft.com/en-us/sql/connect/odbc/dsn-connection-string-attribute?view=sql-server-ver17) |
| 113 | +- [OrionSDK](https://github.com/solarwinds/OrionSDK) |
| 114 | +- [DPA API docs](https://documentation.solarwinds.com/en/success_center/dpa/content/dpa-use-the-api.htm) |
| 115 | + |
| 116 | +## Optional Resources |
| 117 | +- [SQLAlchemy tutorial](https://docs.sqlalchemy.org/en/20/tutorial/index.html) |
| 118 | +- [python-oracledb docs](https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html) |
| 119 | + |
| 120 | +## Next |
| 121 | +Go to [14_NAVIGATION_AND_STUDY_WORKFLOW.md](./14_NAVIGATION_AND_STUDY_WORKFLOW.md). |
0 commit comments