Database Reference
In-Depth Information
When you sort strings, the first letter is examined and sorted, then the
second letter, and then the third, and so on. This causes our date data to
get out of whack. After 1/1/2007, the next number in the alphanumeric sort
is 1/10/2007. This makes for an ugly result set.
To get around this problem now, you must convert the StringDate col-
umn during your select operation. We won't go into the details of the query
engine, but suffice it to say, the conversion of a string into a date adds over-
head to the select query. Paraphrasing a saying from a wise, uh, man,
“Overhead leads to higher CPU utilization, higher CPU utilization leads to
poor performance, poor performance leads to suffering.” Again, had we
used the correct data type, we could have avoided the problem of needing
to convert the string and avoided the eventual suffering.
Slow Join Performance
When you need to join your foreign key tables to your primary key tables,
the slowest joins occur when you use strings. This is a generalization, but
it usually holds true. That being said, you want to avoid using strings as key
fields when possible. So using nothing but strings would obviously violate
this guideline. If you use the appropriate data types, you will reduce the
possibility of having a string in your key field.
Relationship Problems
One of the trickiest parts of building a data model is getting all your rela-
tionships correct. Assuming that you have created all the appropriate enti-
ties, you still have to build relationships between them. This quandary is
compounded by a couple of tricky relationship types, specifically one-to-
one and many-to-many relationships.
One-to-One Relationships
Although 1:1 relationships have their place, they often split an entity in two
that should in fact remain a single entity. A good 1:1 relationship is some-
thing like presidents to countries. Each country has only one president,
and each president is president of only one country. In this case, each
of these entities is different, but the relationship needs to be constrained
to 1:1.
 
 
Search WWH ::




Custom Search