views:

153

answers:

3

Is there such a thing as Design Patterns in SQL ???

+4  A: 

A design pattern is simply a recognised way of solving a problem that works in different specific circumstances. Do such things exist in SQL? Of course - for example implementing many to many relationships between two tables using a third table.

anon
+3  A: 

You may want to look at database normalization which is some sort of general Design Pattern in SQL.

neo
There is also a SQL 'anti-pattern' book coming soon.http://www.pragprog.com/titles/bksqla/sql-antipatterns
Eno
And I've looked at two chapters of said book, and at this point, it's got some magnificent errors in it. The following from the book is supposed to fetch a random row from a table in Oracle, and it's got two showstopper errors in it: $offset = $pdo->query("SELECT dbms_random.value(1, (SELECT COUNT(*) FROM Bugs) AS offset FROM dual)")->fetch(); $stmt = $pdo->prepare("SELECT * FROM Bugs WHERE ROWNUM = :offset" ); $stmt->execute( $offset ); $rand_bug = $stmt->fetch();
Adam Musch
+4  A: 

Yes. :)

SQL Design Patterns: Expert Guide to SQL Programming

(Not even sure if this is a recommended book.. just illustrating that "proper design" exists).

08Hawkeye
I live in a universe of "improper design" in both the host side(.NET) and database side(MS SQL SERVER). I am just wondering if I will ever get to work in an evironement where fellow programmers DON'T take pride in shunning books and "GETTING THE JOB DONE".
Berlioz
You and me both my man. We are constantly balancing results vs. good OO code. Seems like one or the other always has to suffer...
08Hawkeye