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

File format creation using Python in Snowflake

We are using python for data load so we need to create file format in snowflake using python. I have tried to creating file format through python but it got error out. Could someone please share the sample python script for creating file format…
0
votes
1 answer

Snowflake stage creation with relative path

I'm trying to use the "test" folder name as dynamic folder path for Snowflake stage creation, which comes after the s3 url. Copy command runs but returns zero records. create or replace stage MYSQL_S3 url='s3://myproject/product/BackEnd/' …
0
votes
1 answer

Unable to create a role when using ACCOUNTADMIN or SYSADMIN in Snowflake

I am getting the error "SQL access control error: Insufficient privileges to operate on account 'XXXXXX'" when I try to create a role in Snowflake in order to get it connected to Segment. I am following the Segment documentation here:…
0
votes
2 answers

To get subtring from a string

I am having issue to extract substring from string. The input values are like {Resultset: 234, edf, ejj, Resultvalue: hsh, 23,hhs} { hashvalue: 233, ehdh, Resultset: 2dd34, edf, ejj} 3rd value: {hashvalue: 233, ehdh, Resultset: 2dd34, Resultvalue:…
0
votes
1 answer

INSERT data From IBM i-series database table into SNOWFLAKE database table using Linked server connection

INSERT data From IBM i-series database (Created Linked server connection -SOFT) table into SNOWFLAKE database table (Created Linked server connection -SF_64) Linked server connection(Created in One of the SQL server) SOFT - linked server connection…
0
votes
1 answer

Javascript function in snowflake to append tablename with current date

I have recently started to use snowflake and have been stuck at this issue: I want to clone a table called AB_USER to AB_USER_(current_date). I have written following code to accomplish this: CREATE or replace PROCEDURE backup_proc() RETURNS…
0
votes
2 answers

Snowflake user/role management

I have different users with role "sysadmin". When user "AAA" which is a sysadmin, is creating a table, everything is working but then when user "BBB", wants to drop/create or replace the table that user "AAA" created, we receive an error that…
0
votes
2 answers

Roles Metadata Tables in Snowflake

I need to check the roles and grants given to users, but from the metadata tables. Basically, I need the metadata table, where I can query this, using multiple roles, eg. XXX, YYY,ZZZ. I need this to get the hierarchy of the roles that might have…
0
votes
1 answer

Unloading Snowflake data to S3 Location directly with Canned ACL

I am trying to unload the results of a particular query in Snowflake to an S3 location directly. copy into 's3://bucket-name/folder/text.csv' from file_format = (type = CSV file_extension = '.csv' field_optionally_enclosed_by =…
0
votes
3 answers

Why do i get this error when i connect snowflake and python

This is the error i get when i connect to snowflake via python? OperationalError: 250003: Failed to execute request: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])",) I connect using: ctx…
Maths12
  • 852
  • 3
  • 17
  • 31
0
votes
1 answer

How do I add an extra column from JSON into my snowflake table?

I am new to using snowflake. I have a table that includes the original and full JSON message from which the table was created. So when I query e.g. select * from dbo.TradeData one of the columns is called JSON and contains the complete JSON…
Maths12
  • 852
  • 3
  • 17
  • 31
0
votes
1 answer

Nested window function not working in snowflake

I am working on migration of spark sql to snowsql. At one point i got a scenario where i have used nested window functions in spark sql. And i want to migrate that sql query into snowflake. But snowflake doesn't support nested window…
0
votes
2 answers

How to avoid sub folders in snowflake copy statement

I have a requirement to exclude certain folder from prefix and process the data in snowflake (Copy statement) In the below example I need to process files under emp/ and exclude files from abc/ Input : s3://bucket1/emp/…
0
votes
2 answers

Doing aggregate functions on queries across standard and variant typed columns

I am looking to leverage the variant capabilities in snowflake. I am new to snowflake and can't see from the docs if it supports what I want to do. I want to perform queries on a table where I do aggregations (groupings) across columns that have…
0
votes
2 answers

What Operations in snowflake do not consume compute credits?

I know that DDL and Show operations do not consume compute credits? Is there any list some one has compiled to determine what operations in snowflake do not consume compute credits? Appreciate your help