Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
Querying EAV data
14 posts, Page 1 of 2
1
2
»»
Querying EAV data
Rate Topic
Display Mode
Topic Options
Author
Message
Lokesh Vij
Lokesh Vij
Posted Thursday, August 30, 2012 2:36 AM
Ten Centuries
Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 1,176,
Visits: 1,253
Friends,
I am using a third partry tool whose database is modeled using Entity-Attribute-Value model.
What according to you would be the best way to query data. Every time I increase one attribute in my select clause, I need to add a join conditions.
Looking forward for your response.
Thanks
Lokesh
~ Lokesh Vij
Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions
Link to my Blog Post -->
www.SQLPathy.com
Follow me
@Twitter
Post #1352053
Lowell
Lowell
Posted Thursday, August 30, 2012 6:21 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 9:34 AM
Points: 11,638,
Visits: 27,721
can you post some more details? the DDL for the table, a couple of sample rows, and an example of what you have to change wehn you add a new value would help enourmously.
Lowell
--
There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1352141
Evil Kraig F
Evil Kraig F
Posted Thursday, August 30, 2012 2:05 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 4:36 AM
Points: 5,678,
Visits: 6,126
Lokesh Vij (8/30/2012)
What according to you would be the best way to query data. Every time I increase one attribute in my select clause, I need to add a join conditions.
Create a view that will pivot the data for you and hook to that. Otherwise, you're basically stuck working with EAV as you describe to handle additional values as join conditions or to pivot it.
If you know your attribute names you can simply build it once (with further adjustments as necessary) as a pivoted view. Indexing the results may be in your best interest, but you will have to decide about the weight of the pivot updating for every change vs. speed of access to the rest.
- Craig Farrell
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions
|
Forum Netiquette
For index/tuning help, follow these directions.
|
Tally Tables
Twitter: @AnyWayDBA
Post #1352484
Jeff Moden
Jeff Moden
Posted Thursday, August 30, 2012 7:59 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 5:13 AM
Points: 32,906,
Visits: 26,793
Evil Kraig F (8/30/2012)
Lokesh Vij (8/30/2012)
What according to you would be the best way to query data. Every time I increase one attribute in my select clause, I need to add a join conditions.
Create a view that will pivot the data for you and hook to that. Otherwise, you're basically stuck working with EAV as you describe to handle additional values as join conditions or to pivot it.
If you know your attribute names you can simply build it once (with further adjustments as necessary) as a pivoted view. Indexing the results may be in your best interest, but you will have to decide about the weight of the pivot updating for every change vs. speed of access to the rest.
d
Materializing the view as an indexed view may be the best bet for such a thing. Using a pivot or a Cross Tab to create the view without persisting the information would mean that the whole view would probably need to materialize before you could use any of the pivoted columns in something like a join.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1352556
Lokesh Vij
Lokesh Vij
Posted Thursday, August 30, 2012 11:04 PM
Ten Centuries
Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 1,176,
Visits: 1,253
Evil Kraig F (8/30/2012)
Lokesh Vij (8/30/2012)
What according to you would be the best way to query data. Every time I increase one attribute in my select clause, I need to add a join conditions.
Create a view that will pivot the data for you and hook to that. Otherwise, you're basically stuck working with EAV as you describe to handle additional values as join conditions or to pivot it.
If you know your attribute names you can simply build it once (with further adjustments as necessary) as a pivoted view. Indexing the results may be in your best interest, but you will have to decide about the weight of the pivot updating for every change vs. speed of access to the rest.
Thanks Kraig. My first thought was the same --> create a view to hold pivot data. But was bit reluctant, because any changes in the database may trigger changes in the view
Any way thanks for supporting my thoughts. Much appreciated!
~ Lokesh Vij
Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions
Link to my Blog Post -->
www.SQLPathy.com
Follow me
@Twitter
Post #1352589
Lokesh Vij
Lokesh Vij
Posted Thursday, August 30, 2012 11:07 PM
Ten Centuries
Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 1,176,
Visits: 1,253
Jeff Moden (8/30/2012)
Materializing the view as an indexed view may be the best bet for such a thing. Using a pivot or a Cross Tab to create the view without persisting the information would mean that the whole view would probably need to materialize before you could use any of the pivoted columns in something like a join.
Very rightly pointed out. I just had a word with my product vendor reagrding the frequency of change in design. Outcome was that design is frozen.
I will go ahead and materialize my pivot view. Thanks for your kind response.
~ Lokesh Vij
Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions
Link to my Blog Post -->
www.SQLPathy.com
Follow me
@Twitter
Post #1352591
CELKO
CELKO
Posted Friday, August 31, 2012 7:25 AM
SSCommitted
Group: General Forum Members
Last Login: Tuesday, January 15, 2013 11:11 AM
Points: 1,945,
Visits: 2,782
You are screwed; EAV is 10 orders of magnitude worse than even a bad non-normalized schema. Yes, you have to assembly each column with joins and all yiou can do is hide it.
Books in Celko Series for Morgan-Kaufmann Publishing
Analytics and OLAP in SQL
Data and Databases: Concepts in Practice
Data, Measurements and Standards in SQL
SQL for Smarties
SQL Programming Style
SQL Puzzles and Answers
Thinking in Sets
Trees and Hierarchies in SQL
Post #1352797
Lokesh Vij
Lokesh Vij
Posted Friday, August 31, 2012 8:46 AM
Ten Centuries
Group: General Forum Members
Last Login: Today @ 8:24 AM
Points: 1,176,
Visits: 1,253
CELKO (8/31/2012)
You are screwed; EAV is 10 orders of magnitude worse than even a bad non-normalized schema. Yes, you have to assembly each column with joins and all yiou can do is hide it.
My company should have involved in POC before zeroing-in-on this crappy product.
~ Lokesh Vij
Guidelines for quicker answers on T-SQL question
Guidelines for answers on Performance questions
Link to my Blog Post -->
www.SQLPathy.com
Follow me
@Twitter
Post #1352868
Michael Valentine Jones
Michael Valentine Jones
Posted Friday, August 31, 2012 9:09 AM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 9:55 PM
Points: 2,944,
Visits: 10,510
I would be very careful with the materialized view.
There is a lot of potential for blocking or deadlocks, so you may find it just makes things worse.
Post #1352890
RBarryYoung
RBarryYoung
Posted Friday, August 31, 2012 9:28 AM
SSCrazy Eights
Group: General Forum Members
Last Login: Saturday, May 04, 2013 11:13 AM
Points: 9,855,
Visits: 9,374
This is basically the price you pay for the flexibility that EAV brings.
And developers love EAV because its seems like a dream during the Design and initial Development phases, especially compared to the apparent unreasonable strictures and inflexibility of SQL and Relational Data Design. Plus EAV intuitively maps better to the OAV concepts implicit in Object-Orientation.
Of course they don't understand the maintenance and administration issues that come along with it. Nor even the massive effort overhead of actually doing the development correctly, that doesn't become apparent until Version 2 (or late in the V1 development, if they've got good testing and acceptance procedures).
-- RBarryYoung
,
(302)375-0451
blog:
MovingSQL.com
, Twitter:
@RBarryYoung
Proactive
Performance Solutions, Inc.
"Performance is our middle name."
Post #1352910
« Prev Topic
|
Next Topic »
14 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.