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
1 answer

New to snowflake and having issues loading JSON file into internal stage and then the table

I have a JSON file that I am trying to load via SnowSQL into Snowflake. I have an SQL script that's partially working. Here is a sample of the JSON file: {"year":"2011","_113_cause_name":"Nephritis, nephrotic syndrome and nephrosis (N00- …
0
votes
2 answers

Extract particular text from String in Snowflake

I m new to snowflake. Input String : ["http://info.wealthenhancement.com/ppc-rt-retirement-planning"] Output String : info.wealthenhancement.com/ppc-rt-retirement-planning Please help to get output string. Thanks
at9063
  • 33
  • 1
  • 1
  • 8
0
votes
1 answer

ACCOUNT_USAGE forced refresh

I know that many views under SNOWFLAKE.ACCOUNT_USAGE will have a latency, some up to 3 hrs, so is there a way to "force" a refresh of the data, kind of like a ALTER ACCOUNT ... command or ALTER SHARE snowflake...? I love the concept of checking…
Dave
  • 33
  • 4
0
votes
1 answer

Snowflake external stage - getting error access denied

I have created an external stage for my S3 bucket in snowflake. When I try to access the stage using List @database.schema.stagename am getting access denied error. We have checked the S3 bucket policy and fixed the issue. But I want to check log in…
0
votes
1 answer

MINUS not working for the same value in Snowflake

I loaded data from oracle to snowflake in table1 using informatica. and the same data we have in snowflake table already table2. i want to perform minus query for testing but it doesn't work as expected. eg col1 field value is 1.21 in table1 and the…
0
votes
1 answer

Parse date to different format in snowflake

In Snowflake I have the date format in following Thu Nov 12 00:00:00 UTC 2020 If I want to make it as follows: MM-DD-YYYY HH24:MI:SS Can this be achieved. I have tried to_date function doesn't seems to…
0
votes
1 answer

Sum case from previous month

I couldn't find the answer to this on here or on google. This is part of the main table +---+-------+----------------+--------------+ | | Acct | Last_trans_date|Last_transpay | +---+-------+----------------+--------------+ | 1 | ABC | July 31 …
dtman85
  • 1
  • 1
0
votes
3 answers

SQL - Find Record count for multiple tables at a time in snowflake

I want to see counts have Tables at 1 time, instead of Running each. For EX: select COUNT(*) from "Fact_MASTER "; select COUNT(*) from "Dim_MASTER "; select COUNT(*) from "Fact2 "; select COUNT(*) from "Dim2"; select COUNT(*) from …
0
votes
1 answer

Unable To Find Table Functions In Information_Schema Schema

While reading INFORMATION_SCHEMA details on Snowflake documentation site URL Given below ; we can see 2 objects one is views and other is Table Functions. Views provide that database specific objects (Tables, Functions , stages etc ) metadata…
0
votes
0 answers

How to Convert SQL code to Snowflake Code

I have the following SQL code.Can you please help convert the following SQL server code to snowflake code.How to extract JSON and use crossapply in snowflake. select vid, ctextid, createdby, Created, description, p.dCode, dense_rank()…
user3369545
  • 310
  • 2
  • 14
0
votes
1 answer

How to get Session parameter details if I have session ID

I want to debug what went wrong with the SQL so want to know what parameters were used is executing SQL like schema name. I can grab Session ID from Query history UI but unable to fetch associated parameters. Any idea how to fetch those?
mad_
  • 8,121
  • 2
  • 25
  • 40
0
votes
2 answers

Using REGEXP_SUBSTR in Snowflake to pull multiple items around symbols including "("

I have an long string with the syntax 'item_name (price + tax), item_name (price + tax), item_name (price +tax)' that I want to get into the rows: item_1, price_1, item_2, price_2, etc. I used the below methods to get item_1 and item_2 but I can't…
0
votes
1 answer

how to extract snowflake tables schema and store-procedures using python script?

I'm intermediate with python and beginner with snowflakes. Here i'm able to connect snowflakes and fetch table data. But main problem is to extract tables schema and store-procedures from snowflakes using python script. thanks in advance.
0
votes
1 answer

Convert MongoDB query to Snowflake

I'm working on a migration project (MongoDB to Snowflake) and trying to convert one of the mongo queries to Snowflake, we have a use case to fetch records if all the elements from an array matched based on the given parameters. Mongo DB Function:…
0
votes
1 answer

Unable to fetch value from SNOWFLAKE_SAMPLE_DATA database in spark

I have a test account for snowflake. I can able to a fetch data from Python but unable to fetch it from Pyspark. Error is showing like unable to create a stage for shared DB. How the stage is creating in Python-snowflake connector?