Solved

Index on Database

Posted on 2014-11-12
5
203 Views
Last Modified: 2014-11-24
I have two tables and no index is defined. This is a data warehouse tables that will be loaded into MS AS Cube.

DIM_CURRENCY (CURRENCY_IDX, CURRENCYCODE, NAME, SYMBOL, RATE)

FACT_SALES_INVOICE (CURRENCY_IDX, REGION_COUNTRY, TRANSDATE, CUSTOMER_IDX, SALESMAN_IDX, BASEAMOUNT, QTY, INVOICENO, COMPANY)

What kind of index should I create on each tables ?
As there is no primary key on fact table, should I create individual index key for each attribute, or a single key combining all attributes ?

Tks
0
Comment
Question by:AXISHK
  • 3
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 40439383
You should have at least a primary key in both tables and a foreign key in the fact tables to guarantee the relationship between tables.
Only after that you should start think in another indexes but that's depends on your queries.
0
 

Author Comment

by:AXISHK
ID: 40439943
Should I create separate logical index for each foreign key, or combine all foreign key within a single logical index ?

Tks
0
 
LVL 47

Expert Comment

by:Vitor Montalvão
ID: 40439975
Normally you should create an index for each FK so will boost the JOIN between tables.
Don't create a composite index just for saving indexes.
0
 

Author Comment

by:AXISHK
ID: 40440000
One quick question, what's my consideration to create a composite index over  a single index for each FK ?  Tks
0
 
LVL 47

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 40440071
My recommendation is to create indexes for FK with the same fields. A composite index for a FK will only make sense if the FK is composed by more than one field.
If a table has for example 4 FK's and each FK are relative to different tables then you should create 4 indexes, one for each FK. But if for example the table only has a FK that is composed by 4 fields and relative only to another table, then you should create a composite index with those 4 fields.

Hope that I was clear.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question