views:

134

answers:

2

I'm writing up documentation for a tool that works with SQL schemas. It would make sense for the documentation to use a common example schema rather than making up a new one. Any recommendations for one that's already defined somewhere?

Ideally it would

  • come from a problem domain most readers are already familiar with;
  • have an example of all the major cardinalities (1-to-many, optional-to-many, many-to-many, optional-to-one) and have examples with and without "cascade delete" ownership;
  • not be mired in meta-terms (not be a schema for schemas for example!)
  • be simple;

I remember MS SQL Server 2000 documentation using their PUBS database, which was a database about publishers and authors and books. Not bad. But Microsoft has moved away from it to AdventureWorks and Northwind. Would anyone recommend any of those?

+1  A: 

AdventureWorks has a pretty standard (read: not exotic) schema. It's more complex than Northwind, but still simple enough to fully grok.

I assume by optional to many you mean a PK/FK relationship where the FK can be null. I haven't checked AdventureWorks to see if it contains all of these cardinalities, but it would be easy enough to add simple examples for the "optional" ones.

Robert Harvey
o.k.w
Thanks guys. I did download an AdventureWorks schema diagram and it was really complete, but maybe overwhelming as an example. It really is an entire enterprise schema. The diagram has the schema divided into about 6 different subschemas.<a href="http://merc.tv/img/fig/Northwind_mdb_physical.gif">Northwind</a> is a lot simpler. Yes, by optional I meant a NULLable FK. I couldn't tell from the diagram if there are any though. The FK from Orders to Employees possibly could be. I definitely did not see any optional-to-one relationships.
Colin Kelley
A: 

If you are talking cross-platform, I woulnd't recommend MS schemas as they are bound to have SQL Server specific features used in the DDL, so you lose the benefit of having DDL provided to you. AdventureWorks seems to be a decent schema, although I have not looked at it carefully. You could create the DDL manually to recreate a similar one in Oracle and others if you want

You can also find tons of other more generic schema examples here:

Database Answers

RedFilter
Thanks! I spot-checked about a dozen of those and they were all clean and simple, but I failed to find one that had the complete variety of cardinalities I'd like for example purposes. But I'll keep looking; the right answer is probably in there somewhere. Worst case I'll probably tweak one to introduce the variety. Optional-to-one seems to be the most uncommon. (An example of that might be CarLoan to Car. A CarLoan must have one Car. A Car may optionally have one CarLoan.)
Colin Kelley