Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Filtering attributes across a many-to-many table?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-28 : 08:08:45
Paul writes "Hello

I've got a really complicated query to do and wonder if you can help me...

The main table is called "Transaction" - this contains a transaction id and a reference

each transaction has many (0 - unlimited) attributes associated with it:

Attribute(AttributeTypeId, AttributeName)

So....

For "Transaction 1" it has:
Attribute: 1, Red
Attribute: 2, Medium

For "Transaction 2" it has:
Attribute: 1, Blue
Attribute: 2, Medium

- in the real database each Transaction commonly has about 10 attributes, but could have as many as it needs (which is why we've done it like this)


The problem that I've got is how do I filter on the attributes?

So...

Filter: Red/Medium - returns Transaction 1
Filter: Blue/Medium - returns Transaction 2
Filter: Medium - returns Transaction 1 & 2



--- but I don't know how to do that, are you able to help?

Over time, the database is going to grow to millions of transactions (literally)...so somehow it needs to be actually as efficient as possible, that's the main worry (apart from actually being able to do it in the first place!!)

I really look forward to your reply!!

Many thanks, Paul"

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-28 : 08:13:18
How do you connect attributes to transactions?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

rlaubert
Yak Posting Veteran

96 Posts

Posted - 2007-02-28 : 16:18:00
Are these attributes always in the same order? Is this a commercial app or custom designed?

Raymond Laubert
MCDBA, MCITP:Administration, MCT
Go to Top of Page
   

- Advertisement -