5 ms·
> "show me all ratings for every book that was written by the authors who currently have a book in the top 100 books list." Why not? That seems like a pretty b
by epochwolf 17y ago
> "show me all ratings for every book that was written by the authors who currently have a book in the top 100 books list."
Why not? That seems like a pretty basic SQL query to me, with one nested query. I think we even did something almost exactly like that in my undergrad dB database management class in the first few weeks.
That's more like (sorry, I'm bad at sql too)
SELECT ratings.*, book.name, author.name
FROM ratings
JOIN books ON ratings.book_id = book.id
JOIN authors ON books.author_id == author.id
WHERE author.id
IN (
SELECT author_id
FROM books
JOIN ratings ON book.id = book_id
ORDER ratings.score ASC LIMIT 100
)
You better hope that sucker uses indexes or it's going to be a few minutes. And you better cache that because you don't want that running every time someone hits the recommended reads.
SQL can be pretty scary for this stuff. It would be even worse if you allows a many to many relationship with books and authors.
- elblanco 17y agoLike I said, I'm the world's worst SQL guy. But the good news is that I haven't invalidated my point by my sloppy syntax. So this raises two questions... 1) Who doesn't use indexes these days? Even light solutions like SQLite support them. 2) The only real remaining advantage to RDF is that the data resources can sit on the end of URLs if I remember. I think this is mainly because nobody has put much effort into dangling indexed relational tables at the end of a URL. There's nothing that says I couldn't have SELECT ratings.*, book.name, author.name FROM http://someplace.com/booklists.ratings AS ratings JOIN http://someplaceelse.net/booksales.books AS book ON ratings.book_id = book.id JOIN http://yetsomeotherplace.org/publisherdata.authors AS authors ON books.author_id == author.id WHERE author.id IN ( SELECT author_id FROM books JOIN ratings ON book.id = book_id ORDER ratings.score ASC LIMIT 100 ) Or some such...sure it's sloppy and it's slowish, but aren't those the same problems as with RDF? And yet we're still using SQL to do this.