Proje: Okul Database · Hub: Okul Database — Tables

school_interactions Tablosu

CRM aktivite logu. Her müşteri-okul teması kaydedilir.


Kolonlar

KolonTipAçıklama
idbigint PK
school_idFKschools
campus_idFK nullablecampuses
customer_idFKcustomers
customer_user_idFKcustomer_users
typevarcharİnteraksiyon tipi (call, email, meeting…)
is_latesttinyintBu okul için son interaction mı
notetext nullableİnteraksiyon notu
interacted_attimestampİnteraksiyon zamanı
created_attimestamp
deleted_attimestampSoft delete

Index Stratejisi

8 compound index var — temporal ve kategorik sorgular için optimize edilmiş:

(is_latest, deleted_at, school_id, created_at)
(school_id, campus_id, customer_id, is_latest)
... vb.

is_latest Kullanımı

-- Her okulun son interaction'ı
SELECT * FROM school_interactions
WHERE is_latest = 1 AND deleted_at IS NULL;
 
-- Belirli bir okul için tüm interaction geçmişi
SELECT * FROM school_interactions
WHERE school_id = ? AND deleted_at IS NULL
ORDER BY interacted_at DESC;