﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Josh Schwartzberg commented on Resolution: Efficient Querying</title><description>@Alexey Chabunin : It looks like the visual studio class designer.
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment10</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment10</guid><pubDate>Mon, 15 Feb 2010 22:03:02 GMT</pubDate></item><item><title>Richard Armstrong commented on Resolution: Efficient Querying</title><description>I agree with this approach, though how would one represent multiple authors? As serialzed JSON or XML data? For those that don't like denormalization you should read this article by Obasanjo: Building Scalable Databases. Some applications just won't scale without it.
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment9</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment9</guid><pubDate>Mon, 15 Feb 2010 06:58:24 GMT</pubDate></item><item><title>John Simons commented on Resolution: Efficient Querying</title><description>Why not simplify the model by applying CQRS?
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment8</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment8</guid><pubDate>Mon, 15 Feb 2010 03:02:34 GMT</pubDate></item><item><title>Alexey Chabunin commented on Resolution: Efficient Querying</title><description>An off-topic question: What tool do you for class diagram drawing? I saw it in ASP.NET MVC book and now in your blog - it looks clean and clear...
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment7</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment7</guid><pubDate>Mon, 15 Feb 2010 02:08:11 GMT</pubDate></item><item><title>Rafal commented on Resolution: Efficient Querying</title><description>It's not denormalization, it's amputation.
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment6</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment6</guid><pubDate>Sun, 14 Feb 2010 07:39:18 GMT</pubDate></item><item><title>Andrey Shchekin commented on Resolution: Efficient Querying</title><description>This is something that requires a specific mindset. Even when I do some hacking/duct-taping, I can not force myself to use denormalization (except for caching/as a rebuildable view).
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment5</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment5</guid><pubDate>Sat, 13 Feb 2010 20:28:57 GMT</pubDate></item><item><title>CodeAddict commented on Resolution: Efficient Querying</title><description>Ah that's true, I forgot a GROUP BY at the end:
  
  
SELECT u.*, b.*, q.Index, GROUP_CONCAT(CONCAT(a.Id, ';', a.Name) SEPARATOR ',')
  
FROM Users u
  
JOIN UsersWaitingBooks q ON q.User = u.Id
  
JOIN Books b ON b.Id = q.Book
  
JOIN BooksAuthors ba ON ba.Book = b.Id
  
JOIN Authors a ON a.Id = ba.Author
  
WHERE u.Id = 1 
  
GROUP BY b.Id
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment4</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment4</guid><pubDate>Sat, 13 Feb 2010 15:04:23 GMT</pubDate></item><item><title>Leonardo commented on Resolution: Efficient Querying</title><description>But you changed the model, now you are constraining the books to have only one Author, where as the previous model allowed to have various ones. That is something that is not always applicable, you had to know something else.
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment3</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment3</guid><pubDate>Sat, 13 Feb 2010 14:23:39 GMT</pubDate></item><item><title>CodeAddict commented on Resolution: Efficient Querying</title><description>MySQL has a GROUP_CONCAT function for this. I don't know if it performs well, and it's probably not supported in any other RDBMS. But I find it a nice solution to the problem. I use it a lot for selecting all tags on a set of posts in one query.
  
  
With GROUP_CONCAT the query could be:
  
  
SELECT u.*, b.*, q.Index, GROUP_CONCAT(CONCAT(a.Id, ';', a.Name) SEPARATOR ',')
  
FROM Users u
  
JOIN UsersWaitingBooks q ON q.User = u.Id
  
JOIN Books b ON b.Id = q.Book
  
JOIN BooksAuthors ba ON ba.Book = b.Id
  
JOIN Authors a ON a.Id = ba.Author
  
WHERE u.Id = 1
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment2</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment2</guid><pubDate>Sat, 13 Feb 2010 13:59:25 GMT</pubDate></item><item><title>Frans Bouma commented on Resolution: Efficient Querying</title><description>You have an objectified relationship in your model (queue) which by definition is an entity on its own. You see that with the table it requires (UsersWaitingBooks). In general it's a 'smell' (to use a term common to code oriented folks ;)) to hide these entities under the rugs, as they contain non-pk attributes (fields) which means they can't be saved properly. 
</description><link>http://ayende.com/4398/resolution-efficient-querying#comment1</link><guid>http://ayende.com/4398/resolution-efficient-querying#comment1</guid><pubDate>Sat, 13 Feb 2010 12:00:27 GMT</pubDate></item></channel></rss>