MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 26th, 2012, 12:05 PM
DCSS DCSS is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Location: Central Valley California
Posts: 2 DCSS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 59 sec
Reputation Power: 0
Question Using Foreign Keys

For years I used a version of SQL called KBSQL developed for use on Unix systems running Mumps databases. One thing I really miss was the ability to use index tables that basically had necessary columns and Foreign Keys to other tables.

So, instead of a Join, I could search against these indexes and link to other tables using the Foreign keys.

For example:

MED_LINK@DSCHRG_DT
MED_LINK@PAT_NAME
MED_LINK@DEMOG_LINK@PAT_SSN

The columns with the _LINK were the Foreign keys. The third example shows linking to another index to use it's Foreign Keys to link to a table.

Using this made the queries run much faster than using the linked to table only or even using Joins instead.

I have been looking for this same capability in MS SQL with no luck. Is there such a capability in MS SQL?

Thanx in advance for any help on this.

Reply With Quote
  #2  
Old June 26th, 2012, 02:58 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,373 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 6 h 53 m 41 sec
Reputation Power: 4140
Quote:
Originally Posted by DCSS
Is there such a capability in MS SQL?
i think the concept is called a covering index

a covering index contains all the columns needed to resolve the sql, consequently there is no need to access table rows at all

this happens all the time... the compiler first inspects all indexes looking for a covering index for the query being parsed, before deciding to retrieve table rows
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old June 26th, 2012, 04:35 PM
DCSS DCSS is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Location: Central Valley California
Posts: 2 DCSS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 59 sec
Reputation Power: 0
Using Foreign Keys

Thanx r937 for the response.

I checked into covering index and that's not quite what I had in mind. The index tables I used in KBaseSQL only had the fields needed for the Foreign Key(s). The actual data I wanted to retireve was found in the tables being linked to by the Foreign Key.

An index that contains all information required to resolve the query is known as a "Covering Index"; it completely covers the query.

If I am missing something, please let me know.

Thanx again for your response.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Using Foreign Keys

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap