Giter Site home page Giter Site logo

serzhyale / sql_calendar Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 11.68 MB

Calendar for MySQL, Microsoft SQL, Oracle, Postgres (dates, hours, weeks, months, quarters, years)

License: Other

TSQL 48.90% PLpgSQL 51.10%
calendar dates hours months mssql mysql sql weeks quarters mssql-database postgres mariadb-mysql oracle oracle-database

sql_calendar's Introduction

sql_calendar

Physical Calendar for

- MySQL (MariaDB)

- Microsoft SQL

- Oracle SQL

- Postgres SQL

- Snowflake

- As CSV table files (just to import)

Hours, Dates, Weeks, Months, Quarters, Years


The solution for enterprise applications. Calendar with already calculated fields for grouping and filtering date-time aggregated stored data.
In this package code for:

The tables:

  • calendar_dates
  • calendar_hours

The views:

  • calendar_weeks
  • calendar_months
  • calendar_quarters
  • calendar_years

Fast physical JOIN entity for any calendar-related aggregarions.

You can check the file sql_calendar_csv_files.zip with resulted csv files.


calendar_dates (68 columns)

The table points to each date in the period. Main fields can be key to dimensions in aggregated tables: date (date YYYY-MM-DD) and date8 (int YYYYMMDD).
But all known other versions are presented.

The idea is to have a real table with already calculated information and use it in joining any daily aggregations. Columns year_week or week_begin, year_month2, year_quarter, year - pointing its views.


calendar_hours (38 columns)

The table points to each hour for every date in the period.

The idea is to have a real table with already calculated information to use in joining any hourly aggregations.
Main fields can be key to dimensions in aggregated tables: date_hour (char(13) YYYY-MM-DD HH) and date_hour10 (int YYYYMMDDHH).
Column date pointing table calendar_dates. Column year_month2 - pointing its view.

Also can help to join data with hours in different timezones. In this example, the table stores information about UTC hours for CET. To aggregate UTC-stored data for CET calendar dates.
The fields date_hour_cet (char(13) YYYY-MM-DD HH) and date_hour_cet10 (int YYYYMMDDHH) can be key to dimensions in aggregated tables.
Columns date_cet, year_month2_cet - pointing CET timezone.

Also presented 3 short versions of this table for fast indexing for usage in big data selections.


calendar_weeks (28 columns)

The view to aggregate daily-presented data by its weeks. The main field can be key to dimensions in aggregated tables: year_week (char(7) YYYY/WW)


calendar_months (29 columns)

The view to aggregate daily-presented data by its calendar months. The main field can be key to dimensions in aggregated tables: year_month2 (char(7) YYYY-MM)


calendar_quarters (16 columns)

The view to aggregate daily/monthly-presented data by its calendar quarters. The main field can be key to dimensions in aggregated tables: year_quarter (char(6) YYYY-Q)


calendar_years (16 columns)

The view to aggregate daily/monthly-presented data by its calendar year. The main field can be key to dimensions in aggregated tables: year (YYYY)


Please choose the solution folder for your SQL version and pay attention to the details written in comments in the code files (.sql)

/* sza(c) */

sql_calendar's People

Contributors

serzhyale avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.