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
0
votes
2 answers

Snowflake : Copy comman not generating Constant SIze for multiple files while unloading

copy into @elasticsearch/product/s3file from (select object_construct(*)from mytable) file_format = (type = json, COMPRESSION=NONE), overwrite=TRUE, single = False, max_file_size=5368709120; the table has 2GB of data. I want to split them in…
Sundar
  • 95
  • 1
  • 13
0
votes
1 answer

How to convert all the column data in snowflake/database to upper case with a with a single query in Snowsql?

I would like to convert all the data if in lower case in snowflake table to upper case. I have multiple catalogs, schemas and then tables. Would like to do this with Python. Is there a straight query on table to convert all the data (columns) into…
0
votes
2 answers

Snowflake ifnull and parse_json when combined it is not working as expected

This is my query select object_construct('id', id, alpha, PARSE_JSON(null)) from tablename limit 1 the output is { "id" :1, "alpha":null } but when I combined parse_json with ifnull it returns empty object {} not working as expected select…
0
votes
1 answer

Snowflake object_construct unloading Key Order should be preserved as same. how to maintain the order not by alphabetical?

I use copy command of snowflake which is below returns a file with content json copy into @elasticsearch/product/sf_index from (select object_construct('id',id, alpha,'alpha')from table limit 1) file_format = (type = json, COMPRESSION=NONE),…
0
votes
2 answers

Snowflake: Unload table Data to JSON, how to do without .gz compression?

create or replace stage elasticsearch_dev url='s3://s3bucket/ElasticSearch' credentials=(aws_role='arn:aws:iam::XXXXXXX:role/role_snowflake') copy into @elasticsearch_dev/test/SAMPLE.json from (select To_JSON(object_construct(*)) from Sample) …
Sundar
  • 95
  • 1
  • 13
0
votes
1 answer

How to perform SCD 1 on snwoflake tables using talend

I am quite new to Talend and I need to perform the scd1 operation on snwoflake tables. Can anyone suggest me the important components I need to use in talend to perform this operation. I tried with tDBSCD but it does not allow snowflake database. Is…
0
votes
2 answers

Can snowflake spark connector create external table?

Please let me know whether Snowflake Spark connector has the ability to create Snowflake external table?
0
votes
2 answers

How to get relationship between tables

Hi I am creating a ER diagram for my organization. How can i get the relationship between the tables in snowflake Thanks
bkan
  • 11
  • 1
0
votes
2 answers

Activating warehouse in Snowflake using Java and spark

I am trying to connect to snowflake DB and activate a particular warehouse.I have used warehouse in both JDBC connection jdbc:snowflake://xy12345.eu-central-1.snowflakecomputing.com/?warehouse=mywh as well as in the…
0
votes
1 answer

SHOW GRANTS TO user ''usename" with filter on role (SNOWFLAKE)

I want to select a user only with a given role. I gone through the document but didnt get how to filter rows for a particular role. DATABASE: SNOWFLAKE
0
votes
1 answer

Flattens (explodes) compound values into multiple rows

Flatten can be used for following semi structure and structure data, or only semi structure.
Prats
  • 11
  • 2
0
votes
1 answer

How to pass a range of date in where clause in snowflake while writing a query

How to pass a range of date in where clause in snowflake while writing a query and avoiding duplicates also for the next run. I have below query and i have to fetch 15-days of data each day till previous day. The data would be passed to my final…
0
votes
1 answer

SQL compilation error: syntax error line 21 at position 6 unexpected '@CPG'. syntax error line 21 at position 29 unexpected ','

I am trying to create a new table in snowflake, but it is giving me the above error, how do i resolve this issue?? Does snowflaqke have problem with @ symbol while creating Has anyone else encountered this issue?? CREATE OR REPLACE TABLE F58155 ( …
0
votes
0 answers

How to get a list of IDataRecord from IDataReader returned by Snowflake .net client?

If we use Microsoft SQL Database, then we get SQLDataReader object when ExecuteReader() function is executed. So we have a function for converting SQLDataReader object into List of IDataRecord which can be used later on when the connection is…
0
votes
2 answers

How to bulk load files from external stage Amazon s3 to snowflake table using COPY into for disordered columns using Column?

I am facing issue while I am trying to do a copy into from S3 stage (with column headers but in different order than that of target snowflake table) to snowflake db using this copy into command COPY INTO db.schema.table FROM @stage/file.csv…