I've been refining the core classes in the business model, the snapshot below
illustrates the overall design of the business model. I've spent the some
upfront time making sure that I can create, load and save core classes
(Producer, Wine) to the data store. The Wine class posed a particularly
interesting problem in that it also required the loading and saving of the
contained Producer class. I didn't want the Wine class to be dependent on the
ProducerRepository, so I used the idea of a ProducerAssociate class as discussed
by
Steve Maine. To simplify the diagram, I purposely left out the
WineRepository and it's associated WineFactory class.

In this post, I want to focus on a Wine's Varietal. The
Wine Diva lists
128 grape varieties,
and in reality there are many more when you take into account regional growing
areas and clone varieties. Initially, I modeled the Varietal property as a
string on the wine class. After looking at the multitude of grape varieties, and
how some varieties are simply synonyms for others, I realized I wanted more than
just a name. So I came up with the following definition.

Now, I can query the Derivatives property to get a list of
Varietals that the grape is a synonym for. If the wine is a Blend, of say
Cabernet Sauvignon and Merlot, the Blend property will be populated, the Percent
representing the amount of one varietal versus another. I may also add a Parent
property of type Varietal which would point to the root or parent of the
Varietal. For example, Auvernat, Beaunois, Epinette Blanche, Pinot Chardonnay,
and Feiner Weiseser Burgunder are all types of the Chardonnay grape.
So how to handle this in the database? I'll start off with a
Wine table that has a foreign key to the Varietal table. If the wine is of a
Blend varietal, it will also have multiple WineVarietal records for the WineId.
I'm thinking that I'll have to put some "special" code to recognize the "Blend"
varietal, and maybe even add an IsBlend property to the Varietal class.

Next up? Tackling the Appellation issue. Of course I may not
write for awhile. I'm heading off to Barcelona for a few days, then on a bit of a
cruise. Anybody know any good sights in Barcelona or Marrakesh? Hopefully the
weather will be good, it's mighty cold here in Bellevue.