-- Create a Calendar table 

CREATE TABLE dbo.dim_calendar (

    calendar_date DATE NOT NULL,

    day_of_week TINYINT NOT NULL,

    is_business_day TINYINT NOT NULL,

    is_holiday TINYINT NULL,

    holidy_name nvarchar(MAX)

CONSTRAINT PK_dim_calendar PRIMARY KEY (calendar_date)

);

 

-- 2015-01-01 부터 30년 동안의 날짜 입력

DECLARE @StartDate DATE = '20150101', @NumberOfYears INT = 30;

DECLARE @CutoffDate DATE = DATEADD(YEAR, @NumberOfYears, @StartDate);

 

INSERT dim_calendar([calendar_date], [day_of_week], [is_business_day]) 

SELECT d, (select DATEPART(dw, d)), 1

FROM

(

  SELECT d = DATEADD(DAY, rn - 1, @StartDate)

  FROM 

  (

    SELECT TOP (DATEDIFF(DAY, @StartDate, @CutoffDate)) 

      rn = ROW_NUMBER() OVER (ORDER BY s1.[object_id])

    FROM sys.all_objects AS s1

    CROSS JOIN sys.all_objects AS s2

    ORDER BY s1.[object_id]

  ) AS x

AS y;

 

-- Update data

update hh_calendar set day_of_week = (select DATEPART(dw, calendar_date));

update hh_calendar set is_holiday = 0;

 

* 참고:

1) DATEPART (Transact-SQL)

https://docs.microsoft.com/en-us/sql/t-sql/functions/datepart-transact-sql?view=sql-server-ver15

 

DATEPART (Transact-SQL) - SQL Server

Transact-SQL reference for the DATEPART function. This function returns an integer corresponding to the datepart of a specified date.

docs.microsoft.com

2) Query

https://gist.github.com/gavincampbell/4a4d4aa581038c261d89eddddfcaf45c

 

Creates a calendar table in Azure SQL Data Warehouse

Creates a calendar table in Azure SQL Data Warehouse - CreateDateAzureSQLDW.sql

gist.github.com

 

1. Region(리전)

- 모든 서비스가 위치하고 있는 물리적 장소

- 전 세계 주요 지역에 위치 (네트워크 속도를 빠르게 하기위함, 큰 재해(지진, 태풍)에 대비)

- 리전안에는 가용영역(Avaliability Zone, AZ, aka. 데이터센터)이 여러개 있음

* 가용영역은 같은 지역이라도 멀리 떨어져 있음(큰재해에 대비하기 위해)

 

2. Edge Location(엣지 로케이션)

-  AWS ColudFront(CDN 서비스를 위한 캐시 서버) 

*CDN 서비스: CDN(Content Delivery Network) 서비스란, 콘텐츠(HTML, 이미지, 동영상 등)을 사용자들이 빠르게 받을 수 있도록 캐시 서버에 복제해주는 서비스

'개발 > AWS' 카테고리의 다른 글

AWS 개요  (0) 2020.06.24

1. EC2

- 가상서버, 컴퓨터

 

2. ELB (Elastic Load Balancer, 로드밸런서 )

- 여러 가용 영역을 만들어 트래픽 분배. 

-서버 중 하나가 작동하지 않아도 다른 가용영역에 있는 서버는 작동하기 때문에 사용자는 문제없이 웹페이지 접속 가능함.

 

3. Route 53 

- DNS 서비스

 

4. ColudFront

- 콘텐츠 배포 서비스, CDN 서비스

 

5. Cloud Formation

- 서버 구성을 자동화

 

6. S3

- 스토리지 서비스

 

 

'개발 > AWS' 카테고리의 다른 글

EC2에서 Region(리전), Edge Location(엣지 로케이션)  (0) 2020.06.24

+ Recent posts