What data type is appropriate for star schema keys (integer or text)?

35 Views Asked by At

I have inherited a star schema based report.

However the keys (links) are text fields. Not numeric ids.

For example:

The DimClient has values like:

Client Name
JLR
Mercedes
Audi
Volvo

And the FactSales has values link:

id date       client value
1  01-01-2024 JLR    50000
2  05-01-2024 Audi   40000

Is this bad practice?

Is it recommended to handle this by adding an index column to the dim, then joining the fact to the dim on client name and fetching the id from the dim, followed by removing the client name from the fact table?

2

There are 2 best solutions below

4
davidebacci On BEST ANSWER

No, it's fine as text keys. VertiPaq uses dictionary encoding for things like this.

Reporting databases do not follow the same design patterns as transactional databases and it is fine to have things like denormalisation etc (recommended even).

0
zach On

As @davidbacci pointed out, text values work fine for relationships in the model. There are benefits to surrogate keys in the data warehouse, but you should be ok in just your report.

Surrogate Key benefits explanation here.