-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.sql
More file actions
83 lines (78 loc) · 2.46 KB
/
views.sql
File metadata and controls
83 lines (78 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-- VIEWS
-- VIEW HIGH PRIORITY TASKS
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `v_high_priority_tasks` AS
SELECT
`t`.`id_task` AS `id_task`,
`t`.`title` AS `title`,
`t`.`description` AS `description`,
`t`.`limit_date` AS `limit_date`,
`u`.`username` AS `user`,
`c`.`name` AS `category`
FROM
((`tasks` `t`
LEFT JOIN `users` `u` ON ((`t`.`id_user` = `u`.`id_user`)))
LEFT JOIN `categories` `c` ON ((`t`.`id_category` = `c`.`id_category`)))
WHERE
(`t`.`priority` = 'high');
-- VIEW OVERDUE TASKS
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `v_overdue_tasks` AS
SELECT
`t`.`id_task` AS `id_task`,
`t`.`title` AS `title`,
`t`.`description` AS `description`,
`t`.`limit_date` AS `limit_date`,
`u`.`username` AS `user`,
`c`.`name` AS `category`
FROM
((`tasks` `t`
LEFT JOIN `users` `u` ON ((`t`.`id_user` = `u`.`id_user`)))
LEFT JOIN `categories` `c` ON ((`t`.`id_category` = `c`.`id_category`)))
WHERE
((`t`.`state` = 'pending')
AND (`t`.`limit_date` < NOW()));
-- VIEW PENDING TASKS
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `v_pending_tasks` AS
SELECT
`t`.`id_task` AS `id_task`,
`t`.`title` AS `title`,
`t`.`description` AS `description`,
`t`.`limit_date` AS `limit_date`,
`t`.`priority` AS `priority`,
`u`.`username` AS `user`,
`c`.`name` AS `category`
FROM
((`tasks` `t`
LEFT JOIN `users` `u` ON ((`t`.`id_user` = `u`.`id_user`)))
LEFT JOIN `categories` `c` ON ((`t`.`id_category` = `c`.`id_category`)))
WHERE
(`t`.`state` = 'pending');
-- VIEW TASKS BY USER
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`@`localhost`
SQL SECURITY DEFINER
VIEW `v_tasks_by_user` AS
SELECT
`t`.`id_task` AS `id_task`,
`t`.`title` AS `title`,
`t`.`state` AS `state`,
`t`.`priority` AS `priority`,
`t`.`limit_date` AS `limit_date`,
`u`.`username` AS `user`,
`c`.`name` AS `category`
FROM
((`tasks` `t`
LEFT JOIN `users` `u` ON ((`t`.`id_user` = `u`.`id_user`)))
LEFT JOIN `categories` `c` ON ((`t`.`id_category` = `c`.`id_category`)));