1 CREATE VIEW community_view AS
2 with all_community AS (
11 c.creator_id = u.id) AS creator_name,
18 c.category_id = ct.id) AS category_name,
25 cf.community_id = c.id) AS number_of_subscribers,
32 p.community_id = c.id) AS number_of_posts,
41 AND p.id = co.post_id) AS number_of_comments
55 AND ac.id = cf.community_id) AS subscribed
58 CROSS JOIN all_community ac
67 CREATE VIEW community_moderator_view AS
76 cm.user_id = u.id) AS user_name,
83 cm.community_id = c.id) AS community_name
85 community_moderator cm;
87 CREATE VIEW community_follower_view AS
96 cf.user_id = u.id) AS user_name,
103 cf.community_id = c.id) AS community_name
105 community_follower cf;
107 CREATE VIEW community_user_ban_view AS
116 cm.user_id = u.id) AS user_name,
123 cm.community_id = c.id) AS community_name
125 community_user_ban cm;
127 CREATE VIEW site_view AS
136 s.creator_id = u.id) AS creator_name,
141 user_) AS number_of_users,
146 post) AS number_of_posts,
151 comment) AS number_of_comments