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 8041989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:24:55+00:00 2026-06-05T04:24:55+00:00

My problem domain is advertising, and, to that end, I have a database which

  • 0

My problem domain is advertising, and, to that end, I have a database which contains a table called ADVERT. An advert can have facets (i.e. quasi-taxonomic descriptive terms). So, there’s a FACET table which defines the facets and a FACETTERM table which contains the values for each facet. ADVERTFACETTERMASSIGNMENT is the link table which says which facet term values are allocated to which advert.

So, you may have an advert for a car which has a value “Honda” for it’s “Make” facet, and “Sussex” for its “Location” facet. So if the advert is advert {PK = 14}, and Honda is facet-term {PK = 1} and Sussex is facet-term {PK = 2}, you expect to rows in ADVERTFACETTERMASSIGNMENT { AdvertId, FacetTermId }: 14, 1 and 14, 2.

Given this arrangement, how do I go about finding all the other adverts which are for Hondas in Sussex? In other words, how do I find a set of rows in ADVERTFACETTERMASSIGNMENT which match the rows from that table for a given advert but which are not from that advert?

I am using SQL Server 2008. I have tried using an IN clause, but this returns partial matches, i.e. all Hondas other than in Sussex and all cars in Sussex which aren’t Hondas etc.

To restate my requirements, I need to find all rows from ADVERTFACETTERMASSIGNMENT where those rows contain at least the same facet-term ids as those for another given advert. It doesn’t matter if it has more facet-terms, provided it has at least exactly the same facet-terms as the chosen, comparator, advert.

  • 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. Editorial Team
    Editorial Team
    2026-06-05T04:24:58+00:00Added an answer on June 5, 2026 at 4:24 am

    This is basically an EAV – Entity, Attribute, Value model with fixed selections of values.

    WITH FLATTENED AS (
        SELECT a.ADVERT_ID, ft.FACETTERM_ID
        FROM ADVERT a
        INNER JOIN ADVERTFACETTERMASSIGNMENT afta
            ON afto.ADVERT_ID = a.ADVERT_ID
        INNER JOIN FACETTERM ft
            ON ft.FACETTERM_ID = afta.FACETTERM_ID
        INNER JOIN FACET f
            ON f.FACET_ID = ft.FACET_ID
    )
    SELECT rhs.ADVERT_ID, COUNT(*)
    FROM FLATTENED lhs
    INNER JOIN FLATTENED rhs
        ON lhs.ADVERT_ID = @SOME_ID
        AND rhs.ADVERT_ID <> lhs.ADVERT_ID
        AND rhs.FACETTERM_ID = lhs.FACETTERM_ID
    GROUP BY rhs.ADVERT_ID
    HAVING COUNT(*) = (SELECT COUNT(*) FROM FLATTENED WHERE ADVERT_ID = @SOME_ID)
    

    The technique here is that the number of matched facets in the inner join between any two adverts has to be equal to the number of facets of the object advert on the left hand side.

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

Sidebar

Related Questions

Here is my problem: Domain: I have following Entities: [Sensor] that can be positioned
I have a problem with the code analysis rule CA1726:UsePreferredTerms . Our business domain
I have been spending some time on this. My problem involves bringing back domain
Problem domain We have Projects and Milestones Once created, a Milestone has a Project
It is said that the Domain Model is used to capture the problem domain
I read that Domain Driven Design is about concentrating on the problem domain instead
I am new bie in grails and i have following query. Problem Domain: Parent
How are cross-domain web tracking services implemented (e.g., for behavioral advertising ), now that
I have two tables with hierarchyid fields, one of which is a staging table
Problem Domain: I am working on a new revision of a Java application that

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.