File size: 1,941 Bytes
21bdc64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
-- ํ†ตํ•ฉ ๋Œ€์‹œ๋ณด๋“œ(BI)์šฉ ๋ถ„์„ ๊ฒฐ๊ณผ ์ €์žฅ ์Šคํ‚ค๋งˆ โ€” Supabase SQL Editor์— ๋ถ™์—ฌ ์‹คํ–‰
-- ๋ถ„์„ 1ํšŒ = (keyword, run_date) ๋‹จ์œ„. Tableau/Looker๊ฐ€ ๋ฐ”๋กœ ์กฐํšŒํ•  ์ˆ˜ ์žˆ๋Š” ํ”Œ๋žซ ๊ตฌ์กฐ.

-- 1) ๋ถ„์„ ์š”์•ฝ (ํ‚ค์›Œ๋“œยท๋‚ ์งœ๋ณ„ 1ํ–‰)
create table if not exists analysis_run (
    keyword               text not null,
    run_date              date not null,
    total_search_volume   bigint,
    keyword_count         integer,
    cluster_count         integer,
    intent_info           bigint default 0,   -- ์ •๋ณด ํƒ์ƒ‰ํ˜• ๊ฒ€์ƒ‰๋Ÿ‰
    intent_transactional  bigint default 0,   -- ๊ตฌ๋งค/๊ฑฐ๋ž˜ํ˜•
    intent_navigational   bigint default 0,   -- ๋ธŒ๋žœ๋“œ/๋‚ด๋น„๊ฒŒ์ด์…˜ํ˜•
    intent_mixed          bigint default 0,   -- ํ˜ผํ•ฉํ˜•
    marketing_suggestion  text,
    primary key (keyword, run_date)
);

-- 2) ํด๋Ÿฌ์Šคํ„ฐ๋ณ„ (๊ฒ€์ƒ‰ ์˜๋„ ๊ทธ๋ฃน)
create table if not exists analysis_cluster (
    id                   bigserial primary key,
    keyword              text not null,
    run_date             date not null,
    theme                text,        -- AI ํ…Œ๋งˆ ๊ทธ๋ฃน๋ช…
    rep_keyword          text,        -- ๋Œ€ํ‘œ ํ‚ค์›Œ๋“œ
    intent               text,        -- info | transactional | navigational | mixed
    total_search_volume  bigint,
    keyword_count        integer,
    top_keywords         text         -- ์ฃผ์š” ํฌํ•จ ํ‚ค์›Œ๋“œ (์‰ผํ‘œ ๊ตฌ๋ถ„)
);
create index if not exists idx_cluster_kw_date on analysis_cluster (keyword, run_date);

-- 3) ์ธ๊ตฌํ†ต๊ณ„ ์ถ”์ • ๋น„์ค‘ (์„ฑ๋ณ„ร—์—ฐ๋ น)
create table if not exists analysis_demographic (
    id        bigserial primary key,
    keyword   text not null,
    run_date  date not null,
    gender    text,    -- ๋‚จ์„ฑ | ์—ฌ์„ฑ
    age       text,    -- 20๋Œ€ ์ดํ•˜ | 30๋Œ€ | 40๋Œ€ | 50๋Œ€ ์ด์ƒ
    pct       numeric  -- ์ถ”์ • ๋น„์ค‘(%)
);
create index if not exists idx_demo_kw_date on analysis_demographic (keyword, run_date);