tags:

views:

116

answers:

4

At my work everyone has sql snippets that they use to answer questions. Some are specific to a customer, while some are generic for a given database. I want to consolidate those queries into a library/repository that can be accessed by anyone on the team. The requirements would be:

  1. Accessible
  2. Searchable
  3. Tagable (multiple tags allowed per sql)
  4. Exportable (create a document containing all queries with certain tags)

I'm interested in what has been found to work in other team environments.

+9  A: 

You could use a wiki.

You could get started with something as simple as Tiddly wiki.

johnstok
that is a great idea! I don't believe I didn't think of that! I am going to start this at my place this afternoon.
Kevin
A: 

Rather than pasting SQL snippets, I would consider graduating to an ORM (Object-Relational Mapper) or some other library to make representing and manipulating the data easier. It provides a layer of encapsulation to guard against schema changes and a layer of abstraction so you can think of the data in terms of business logic (ie. a user) rather than a collection of tables (ie. a user table, a password table, an access table...).

In Perl this would be something like DBIx::Class.

Schwern
+1  A: 

A wiki is a great approach.

For database specific or project specific snippets it's also very useful to have links to where a similar construct occurs in the code. We use trac's wiki which gives nice integration with out SVN for this.

Bell
A: 

Another approach you may want to look at is creating views in your database. 'select * from some_view' can hide quite a bit of SQL. You'll still want to use a wiki to document them, but if its a view you don't have to worry about people keeping outdated copies.

derobert