dbTalk Databases Forums  

Normalization Pitfalls

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Normalization Pitfalls in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
eric.nave@gmail.com
 
Posts: n/a

Default Normalization Pitfalls - 02-20-2008 , 02:02 PM






I have to give a little presentation on database theory, and I'm
looking for a few good examples of questions that cannot be (easily)
answered if a database isn't normalized. If you have any examples
that I could use, I'd greatly appreciate it.

Here's one that I've got so far:
A social club kept track of members, their spouses, and children in an
Excel spreadsheet, which they imported into a database. The single
table looks like this
create table members (
firstName varchar(20),
child1 varchar(20),
child1age tinyint,
child2 varchar(20)
child2age tinyint,
)

problem: list the names of any children eligible to participate in the
trick or treat outing, which is open to kids 5-10 years old.

select child1 as childname from members where age >= 5 or age < 10
union select child2 as childname from members where age >=5 or age <
10

so as you can see, I can do it, but it's cumbersome. The actual
database might have 10 child fields. It's *much* nicer if the
children are in another table.

I'm looking for examples like this one. Any help is appreciated.
Just a simple narrative will do. You don't have to provide code
unless you want to.

thanks

Reply With Quote
  #2  
Old   
--CELKO--
 
Posts: n/a

Default Re: Normalization Pitfalls - 02-20-2008 , 03:10 PM






http://www.marcrettig.com/poster/

This is a classic and it is free to download. I have an original in
my office.


Reply With Quote
  #3  
Old   
David Portas
 
Posts: n/a

Default Re: Normalization Pitfalls - 02-20-2008 , 04:13 PM



<eric.nave (AT) gmail (DOT) com> wrote

Quote:
I have to give a little presentation on database theory, and I'm
looking for a few good examples of questions that cannot be (easily)
answered if a database isn't normalized. If you have any examples
that I could use, I'd greatly appreciate it.

Here's one that I've got so far:
A social club kept track of members, their spouses, and children in an
Excel spreadsheet, which they imported into a database. The single
table looks like this
create table members (
firstName varchar(20),
child1 varchar(20),
child1age tinyint,
child2 varchar(20)
child2age tinyint,
)

problem: list the names of any children eligible to participate in the
trick or treat outing, which is open to kids 5-10 years old.

select child1 as childname from members where age >= 5 or age < 10
union select child2 as childname from members where age >=5 or age
10

so as you can see, I can do it, but it's cumbersome. The actual
database might have 10 child fields. It's *much* nicer if the
children are in another table.

I'm looking for examples like this one. Any help is appreciated.
Just a simple narrative will do. You don't have to provide code
unless you want to.

thanks
Fabian Pascal's book Practical Issues in Database Management has some of the
clearest diagrams and explanations of normalization around.

It's curious that you should approach the topic in this way. The purpose of
normalization is not to make it easier to write queries but to avoid data
anomalies.

Your example is also a potentially misleading one. The term "repeating
groups" does NOT refer to repeated sets of columns in a table. It means
repeated sets of values within a *column* - something which is impossible to
do in SQL.

--
David Portas




Reply With Quote
  #4  
Old   
Ed Murphy
 
Posts: n/a

Default Re: Normalization Pitfalls - 02-20-2008 , 10:28 PM



David Portas wrote:

Quote:
Your example is also a potentially misleading one. The term "repeating
groups" does NOT refer to repeated sets of columns in a table. It means
repeated sets of values within a *column* - something which is impossible to
do in SQL.
It's possible (but obviously inadvisable) to fake it, though, e.g.
using a comma-separated list.


Reply With Quote
  #5  
Old   
--CELKO--
 
Posts: n/a

Default Re: Normalization Pitfalls - 02-21-2008 , 07:25 AM



Quote:
It's possible (but obviously inadvisable) to fake it, though, e.g. using a comma-separated list.
LOL! I have a section on various methods for faking it in Section
02.02.01. Note on Repeated Groups of SQL FOR SMARTIES.



Reply With Quote
  #6  
Old   
Anith Sen
 
Posts: n/a

Default Re: Normalization Pitfalls - 02-21-2008 , 09:57 AM



Quote:
It's *much* nicer if the children are in another table.
David's point on "repeating groups" is dead on. The lack of nicety by itself
need not be a normalization issue. In your example, having the child data in
another table seems more of a matter of practicality.

--
Anith




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.