CREATE VIEW rssd_table_statistic AS
SELECT
m.name AS table_name,
(SELECT COUNT(*) FROM pragma_table_info(m.name)) AS total_columns,
(SELECT COUNT(*) FROM pragma_index_list(m.name)) AS total_indexes,
(SELECT COUNT(*) FROM pragma_foreign_key_list(m.name)) AS foreign_keys,
(SELECT COUNT(*) FROM pragma_table_info(m.name) WHERE pk != 0) AS primary_keys,
(SELECT table_size_mb FROM surveilr_table_size WHERE table_name = m.name) AS table_size_mb
FROM sqlite_master m
WHERE m.type = 'table'