A kalmo (view) shi ne tambaya da aka ajiye wacce ke aiki kamar teburin rufe — kana buguwar ta kamar teburi, amma kana gudawar da tambayan da ke karkashi kowane lokaci. A kalmo masu aiki (materialized view) yana ajiye sakamakon tambayan sakamakon da aka gida (ana sake sabunta sauran lokuta), gina juyayi na sarkakiya don saurin karantawa.{{LINEBREAK}}{{LINEBREAK}}## Kalmon na yau-a-ran — tambaya da aka ajiye{{LINEBREAK}}{{LINEBREAK}}```sql -- define a view CREATE VIEW active_users AS SELECT id, name, email FROM users WHERE active = true;
-- query it like a table — it runs the underlying SELECT each time SELECT * FROM active_users WHERE name LIKE 'A%'; text ✓ SIMPLIFY complex queries — encapsulate a complex JOIN/aggregation as a named view ✓ ABSTRACTION — present a clean, stable interface; hide underlying table complexity ✓ SECURITY — grant access to a view exposing only certain columns/rows (hide the rest) ✓ REUSABILITY — define common query logic once, reuse it everywhere ✓ Consistency — everyone uses the same definition of "active_users" sql -- stores the RESULTS physically (precomputed) for fast reads CREATE MATERIALIZED VIEW monthly_sales AS SELECT month, SUM(amount) AS total FROM orders GROUP BY month;
