CREATEEXTERNALTABLEIFNOTEXISTSdannys_diner.members(customer_idCHAR(1)COMMENT'Unique identifier for the customer, represented as a single character',join_dateTIMESTAMPCOMMENT'Date and time when the customer joined the loyalty program')COMMENT'The members table captures the dates when each customer joined the beta version of the Dannys Diner loyalty program'STOREDASPARQUETLOCATION's3://sql-case-studies/dannys_diner/members/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Menu
CREATEEXTERNALTABLEIFNOTEXISTSdannys_diner.menu(product_idINTCOMMENT'Unique identifier for the product',product_nameSTRINGCOMMENT'Name of the product',priceDOUBLECOMMENT'Price of the product')COMMENT'The menu table maps the product IDs to the actual product names and prices'STOREDASPARQUETLOCATION's3://sql-case-studies/dannys_diner/menu/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Sales
CREATEEXTERNALTABLEIFNOTEXISTSdannys_diner.sales(customer_idCHAR(1)COMMENT'Unique identifier for the customer, represented as a single character',order_dateTIMESTAMPCOMMENT'Date and time when the order was placed',product_idINTCOMMENT'Unique identifier for the product purchased')COMMENT'The sales table captures all customer ID level purchases with order dates and product IDs'STOREDASPARQUETLOCATION's3://sql-case-studies/dannys_diner/sales/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Data Bank
ERD
Data Bank
DDL
Region
CREATEEXTERNALTABLEIFNOTEXISTSdata_bank.regions(region_idINTCOMMENT'Unique identifier for the region',region_nameVARCHAR(9)COMMENT'Name of the region, up to 9 characters')COMMENT'The region table contains the region IDs and names'STOREDASPARQUETLOCATION's3://sql-case-studies/data_bank/regions/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Customer Nodes
CREATEEXTERNALTABLEIFNOTEXISTSdata_bank.customer_nodes(customer_idINTCOMMENT'Unique identifier for the customer',region_idINTCOMMENT'Unique identifier for the region',node_idINTCOMMENT'Unique identifier for the node within the region',start_dateTIMESTAMPCOMMENT'Date and time when the customer was assigned to the node',end_dateTIMESTAMPCOMMENT'Date and time when the customer was removed from the node, NULL if still active')COMMENT'The customer nodes table stores the customer IDs, region IDs, node IDs, and the start and end dates that the customer was assigned to the node'STOREDASPARQUETLOCATION's3://sql-case-studies/data_bank/customer_nodes/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Customer Transactions
CREATEEXTERNALTABLEIFNOTEXISTSdata_bank.customer_transactions(customer_idINTCOMMENT'Unique identifier for the customer',txn_dateTIMESTAMPCOMMENT'Date and time of the transaction',txn_typeVARCHAR(10)COMMENT'Type of transaction: deposit, withdrawal, or purchase',txn_amountDOUBLECOMMENT'Amount involved in the transaction')COMMENT'The customer transactions table stores all customer deposits, withdrawals, and purchases'STOREDASPARQUETLOCATION's3://sql-case-studies/data_bank/customer_transactions/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Trading
ERD
Daily Bitcoin Prices
DDL
Daily Bitcoin Price
CREATEEXTERNALTABLEIFNOTEXISTStrading.daily_btc(market_dateTIMESTAMPCOMMENT'Cryptocurrency markets trade daily with no holidays',open_priceDOUBLECOMMENT'$ USD price at the beginning of the day',high_priceDOUBLECOMMENT'Intra-day highest sell price in $ USD',low_priceDOUBLECOMMENT'Intra-day lowest sell price in $ USD',close_priceDOUBLECOMMENT'$ USD price at the end of the day',adjusted_close_priceDOUBLECOMMENT'$ USD price after splits and dividend distributions',volumeDOUBLECOMMENT'The daily amount of traded units of cryptocurrency')COMMENT'Daily Bitcoin trading data containing the open, high, low, close, adjusted close prices, and volume'STOREDASPARQUETLOCATION's3://sql-case-studies/trading/daily_btc/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Clique Bait
ERD
Clique Bait
DDL
Users
CREATEEXTERNALTABLEIFNOTEXISTSclique_bait.users(user_idINTCOMMENT'Unique identifier for the user',cookie_idVARCHAR(6)COMMENT'Unique identifier for the user’s browser session, represented as a cookie ID',start_dateTIMESTAMPCOMMENT'Date and time when the user first visited the website')COMMENT'The users table stores customers who visit the Clique Bait website and their tagged cookie IDs'STOREDASPARQUETLOCATION's3://sql-case-studies/clique_bait/users/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Events
CREATEEXTERNALTABLEIFNOTEXISTSclique_bait.events(visit_idVARCHAR(6)COMMENT'Unique identifier for the visit session',cookie_idVARCHAR(6)COMMENT"Unique identifier for the user's browser session, represented as a cookie ID",page_idINTCOMMENT'Unique identifier for the page viewed during the event',event_typeINTCOMMENT'Type of event that occurred (e.g., page view, add to cart, purchase)',sequence_numberINTCOMMENT'Order of the event in the sequence of actions during the visit',event_timeTIMESTAMPCOMMENT'Date and time when the event occurred')COMMENT'The events table captures all customers visits that are logged at the cookie ID level'STOREDASPARQUETLOCATION's3://sql-case-studies/clique_bait/events/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Event Identifier
CREATEEXTERNALTABLEIFNOTEXISTSclique_bait.event_identifier(event_typeINTCOMMENT'Unique identifier for the type of event',event_nameVARCHAR(100)COMMENT'Name or description of the event type')COMMENT'The event identifier table stores the types of events that are captured by the system'STOREDASPARQUETLOCATION's3://sql-case-studies/clique_bait/event_identifier/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Campaign Identifer
CREATEEXTERNALTABLEIFNOTEXISTSclique_bait.campaign_identifier(campaign_idINTCOMMENT'Unique identifier for the campaign',productsVARCHAR(3)COMMENT'List of products associated with the campaign, represented as a short code',campaign_nameVARCHAR(100)COMMENT'Name of the campaign',start_dateTIMESTAMPCOMMENT'Date and time when the campaign started',end_dateTIMESTAMPCOMMENT'Date and time when the campaign ended')COMMENT'The campaign identifier table stores the three campaigns run by Clique Bait so far'STOREDASPARQUETLOCATION's3://sql-case-studies/clique_bait/campaign_identifier/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Page Hierachy
CREATEEXTERNALTABLEIFNOTEXISTSclique_bait.page_hierarchy(page_idINTCOMMENT'Unique identifier for the page',page_nameVARCHAR(50)COMMENT'Name of the page on the website',product_categoryVARCHAR(50)COMMENT'Category of the product featured on the page',product_idINTCOMMENT'Unique identifier for the product featured on the page')COMMENT'The page hierarchy table lists all pages on the Clique Bait website'STOREDASPARQUETLOCATION's3://sql-case-studies/clique_bait/page_hierarchy/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Fresh Segments
ERD
Fresh Segments
DDL
Interest Map
CREATEEXTERNALTABLEIFNOTEXISTSfresh_segments.interest_map(idINTCOMMENT'Unique identifier for the interest',interest_nameVARCHAR(100)COMMENT'Name of the interest',interest_summaryVARCHAR(500)COMMENT'Brief summary or description of the interest',created_atTIMESTAMPCOMMENT'Timestamp when the record was created',last_modifiedTIMESTAMPCOMMENT'Timestamp when the record was last modified')COMMENT'The interest map table links the interest IDs with the relevant interest names and summaries'STOREDASPARQUETLOCATION's3://sql-case-studies/fresh_segments/interest_map/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Interest Metrics
CREATEEXTERNALTABLEIFNOTEXISTSfresh_segments.interest_metrics(record_monthINTCOMMENT'Represents the month of the record',record_yearINTCOMMENT'Represents the year of the record',month_yearVARCHAR(7)COMMENT'Month and year concatenated as a string in the format MM-YYYY',interest_idINTCOMMENT'Unique identifier for the interest',compositionDOUBLECOMMENT'Represents the composition percentage of the interest (e.g., 11.89% of the client’s customer list interacted with the interest)',index_valueDOUBLECOMMENT'Index value indicating how much higher the composition value is compared to the average composition value for all Fresh Segments clients’ customers for this interest in the same month (e.g., 6.19 means 6.19x the average)',rankingINTCOMMENT'Ranking of the interest based on the index value in the given month year (e.g., 1 for the highest index value)',percentile_rankingDOUBLECOMMENT'Percentile ranking of the interest based on its index value, indicating its position relative to other interests in the same month year (e.g., 99.86 means it is in the top 0.14%)')COMMENT"The interest metrics table represents the performance of specific interests based on the client's customer base"STOREDASPARQUETLOCATION's3://sql-case-studies/fresh_segments/interest_metrics/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Data Mart
ERD
Data Mart
DDL
Weekly Sales
CREATEEXTERNALTABLEIFNOTEXISTSdata_mart.weekly_sales(week_dateTIMESTAMPCOMMENT'The starting date of the sales week for each record',regionVARCHAR(20)COMMENT"Represents the geographical area of operations within Data Mart's multi-region strategy",platformVARCHAR(10)COMMENT'Indicates whether sales occurred through the retail channel or the online Shopify storefront',segmentVARCHAR(10)COMMENT'Categorizes customers based on demographic and age-related groupings',customer_typeVARCHAR(10)COMMENT'Provides additional demographic details, such as lifestyle or purchasing behavior',transactionsINTCOMMENT'The count of unique purchases made during the corresponding sales week',salesDOUBLECOMMENT'The total dollar amount of purchases made in the corresponding sales week')COMMENT'Sales data containing weekly transaction and sales information by region, platform, segment, and customer type'STOREDASPARQUETLOCATION's3://sql-case-studies/data_mart/weekly_sales/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Balanced Tree
ERD
Balanced Tree
DDL
Sales
CREATEEXTERNALTABLEIFNOTEXISTSbalanced_tree.sales(prod_idVARCHAR(6)COMMENT'Unique identifier for the product',qtySMALLINTCOMMENT'Quantity of the product purchased in the transaction',priceSMALLINTCOMMENT'Price of the product in the transaction',discountSMALLINTCOMMENT'Discount percentage applied to the product',memberVARCHAR(1)COMMENT'Membership status of the buyer (e.g., t for true, f for false)',txn_idVARCHAR(6)COMMENT'Unique identifier for the transaction',start_txn_timeTIMESTAMPCOMMENT'Timestamp of when the transaction started')COMMENT'This table contains product-level transaction data, including quantities, prices, discounts, membership status, transaction IDs, and transaction timestamps'STOREDASPARQUETLOCATION's3://sql-case-studies/balanced_tree/sales/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Product Details
CREATEEXTERNALTABLEIFNOTEXISTSbalanced_tree.product_details(product_idVARCHAR(6)COMMENT'Unique identifier for the product',priceSMALLINTCOMMENT'Price of the product in the store',product_nameVARCHAR(50)COMMENT'Name of the product',category_idSMALLINTCOMMENT'Unique identifier for the category',segment_idSMALLINTCOMMENT'Unique identifier for the segment',style_idSMALLINTCOMMENT'Unique identifier for the style',category_nameVARCHAR(10)COMMENT'Name of the category',segment_nameVARCHAR(10)COMMENT'Name of the segment',style_nameVARCHAR(50)COMMENT'Name of the style')COMMENT'The product details table includes all information about the products featured in the store'STOREDASPARQUETLOCATION's3://sql-case-studies/balanced_tree/product_details/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Product Prices
CREATEEXTERNALTABLEIFNOTEXISTSbalanced_tree.product_prices(idSMALLINTCOMMENT'Unique identifier for the price record',product_idVARCHAR(6)COMMENT'Unique identifier for the product',priceSMALLINTCOMMENT'Price of the product in the store')COMMENT'This table stores the pricing information for products, including product identifiers and their corresponding prices'STOREDASPARQUETLOCATION's3://sql-case-studies/balanced_tree/product_prices/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Product Hierarchy
CREATEEXTERNALTABLEIFNOTEXISTSbalanced_tree.product_hierarchy(idSMALLINTCOMMENT'Unique identifier for the entry in the hierarchy',parent_idSMALLINTCOMMENT'Parent identifier for the current level (NULL for top-level categories)',level_textVARCHAR(30)COMMENT'Name or description of the hierarchy level (e.g., product type or style)',level_nameVARCHAR(20)COMMENT'Name of the hierarchy level (e.g., Category, Segment, or Style)')COMMENT'This table represents the hierarchical structure of product categories, segments, and styles for the store, and each entry defines the relationship between levels, starting from top-level categories down to individual product styles'STOREDASPARQUETLOCATION's3://sql-case-studies/balanced_tree/product_hierarchy/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Foodie Fi
ERD
Foodie Fi
DDL
Plans
CREATEEXTERNALTABLEIFNOTEXISTSfoodie_fi.plans(plan_idTINYINTCOMMENT'Unique identifier for the plan',plan_nameVARCHAR(20)COMMENT'Name of the subscription plan',priceFLOATCOMMENT'Price of the subscription plan')COMMENT'The plans table contains information about the different subscription plans available, including churn events'STOREDASPARQUETLOCATION's3://sql-case-studies/foodie_fi/plans/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');
Subscriptions
CREATEEXTERNALTABLEIFNOTEXISTSfoodie_fi.subscriptions(customer_idSMALLINTCOMMENT'Unique identifier for the customer',plan_idTINYINTCOMMENT'Unique identifier for the plan associated with the subscription',start_dateTIMESTAMPCOMMENT'Start date of the subscription')COMMENT'The subscriptions table stores information about customer subscriptions to various plans'STOREDASPARQUETLOCATION's3://sql-case-studies/foodie_fi/subscriptions/'TBLPROPERTIES('classification'='parquet','parquet.compress'='SNAPPY');