DROP TABLE IF EXISTS `v_schedule`;
DROP VIEW IF EXISTS `v_schedule`;

CREATE OR REPLACE VIEW `_db_diary`.`v_schedule` AS 
SELECT m_schedule.*, m_category.c_categoryName, m_category.c_categoryDisplayOrder
FROM m_schedule
LEFT OUTER JOIN m_category ON m_schedule.id_category = m_category.id_category
WHERE m_schedule.c_delete = 0;


DROP TABLE IF EXISTS `v_marker`;
DROP VIEW IF EXISTS `v_marker`;

CREATE OR REPLACE VIEW `_db_diary`.`v_marker` AS 
SELECT m_marker.*, r_markertype.c_markertype, r_markertype.c_markericon,
m_schedule.c_subject, m_schedule.c_date, m_schedule.c_date as c_mdate, m_schedule.c_currencyUnit, m_schedule.c_exchangeRate
FROM m_marker
LEFT OUTER JOIN r_markertype ON m_marker.id_markertype = r_markertype.id_markertype
LEFT OUTER JOIN m_schedule ON m_marker.id_schedule = m_schedule.id_schedule
WHERE m_marker.c_delete = 0;


DROP TABLE IF EXISTS `m_holiday`;
DROP VIEW IF EXISTS `m_holiday`;

CREATE OR REPLACE VIEW `_db_diary`.`m_holiday` AS 
SELECT _db_calendar.m_holiday.*
FROM _db_calendar.m_holiday
