Questions tagged [snowflake-schema]

**Snowflake schema** is special case of the database Star Schema, where one or many dimension tables are normalized. This is often done for improving the performance in some cases of the Star Schema. When the dimension tables are completely normalized, the resulting structure resembles a snowflake with the fact tables in the middle.

Snowflake schema is a logical arrangement of tables in a multidimensional database in which the dimensions are expressed by more than one table. The dimension tables that relate to the facts table represent the smallest granularity of data-analysis. The other tables in the same dimension represent aggregators of dimension's individual elements. When a dimension is aggregated by several independent criteria, the diagram resembles the shape of a snowflake. Used in data warehouses.

Methods for creating Snowflake Schema out of Star Schema:

  • Partially or fully normalize one or many dimension tables, leaving other dimensions unchanged.
  • Partially or fully normalize all dimension tables.

When to use

Query performance takes the highest significance in a data warehouse and snowflaking can hamper the performance. It very useful for cases, when some attributes like demographic attributes are browsed more then the whole customer table itself. Another case is for precalculated summaries derived from a fact table. This helps not aggregating over and over again since the operation is expensive.

Advantages

Savings in the storage space. Normalized structures are having no insertion, deletion or update anomalies. Easier to update and maintain.

Disadvantages

Schemas are less intuitive, with higher complexity and abstraction. Difficult browsing through the contents for users. Additional joins - worse query performance in some cases.

Example

Having a fact table called "Sales" and dimension table called "Product". Assume there are 500000 product dimension rows. These products can fall under 10 brands. For running query for products, not indexed on brands, the query will have to search through 500000 rows to find all brands.

On the other hand, if the "Product" table partially normalized, separated on another table "Brand" the initial search query would need to go through just 10 rows on.

External links

893 questions
-1
votes
2 answers

How to write data into snowflake database using python

I need to write data into snowflake database, I have the below script, but I want to write data without giving username and password, is there any other way? #NOTE - I have to run this script in databricks. import json import snowflake.connector #…
-1
votes
1 answer

Snowflake JOIN with Multiple Tables

SELECT top 10 * FROM (SELECT * FROM DB.SCHEMA.MODULE_MASTER m INNER JOIN DB.SCHEMA.MODULEINFO ef ON m."moduleinfoid" = ef."moduleinfoid" INNER JOIN DB.SCHEMA.MODULE_RETURNINFO r ON m."modulemasterid" = r."modulemasterid" INNER JOIN…
Erin
  • 465
  • 4
  • 11
-1
votes
1 answer

Need to create date dimension table in snowflake

I have create a date dimension table with columns : D_DATEKEY, D_DATE, D_DAYOFWEEK, D_MONTH, D_YEAR, D_YEARMONTHNUM, D_YEARMONTH ,D_DAYNUMINWEEK, D_DAYNUMINMONTH, D_DAYNUMINYEAR, D_MONTHNUMINYEAR ,D_WEEKNUMINYEAR, D_SELLINGSEASON, D_LASTDAYINWEEKFL,…
-1
votes
1 answer

Filter Column using where condtion in column level in Snowflake

I want to apply a column level filter like if there is an account of 30 then that value has to be taken. But I do not want it to apply this account filter to the whole table as I have few more columns with the same ask like this. I want to filter it…
-1
votes
1 answer

How can I CREATE SECURE VIEW in Snowflake and set the column Type size away from default as eg. VARCHAR(256) without creating a temp table

I'm trying to use our CREATE SECURE VIEW script in snowflake that we use for automated data shares but we need to limit the character lengths from the maximum VARCHAR(16777216) to something more usable by external shareholder middleware. CREATE…
-1
votes
1 answer

How to Split JSON Variant Column in Snowflake

We have Json Variant column in the table. The column D has json variant value like this: [ "[{\"xyz_id\":0001,\"abc_id\":10032,\"dis_name\":\" AP 20%\",\"dis_type_name\":\"Subtotal Dis\",\"disc_rate\":20.0,\"discount_total\":-1.0000}]" ] We want…
-1
votes
1 answer

In Snowflake, How to update the data in the table which is present in other schema using procedure

var run_id_query = `INSERT INTO STG.RUN_STATUS (RUNID,STATUS,STATUS_DESCRIPTION) VALUES (TO_CHAR(CURRENT_DATE,'YYYYMMDD'),0,'RUN START')`; var run_id_stmt = snowflake.createStatement({ sqlText: run_id_query}); var run_id =…
-1
votes
1 answer

How to add one more column in same table while keeping the group by clause

List of columns in Table1: Plan_ID, Claim_id, Patient_id, B_OR_G List of columns in Table2: ORGID, SHAPLANID select distinct a.Plan_ID , a.Total_Claims , Total_Patients , b.PERIOD , b.ORGID,a.B_OR_G FROM (Select distinct…
-1
votes
1 answer

Secure Local Storage issue while connecting java with Snowflake

I am receiving this error: net.snowflake.client.core.CredentialManager initSecureStorageManager INFO: JNA jar files are needed for Secure Local Storage service. Please follow the Snowflake JDBC instruction for Secure Local Storage feature. Fall…
-1
votes
2 answers

How do I join 3 tables with 2 different ids (sql in snowflake)?

First, I need to unzip data from one table to transform into a new table. Secondly, I need to join another table to this new table based on customer id Z. Thirdly, I need to join yet another table to that second table using a different customer id,…
-1
votes
1 answer

How to make sure all sql statements are executed else roolback

I have few SQL statements. copy into STG_PB(VAR,FILE_NAME, LINE_NUMBER) from ( select $1,metadata$filename, metadata$file_row_number from @investor_stage_s3// ) delete from stg_pb1 insert into stg_pb1 values (....) So daily I get…
Xi12
  • 939
  • 2
  • 14
  • 27
-1
votes
3 answers

Row count tables in schema

Is there a way to get a row count of all the tables in a snowflake schema without using the information schema or account usage schema.
-1
votes
3 answers

How to ensure that users are enrolled in MFA

I have a large number of users to set up that all need to access to the data warehouse at the same time. A security requirement for our company is that all users must be set up with multi-factor authentication. From what I have read, users must…
-1
votes
1 answer

What is the point of custom roles being assigned to SYSADMIN

I read that it is recommended practice for custom roles to be assigned to SYSADMIN. What is the point of this ?
-1
votes
3 answers

How to sample 10% of the data from a table?

How can I return 10% of the rows from a table in Snowflake. For example, how can I return the 10th, 20th, 30th row based after sorting a table.