Update QUICK_REFERENCE.md for Phase 2 schema
- Rewrite Core Tables section for unified machines table - Update PC/Equipment/Network device identification queries - Add communications table (replaces pc_network_interfaces) - Update column names (address not ipaddress, machineid not pcid) - Update Important Views section with current views - Fix SQL query examples for new schema - Update file structure and resource references - Update database credentials 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# ShopDB Quick Reference Guide
|
# ShopDB Quick Reference Guide
|
||||||
|
|
||||||
**For:** New team members and quick lookups
|
**For:** New team members and quick lookups
|
||||||
**See Also:** DEEP_DIVE_REPORT.md (comprehensive), ASP_DEVELOPMENT_GUIDE.md (development), STANDARDS.md (coding standards)
|
**See Also:** ASP_DEVELOPMENT_GUIDE.md (development), STANDARDS.md (coding standards), API.md (REST API)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -31,66 +31,86 @@
|
|||||||
|
|
||||||
## Core Tables Cheat Sheet
|
## Core Tables Cheat Sheet
|
||||||
|
|
||||||
### PC Management
|
### Unified Machines Table (Phase 2 Schema)
|
||||||
```sql
|
```sql
|
||||||
-- Main PC table
|
-- ALL PCs, Equipment, and Network Devices are in one table
|
||||||
pc (pcid, hostname, serialnumber, pctypeid, machinenumber, modelnumberid, osid)
|
machines (machineid, hostname, serialnumber, alias, machinenumber,
|
||||||
|
machinetypeid, pctypeid, modelnumberid, osid, printerid,
|
||||||
|
loggedinuser, machinenotes, isactive, maptop, mapleft, lastupdated)
|
||||||
|
|
||||||
-- PC Types
|
-- Identify record type:
|
||||||
pctype (Standard, Engineer, Shopfloor, Server, Laptop, VM)
|
-- PCs: pctypeid IS NOT NULL (machinetypeid 33-35)
|
||||||
|
-- Equipment: pctypeid IS NULL AND machinetypeid < 16
|
||||||
-- PC Status
|
-- Network Devices: machinetypeid IN (16,17,18,19,20)
|
||||||
pcstatus (In Use, Spare, Retired, Broken, Unknown)
|
|
||||||
|
|
||||||
-- Network
|
|
||||||
pc_network_interfaces (pcid, ipaddress, subnetmask, macaddress, isdhcp)
|
|
||||||
|
|
||||||
-- Communication
|
|
||||||
pc_comm_config (pcid, configtype, portid, baud, databits, ipaddress)
|
|
||||||
|
|
||||||
-- DNC
|
|
||||||
pc_dnc_config (pcid, site, cnc, ncif, dualpath_enabled, path1_name, path2_name)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Machine Management
|
### PC-Related Tables
|
||||||
```sql
|
```sql
|
||||||
-- Machines
|
-- PC Types
|
||||||
machines (machineid, machinenumber, alias, machinetypeid, printerid, ipaddress1/2)
|
pctype (pctypeid, typename)
|
||||||
|
-- Values: Standard, Engineer, Shopfloor, CMM, Wax Trace, etc.
|
||||||
|
|
||||||
-- Machine Types
|
-- PC Communication Config (serial ports)
|
||||||
machinetypes (Vertical Lathe, Horizontal Lathe, 5-Axis Mill, CMM, Part Washer, etc.)
|
pc_comm_config (commconfigid, machineid, portname, baudrate, databits, parity, stopbits)
|
||||||
|
|
||||||
-- Installed Apps
|
-- PC DNC Config
|
||||||
installedapps (appid, machineid) -- Junction table
|
pc_dnc_config (dncconfigid, machineid, site, cnc, ncif, dualpath_enabled, path1_name, path2_name)
|
||||||
|
|
||||||
|
-- PC-to-Equipment Relationships
|
||||||
|
machinerelationships (relationshipid, machineid, related_machineid, relationshiptypeid)
|
||||||
|
-- relationshiptypeid 3 = "Controls" (PC controls equipment)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Network & Communications
|
||||||
|
```sql
|
||||||
|
-- All network interfaces (replaces pc_network_interfaces)
|
||||||
|
communications (comid, machineid, comstypeid, address, macaddress,
|
||||||
|
subnetmask, gateway, interfacename, isprimary, isactive)
|
||||||
|
-- comstypeid 1 = Network Interface
|
||||||
|
-- NOTE: Column is 'address' not 'ipaddress'
|
||||||
|
|
||||||
|
-- Subnets
|
||||||
|
subnets (subnetid, address, subnet, vlan, gateway, subnettypeid)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Equipment & Machine Types
|
||||||
|
```sql
|
||||||
|
-- Machine Types (machinetypeid ranges)
|
||||||
|
machinetypes (machinetypeid, machinetype)
|
||||||
|
-- 1-15: Equipment (Vertical Lathe, Mill, CMM, etc.)
|
||||||
|
-- 16-20: Network Devices (16=AP, 17=IDF, 18=Camera, 19=Switch, 20=Server)
|
||||||
|
-- 33-35: PC Types (Desktop, Laptop, Workstation)
|
||||||
|
|
||||||
|
-- Installed Apps on Equipment
|
||||||
|
installedapps (machineid, applicationid)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Applications & KB
|
### Applications & KB
|
||||||
```sql
|
```sql
|
||||||
-- Applications
|
-- Applications
|
||||||
applications (appid, appname, appdescription, supportteamid, isinstallable)
|
applications (applicationid, applicationname, appdescription, supportteamid)
|
||||||
|
|
||||||
-- Knowledge Base
|
-- Knowledge Base
|
||||||
knowledgebase (linkid, shortdescription, keywords, appid, linkurl, clicks)
|
knowledgebase (linkid, shortdescription, keywords, applicationid, linkurl, clicks)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Infrastructure
|
### Infrastructure
|
||||||
```sql
|
```sql
|
||||||
-- Printers
|
-- Printers (separate table, not in machines)
|
||||||
printers (printerid, printercsfname, modelid, serialnumber, ipaddress, fqdn, machineid)
|
printers (printerid, printercsfname, modelid, serialnumber, address, fqdn, isactive)
|
||||||
|
-- NOTE: Column is 'address' not 'ipaddress'
|
||||||
-- Subnets
|
|
||||||
subnets (subnetid, ipaddress, subnet, vlan, gateway, subnettypeid)
|
|
||||||
|
|
||||||
-- Notifications
|
-- Notifications
|
||||||
notifications (notificationid, notification, starttime, endtime, isactive)
|
notifications (notificationid, notification, starttime, endtime, isactive, notificationtypeid)
|
||||||
```
|
```
|
||||||
|
|
||||||
### Reference Data
|
### Reference Data
|
||||||
```sql
|
```sql
|
||||||
models (modelnumberid, modelnumber, vendorid)
|
models (modelnumberid, modelnumber, vendorid)
|
||||||
vendors (vendorid, vendor)
|
vendors (vendorid, vendor)
|
||||||
operatingsystems (osid, operatingsystem)
|
operatingsystems (osid, osname)
|
||||||
supportteams (supportteamid, supportteam)
|
supportteams (supportteamid, supportteam)
|
||||||
|
relationshiptypes (relationshiptypeid, relationshiptype)
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -99,25 +119,20 @@ supportteams (supportteamid, supportteam)
|
|||||||
|
|
||||||
```
|
```
|
||||||
shopdb/
|
shopdb/
|
||||||
├── *.asp # Main pages (91 files)
|
├── *.asp # Main pages
|
||||||
│ ├── default.asp # Dashboard
|
│ ├── default.asp # Dashboard
|
||||||
|
│ ├── api.asp # REST API endpoint
|
||||||
│ ├── search.asp # Unified search
|
│ ├── search.asp # Unified search
|
||||||
│ ├── calendar.asp # Notification calendar
|
|
||||||
│ ├── display*.asp # View pages
|
│ ├── display*.asp # View pages
|
||||||
│ ├── add*.asp # Create forms
|
│ ├── add*.asp # Create forms
|
||||||
│ ├── edit*.asp # Update forms
|
│ ├── edit*.asp # Update forms
|
||||||
│ ├── save*.asp # Backend processors
|
│ └── printerlookup.asp # Zabbix printer lookup
|
||||||
│ └── api_*.asp # JSON APIs
|
|
||||||
│
|
│
|
||||||
├── includes/ # Shared code
|
├── includes/ # Shared code
|
||||||
│ ├── sql.asp # DB connection
|
│ ├── sql.asp # DB connection
|
||||||
│ ├── header.asp # HTML head
|
│ ├── header.asp # HTML head
|
||||||
│ ├── leftsidebar.asp # Navigation
|
│ ├── leftsidebar.asp # Navigation
|
||||||
│ ├── topbarheader.asp # Top bar
|
│ └── topbarheader.asp # Top bar
|
||||||
│ ├── error_handler.asp # Error handling
|
|
||||||
│ ├── validation.asp # Input validation
|
|
||||||
│ ├── db_helpers.asp # DB utilities
|
|
||||||
│ └── data_cache.asp # Caching system
|
|
||||||
│
|
│
|
||||||
├── assets/ # Frontend resources
|
├── assets/ # Frontend resources
|
||||||
│ ├── css/ # Stylesheets
|
│ ├── css/ # Stylesheets
|
||||||
@@ -125,18 +140,16 @@ shopdb/
|
|||||||
│ ├── images/ # Icons, logos
|
│ ├── images/ # Icons, logos
|
||||||
│ └── plugins/ # Third-party libs
|
│ └── plugins/ # Third-party libs
|
||||||
│
|
│
|
||||||
├── images/ # Dashboard images
|
|
||||||
│ └── 1-9.jpg # Rotating images
|
|
||||||
│
|
|
||||||
├── sql/ # Database scripts
|
├── sql/ # Database scripts
|
||||||
│ └── database_updates_for_production.sql
|
│ ├── view_consolidation.sql # All database views
|
||||||
|
│ └── archive/ # Historical migrations
|
||||||
│
|
│
|
||||||
└── docs/ # Documentation
|
└── docs/ # Documentation
|
||||||
├── DEEP_DIVE_REPORT.md # Comprehensive guide
|
├── API.md # REST API docs
|
||||||
├── ASP_DEVELOPMENT_GUIDE.md # Dev setup
|
├── ASP_DEVELOPMENT_GUIDE.md # Dev setup
|
||||||
├── STANDARDS.md # Coding standards
|
├── STANDARDS.md # Coding standards
|
||||||
├── NESTED_ENTITY_CREATION.md # Complex forms
|
├── QUICK_REFERENCE.md # This file
|
||||||
└── QUICK_REFERENCE.md # This file
|
└── archive/ # Historical docs
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -154,16 +167,16 @@ curl http://192.168.122.151:8080 # Test
|
|||||||
### Database Access
|
### Database Access
|
||||||
```bash
|
```bash
|
||||||
# Connect to MySQL
|
# Connect to MySQL
|
||||||
docker exec -it dev-mysql mysql -u 570005354 -p570005354 shopdb
|
docker exec -it dev-mysql mysql -u root -prootpassword shopdb
|
||||||
|
|
||||||
# Backup database
|
# Backup database
|
||||||
docker exec dev-mysql mysqldump -u 570005354 -p570005354 shopdb > backup.sql
|
docker exec dev-mysql mysqldump -u root -prootpassword shopdb > backup.sql
|
||||||
|
|
||||||
# Restore database
|
# Restore database
|
||||||
docker exec -i dev-mysql mysql -u 570005354 -p570005354 shopdb < backup.sql
|
docker exec -i dev-mysql mysql -u root -prootpassword shopdb < backup.sql
|
||||||
|
|
||||||
# Check table counts
|
# Check table counts
|
||||||
docker exec dev-mysql mysql -u 570005354 -p570005354 shopdb \
|
docker exec dev-mysql mysql -u root -prootpassword shopdb \
|
||||||
-e "SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema='shopdb' ORDER BY table_rows DESC;"
|
-e "SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema='shopdb' ORDER BY table_rows DESC;"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -301,26 +314,39 @@ End If
|
|||||||
|
|
||||||
## Important Views to Know
|
## Important Views to Know
|
||||||
|
|
||||||
### PC-Related Views
|
All views defined in `sql/view_consolidation.sql`
|
||||||
- `vw_shopfloor_pcs` - Shopfloor PCs with machine assignments
|
|
||||||
- `vw_active_pcs` - PCs updated in last 30 days
|
### Display Page Views
|
||||||
- `vw_pc_summary` - Overall PC inventory
|
- `vw_equipment_list` - Equipment for displaymachines.asp
|
||||||
- `vw_pc_network_summary` - Network configuration overview
|
- `vw_pc_list` - PCs for displaypcs.asp
|
||||||
|
- `vw_printer_list` - Printers for displayprinters.asp
|
||||||
|
- `vw_machine_detail` - Full details for detail pages
|
||||||
|
- `vw_network_devices` - Network devices (APs, switches, etc.)
|
||||||
|
|
||||||
|
### Map Views
|
||||||
|
- `vw_map_equipment` - Equipment with map positions
|
||||||
|
- `vw_map_printers` - Printers with map positions
|
||||||
|
- `vw_map_network_devices` - Network devices on map
|
||||||
|
- `vw_network_map_devices` - Combined printers + network devices
|
||||||
|
|
||||||
|
### Relationship Views
|
||||||
|
- `vw_equipment_pc_relationships` - PC-to-equipment links
|
||||||
|
- `vw_machine_relationships` - All machine relationships
|
||||||
|
|
||||||
|
### Summary Views
|
||||||
- `vw_warranty_status` - Warranty tracking
|
- `vw_warranty_status` - Warranty tracking
|
||||||
- `vw_warranties_expiring` - Expiring in next 90 days
|
- `vw_warranty_summary` - Warranty stats by status
|
||||||
|
- `vw_pctype_summary` - Counts by PC type
|
||||||
|
- `vw_equipment_type_summary` - Counts by equipment type
|
||||||
|
|
||||||
### Machine-Related Views
|
### Notification Views
|
||||||
- `vw_machine_assignments` - PC-to-machine relationships
|
- `vw_active_notifications` - Current/recent notifications
|
||||||
- `vw_machine_type_stats` - Counts by machine type
|
- `vw_upcoming_notifications` - Scheduled notifications
|
||||||
- `vw_multi_pc_machines` - Machines with multiple PCs
|
|
||||||
- `vw_unmapped_machines` - Missing map coordinates
|
|
||||||
- `vw_dualpath_management` - DualPath CNCs
|
|
||||||
|
|
||||||
### Reporting Views
|
### Application Views
|
||||||
- `vw_vendor_summary` - PC counts by manufacturer
|
- `vw_applications_list` - Apps with KB counts
|
||||||
- `vw_pcs_by_hardware` - Hardware distribution
|
- `vw_knowledge_base` - KB articles with app info
|
||||||
- `vw_pctype_config` - Configuration by PC type
|
- `vw_installed_apps_summary` - App installation stats
|
||||||
- `vw_recent_updates` - Recent changes
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -330,8 +356,8 @@ End If
|
|||||||
- Host: 192.168.122.1 (from Windows VM)
|
- Host: 192.168.122.1 (from Windows VM)
|
||||||
- Port: 3306
|
- Port: 3306
|
||||||
- Database: shopdb
|
- Database: shopdb
|
||||||
- User: 570005354
|
- User: root
|
||||||
- Password: 570005354
|
- Password: rootpassword
|
||||||
|
|
||||||
**Production Database:**
|
**Production Database:**
|
||||||
- See production server documentation (credentials secured)
|
- See production server documentation (credentials secured)
|
||||||
@@ -387,51 +413,70 @@ Before deploying code, verify:
|
|||||||
|
|
||||||
## Useful SQL Queries
|
## Useful SQL Queries
|
||||||
|
|
||||||
### Find PCs by Machine Number
|
### Get All PCs
|
||||||
```sql
|
```sql
|
||||||
SELECT p.hostname, p.serialnumber, p.machinenumber, pt.typename
|
SELECT m.machineid, m.hostname, m.serialnumber, pt.typename AS pctype
|
||||||
FROM pc p
|
FROM machines m
|
||||||
JOIN pctype pt ON p.pctypeid = pt.pctypeid
|
JOIN pctype pt ON m.pctypeid = pt.pctypeid
|
||||||
WHERE p.machinenumber = '3104'
|
WHERE m.pctypeid IS NOT NULL AND m.isactive = 1
|
||||||
AND p.isactive = 1;
|
ORDER BY m.hostname;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Machines Without Assigned PCs
|
### Get All Equipment
|
||||||
```sql
|
```sql
|
||||||
SELECT m.machinenumber, m.alias, mt.machinetype
|
SELECT m.machineid, m.machinenumber, m.alias, mt.machinetype
|
||||||
FROM machines m
|
FROM machines m
|
||||||
LEFT JOIN pc p ON p.machinenumber = m.machinenumber AND p.isactive = 1
|
|
||||||
JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid
|
JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid
|
||||||
WHERE p.pcid IS NULL
|
WHERE m.pctypeid IS NULL AND m.machinetypeid < 16 AND m.isactive = 1
|
||||||
AND m.isactive = 1
|
ORDER BY m.machinenumber;
|
||||||
AND m.islocationonly = 0;
|
```
|
||||||
|
|
||||||
|
### Get Network Devices
|
||||||
|
```sql
|
||||||
|
SELECT m.machineid, m.alias, mt.machinetype, c.address
|
||||||
|
FROM machines m
|
||||||
|
JOIN machinetypes mt ON m.machinetypeid = mt.machinetypeid
|
||||||
|
LEFT JOIN communications c ON m.machineid = c.machineid AND c.isprimary = 1
|
||||||
|
WHERE m.machinetypeid IN (16,17,18,19,20) AND m.isactive = 1;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Find PC by Hostname with IP
|
||||||
|
```sql
|
||||||
|
SELECT m.hostname, m.serialnumber, c.address AS ipaddress, pt.typename
|
||||||
|
FROM machines m
|
||||||
|
JOIN pctype pt ON m.pctypeid = pt.pctypeid
|
||||||
|
LEFT JOIN communications c ON m.machineid = c.machineid AND c.isprimary = 1
|
||||||
|
WHERE m.hostname = 'PC-NAME' AND m.pctypeid IS NOT NULL;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Equipment with Controlling PCs
|
||||||
|
```sql
|
||||||
|
SELECT
|
||||||
|
equipment.machinenumber AS equipment,
|
||||||
|
equipment.alias,
|
||||||
|
pc.hostname AS controlling_pc
|
||||||
|
FROM machinerelationships mr
|
||||||
|
JOIN machines equipment ON mr.machineid = equipment.machineid
|
||||||
|
JOIN machines pc ON mr.related_machineid = pc.machineid
|
||||||
|
WHERE mr.relationshiptypeid = 3 AND mr.isactive = 1;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Most Clicked KB Articles
|
### Most Clicked KB Articles
|
||||||
```sql
|
```sql
|
||||||
SELECT k.shortdescription, a.appname, k.clicks, k.linkurl
|
SELECT k.shortdescription, a.applicationname, k.clicks, k.linkurl
|
||||||
FROM knowledgebase k
|
FROM knowledgebase k
|
||||||
JOIN applications a ON k.appid = a.appid
|
JOIN applications a ON k.applicationid = a.applicationid
|
||||||
WHERE k.isactive = 1
|
WHERE k.isactive = 1
|
||||||
ORDER BY k.clicks DESC
|
ORDER BY k.clicks DESC
|
||||||
LIMIT 20;
|
LIMIT 20;
|
||||||
```
|
```
|
||||||
|
|
||||||
### Warranties Expiring This Month
|
|
||||||
```sql
|
|
||||||
SELECT hostname, serialnumber, warrantyenddate, warrantydaysremaining
|
|
||||||
FROM vw_warranties_expiring
|
|
||||||
WHERE warrantyenddate BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 30 DAY)
|
|
||||||
ORDER BY warrantyenddate;
|
|
||||||
```
|
|
||||||
|
|
||||||
### DualPath PCs
|
### DualPath PCs
|
||||||
```sql
|
```sql
|
||||||
SELECT p.hostname, d.primary_machine, d.secondary_machine, dnc.dualpath_enabled
|
SELECT m.hostname, dnc.dualpath_enabled, dnc.path1_name, dnc.path2_name
|
||||||
FROM pc p
|
FROM machines m
|
||||||
JOIN pc_dualpath_assignments d ON p.pcid = d.pcid
|
JOIN pc_dnc_config dnc ON m.machineid = dnc.machineid
|
||||||
JOIN pc_dnc_config dnc ON p.pcid = dnc.pcid
|
WHERE dnc.dualpath_enabled = 1 AND m.pctypeid IS NOT NULL;
|
||||||
WHERE dnc.dualpath_enabled = 1;
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -439,10 +484,10 @@ WHERE dnc.dualpath_enabled = 1;
|
|||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
- **Comprehensive Guide:** docs/DEEP_DIVE_REPORT.md
|
- **REST API:** docs/API.md
|
||||||
- **Development Setup:** docs/ASP_DEVELOPMENT_GUIDE.md
|
- **Development Setup:** docs/ASP_DEVELOPMENT_GUIDE.md
|
||||||
- **Coding Standards:** docs/STANDARDS.md
|
- **Coding Standards:** docs/STANDARDS.md
|
||||||
- **Complex Forms:** docs/NESTED_ENTITY_CREATION.md
|
- **Project Context:** CLAUDE.md
|
||||||
|
|
||||||
### External Links
|
### External Links
|
||||||
- **Classic ASP Reference:** https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525334(v=vs.90)
|
- **Classic ASP Reference:** https://learn.microsoft.com/en-us/previous-versions/iis/6.0-sdk/ms525334(v=vs.90)
|
||||||
@@ -496,6 +541,6 @@ WHERE dnc.dualpath_enabled = 1;
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Last Updated:** 2025-10-20
|
**Last Updated:** 2025-12-11
|
||||||
**Maintained By:** Development Team
|
**Maintained By:** Development Team
|
||||||
**Review:** Update when major changes occur
|
**Schema:** Phase 2 (unified machines table)
|
||||||
|
|||||||
Reference in New Issue
Block a user