Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:29:10 +08:00
commit 657f1e3da3
29 changed files with 2738 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
# Database Conventions Reference Index
- **[field-naming.md](field-naming.md)** - Complete naming conventions
- **[indexing.md](indexing.md)** - Index patterns and strategies
- **[relationships.md](relationships.md)** - Foreign keys and relations

View File

@@ -0,0 +1,7 @@
# Field Naming Conventions
**Boolean:** `is_active`, `has_access`, `can_edit`
**Timestamp:** `created_at`, `updated_at`, `deleted_at`
**Foreign Key:** `user_id`, `tenant_id`, `organization_id`
**Email:** `email_address` (not `email`)
**Phone:** `phone_number` (not `phone`)

View File

@@ -0,0 +1,12 @@
# Indexing Strategies
**Always index:**
- tenant_id
- Foreign keys
- Unique constraints
- Frequently queried fields
**Composite indexes:**
```typescript
index("users_tenant_email_idx").on(users.tenant_id, users.email_address)
```

View File

@@ -0,0 +1,7 @@
# Relationships Guide
**One-to-Many:** User has many Posts
**Many-to-One:** Post belongs to User
**Many-to-Many:** User has many Roles through UserRoles
See examples for complete patterns.