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 three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three unordered lists that have been created as Scriptaculous Sortables so that
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three models: class ReleaseItem < ActiveRecord::Base has_many :pack_release_items has_one :pack, :through =>
I have three (C++) classes: Player, Hand, and Card. Player has a member, hand,
I have three divs : <div id=login /> <div id=content /> <div id=menu />
I have three TextBox controls on the page <asp:TextBox ID=TextBox1 runat=server AutoPostBack=True OnTextChanged=TextBox_TextChanged TabIndex=1>
I have three values I need to align in a dropdown box. How can
I have three easy questions. Does anybody use QuickTest Pro for automated testing? Any

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.