Re: Database Design



Paul (paulwragg2323@xxxxxxxxxxx) writes:
I have posted a question in the Database design and theory ng, but I
expect a lot of you will have suggestions to help me (and that ng
doesn't seem very active).

The post is here:


http://groups.google.co.uk/group/comp.databases.theory/browse_frm/thread/5db
717bb37ca5b0f?hl=en

Any help would be appreciated.

Your intended design may or may not make sense. I recall that exactly in
the case of telephone numbers we did that transformation in our system.

The design you aim at is known as EAV, and many frown at it. But there are
definitely cases where this design make sense.

What is the problem with it? You've already discovered it: writing the
queries. They are more difficult to write, and if you misspell and
attribute code, there is no compiler to tell you.

For the particular query you had problem with, this is the best way of
writing it:

SELECT per.id, per.dob,
Home = MIN(CASE ph.Type WHEN 'Home' THEN ph.Value END),
Mob = MIN(CASE ph.Type WHEN 'Mob' THEN ph.Value END),

But if you find that you need to write a lot of those queries, you are
probably going in the wrong direction.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Problem when changing Views
    ... There aree several reasons. ... I use neither of the tools, but I guess that Design View resubmits the ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Database Design
    ... Mob = MIN, ... LEFT JOIN phones Home ON per.person = Home.person ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: What is better to use?
    ... The second design is the more natural design in my opinion. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Recommendations for SQL Server-compatible database design tool?
    ... PD as a whole range of design modules, ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.tools)
  • Re: Odd SQL IN usage?
    ... for each row call a stored procedure that unpacks the row into a ... you should strive of changing the database design to move away ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)

Loading