CREATE VIEW cards_data_base AS
SELECT
    cards.card_id AS card_id,
    cards.desk_id AS desk_id,
    cards.last_timing AS last_timing,
    cards.next_timing AS next_timing,
    cards.Hint AS Hint,
    cards.skip AS skip,
    cards.level AS level,
    cards.import_source as card_import_source,
    cards.ts_create As ts_create,
    cards.record_question AS record_question,
    cards.record_answer as record_answer,
    cards.record_hint AS record_hint,
    desks.user_id AS user_id,
    desks.parent_desk AS parent_desk,
    desks.tree AS tree,
    desks.link_id as link_id,
    desks.import_source as desk_import_source,
    desks.import_open as import_open,
    cards.next_timing <= CAST((NOW() + INTERVAL -(5) HOUR) AS DATE)
    OR cards.next_timing IS NULL as Repetition,
    cards.last_timing IS NULL
    AND cards.import_source IS NULL as News,
    cards.last_timing IS NULL
    AND NOT cards.import_source IS NULL as imports,
    cards.next_timing < CAST((NOW() + INTERVAL -(5) HOUR) AS DATE)
    AND cards.next_timing IS NOT NULL as Olds,
    cards.next_timing = CAST((NOW() + INTERVAL -(5) HOUR) AS DATE)
    AND cards.next_timing IS NOT NULL as toDay
FROM
    cards
    JOIN desks ON cards.desk_id = desks.desk_id