Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 172313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:08:37+00:00 2026-05-11T13:08:37+00:00

I have three denormalized tables that I have to take at face value (data

  • 0

I have three denormalized tables that I have to take at face value (data comes from some external resource). The three tables have different definitions, but they each describe the same object from different perspectives.

   object1  A  B    object2  A    object3     B  C    object4        C 

The only commonality between these tables is their primary key. I can corral the IDs together using SELECT UNION SELECT, but the query seems relatively slow, even when each table has its PK field indexed. I could create a view to abstract this query, vw_object_ids, but it performs at the same speed. I thought I could add an index to materialize the view, but in SQL Server 2005, you can’t index views with UNIONs.

What I want is to have a master index of IDs be in sync with with the underlying data, which may get updated or deleted whenever. I guess I could accomplish this indefinitely with a crazy set of triggers or just settle for the speed of the unindexed view. But I just wanted to make sure I’m not missing any options or if this scenario has a name or is indicative of a pattern.

Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:08:38+00:00Added an answer on May 11, 2026 at 1:08 pm

    Create a master table that contains only the ID:

    CREATE TABLE master (ID INT NOT NULL PRIMARY KEY) 

    and make all three tables to refer to that master table with ON DELETE CASCADE.

    To populate the table for the first time, issue

    INSERT INTO    master SELECT  id FROM    a UNION SELECT  id FROM    b UNION SELECT  id FROM    c 

    To populate the table on a regular basis, create a trigger on each of three tables.

    This trigger should try to insert the new ID to master and silently fail on PRIMARY KEY violation.

    To query, use:

    SELECT  * FROM    master m LEFT OUTER JOIN         a ON      a.id = m.id LEFT OUTER JOIN         b ON      b.id = m.id LEFT OUTER JOIN         c ON      c.id = m.id 

    This will use indexes efficienty.

    To delete, use:

    DELETE FROM    master WHERE   id = @id 

    This will fire ON DELETE CASCADE and delete records from all three tables if any.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have denormalized data (coming from a file) that needs to be imported into
We have a data warehouse with denormalized tables ranging from 500K to 6+ million
I have three tables. I have to retrieve the data using Linq statement. My
I have a table with some denormalized precalculated columns that are maintained by a
I have existing tables that are pretty much denormalized. There are no lookup tables
I have two tables: boughtItems(buyerId,ItemId) and denormalized(buyerId,item1,item2,item3,item4,item5) Let's assume that in boughtItems table each
Have three divs in a container that I want to float over a large
I have three divs, within a content div. Container width 70%. Within that I
I have three tables (individuals, groups & recordlabels) and want use the information between
I have three classes that I am using and have shortened for ease of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.