Here's a real-life challenge I was faced with at work: my company (a talent agency) needed me to create a report listing all of our actors that we represent - and for each actor, a comma-delimited string of each production that they've starred in. Simple enough, right......except that, within the comma-delimited list of productions, they wanted those productions that were "theatre" productions to be shown in italics!
Luckily, the front-end tool that would display the data was HTML-aware. So, the challenge became, "How do I dynamically generate the appropriate HTML tags around each item in the list that's in the theatre category?"
Below is the code I came up with to do this. Of course, I have simplified it greatly, and am using some "dummy" tables in this example, But at least you can get the concept from the example below. (Note: this uses a UDF, so it will only work in SQL 2000. If you're using version 7, you must extract the code and run it as straght SQL).
A Normalization Primer
For most DBAs, normalization is an understood concept, a bread and butter bit of knowledge. However, it is not at all unusual to review a database design by a development group for an OLTP (OnLine Transaction Processing) environment and find that the schema chosen is anything but properly normalized. This article by Brian Kelley will give you the core knowledge to data model.
2003-01-13
18,614 reads