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

Significance of Constraints in Snowflake

Snowflake allows UNIQUE, PRIMARY KEY, FOREIGN KEY and NOT NULL constraints but I read that it enforces only NOT NULL constraint. Then what is the purpose of other keys and under what circumstances do we have to define them? I appreciate any…
8
votes
1 answer

What is difference between Snowflake Database And Snowflake Schema

The two concepts confused me a lot recently. Snowflake Database more refers to the data service and its website address as below: https://www.snowflake.com/ This is more like a data platform or data warehouse on the cloud that provides SQL engine…
Chelseajcole
  • 487
  • 1
  • 9
  • 16
6
votes
3 answers

Divide by Zero Error encountered in Snowflake Query

I have the following snowflake query where I am getting a divide by zero error...Can you please help me here.. with cte1 as (select * from "coe.cup" where typeofcare ='AM' and status ='DONE' and review ='false' and date…
user3369545
  • 310
  • 2
  • 14
6
votes
3 answers

Is there a best way to get data from snowflake to s3

Is there a best way to get data from snowflake to s3. ? the data snowflake shows will be in s3, but we don't have access to that bucket. And we only need to get the specific tables from Snowflake not the entire data.
5
votes
0 answers

Is it possible to run a local Snowflake instance using Docker?

Would it be possible to run local instance of snowflake inside docker container? We need to add test cases for the sql scripts written it in snowsql. If it is not possible to run local instance of snowflake inside docker container then is there any…
5
votes
1 answer

Snowflake Row Access Policy privileges

I am unable to find the list of privilege's that are required - 1.) For a Role to create Row Access Policy 2.) Grant Usage on the Policy to a different Role 3.) Grant Modify on the Policy to a different Role Need simple step by step example starting…
5
votes
2 answers

Join on Id in Variant (Array) Snowflake

I have two tables t1 and t2 created as follows: Create Tables CREATE TABLE t1( id integer AUTOINCREMENT START 1 INCREMENT 1, name varchar(10) DEFAULT RANDSTR(10, random()), id_array variant, ) CREATE TABLE t2( id integer…
5
votes
2 answers

Update a mixed and nested object in Snowflake

I have a Snowflake table with one variant column (raw). Every row in this table is complex (both dictionaries and arrays) and nested (multiple hierarchies). What I want to do is to be able to update a specific item in some array. It will be easier…
5
votes
3 answers

Calculate alarm flood in snowflake

I am trying to do an alarm flood calculation in snowflake. I created the below dataset using a snowflake window function. So if the value is greater or equal to 3, then the alarm flood will start and for the next 0 value, it will end. So in the…
Dany
  • 2,034
  • 8
  • 34
  • 54
5
votes
2 answers

How to trigger something in Snowflake

I want to trigger some SQL code just before some update in a table or just after the update in a table. It seems like Triggers are not supported by Snowflake. Any workaround will be appreciated. Regards, Neeraj
Neeraj Kumar
  • 215
  • 3
  • 13
5
votes
1 answer

snowflake is better than indexing?

Here is the problem, I have a sales information table which contains sales information, which has columns like (Primary Key ID, Product Name, Product ID, Store Name, Store ID, Sales Date). I want to do analysis like drill up and drill down on…
Lin Ma
  • 9,739
  • 32
  • 105
  • 175
4
votes
3 answers

Failure using stage area. Cause: [Access Denied (Status Code: 403; Error Code: AccessDenied)]

I am new to snowflake and I have create a external stage and a give my s3 bucket url. My task is to copy json file from s3 to snowflake table. When I run copy command I am gettingan error . My command are as follows: create or replace file format…
Xi12
  • 939
  • 2
  • 14
  • 27
4
votes
0 answers

Protocol buffer/JSON Schema to SQL DDL

We use protocol buffers(protobuf) to define our schemas internally and have translators to translate to various other internal representations such as JSON Schema(Protobuf to JSON schema converter) so as to have protobuf schemas to be the source of…
4
votes
1 answer

Snowflake's Asynchronous External function not respecting HttpStatus 429

I have implemented an API which adhere with the Snowflake's Asynchronous External Function. In our developed system, we are using AWS API gateway, Lambda function and a Third Party API( TPA). In our scenarios, we store certain information in…
4
votes
2 answers

Is a snowflake schema better than a star schema for data mining?

I know the basic difference between a star schema and a snowflake schema-a snowflake schema breaks down dimension tables into multiple tables in order to normalize them, a star schema has only one "level" of dimension tables. But the Wikipedia…
Satvik Beri
  • 271
  • 1
  • 2
  • 9
1
2 3
59 60