-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrendsDatabase_DDL.sql
75 lines (68 loc) · 2.13 KB
/
TrendsDatabase_DDL.sql
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- Following queries are used to create required tables for the project.
-- We create five tables:
-- 1. Product
-- 2. Maintabletransient
-- 3. History
-- 4. Shelf
-- 5. Inventory
CREATE DATABASE trends;
USE DATABASE trends;
CREATE EXTERNAL TABLE IF NOT EXISTS trends.MainTableTransient (
`productID` int,
`productName` string,
`shelfID` int,
`productQuantity` int,
`currentDate` date,
`currentTime` timestamp
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://trendsdatabase/Main_table/'
TBLPROPERTIES ('has_encrypted_data'='false');
CREATE EXTERNAL TABLE IF NOT EXISTS trends.History (
`productID` int,
`productName` string,
`shelfID` int,
`productQuantity` int,
`currentDate` date,
`currentTime` timestamp
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://trendsdatabase/History/'
TBLPROPERTIES ('has_encrypted_data'='false');
CREATE EXTERNAL TABLE IF NOT EXISTS trends.Inventory (
`productID` int,
`productName` string,
`totalQuantity` int
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://trendsdatabase/Inventory/'
TBLPROPERTIES ('has_encrypted_data'='false');
CREATE EXTERNAL TABLE IF NOT EXISTS trends.Shelf (
`shelfID` int,
`productID` string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://trendsdatabase/Shelf/'
TBLPROPERTIES ('has_encrypted_data'='false');
CREATE EXTERNAL TABLE IF NOT EXISTS trends.Product (
`productID` int,
`productName` string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ','
) LOCATION 's3://trendsdatabase/Product/'
TBLPROPERTIES ('has_encrypted_data'='false');