Question

I am currently working in creating Data ware house,i need to know if Foreign keys are required to create a star or snow flake schema ?

If there would not be any foreign key constraints.. how would i differentiate btw star and snowflake schema ?

i read this but i still dont get it Is it good practice to have foreign keys in a datawarehouse (relationships)?

if no Fk constraints how would you differerentiate star and snow flake schema ?

Was it helpful?

Solution

No, you do not need foreign keys in a data warehouse.

Foreign keys are for referential integrity: i.e. "ensure that a value in this column exists in another column". However, most people do referential integrity checks using their ETL tool when putting data in the warehouse, as foreign keys can slow insert performance.

Tables can be related to other tables conceptually, via the values in the columns, without foreign keys. For example, if TableA has a column CustomerID and TableB has a column CustomerID, you could say that those tables are related, even if there is no foreign key.

A star schema has usually just one level of normalization (a fact table has some dimension tables, but a dimension table isn't "related" to any other tables), and a snowflake schema has more levels of normalization (dimension tables are "related" to other tables). That is how you tell the difference. Not with foreign keys.

You may also want to support Hot-Swappable Dimensions down the road, which make foreign keys meaningless.

Snowflake is probably an anti-pattern as well, so just use star schema and don't worry about it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top