SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Bad Microsoft DB Schema Example


Bad Microsoft DB Schema Example

Author
Message
okkko
okkko
Valued Member
Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)

Group: General Forum Members
Points: 67 Visits: 82
OK, generally I try to avoid or ignore bad things. But I think this is important. I'm relearning about DB design concepts and I stumbled upon this Microsoft examples page. I haven't looked closely to all of them but the one example that even has a video is 3rd example.

And here's the image:


What really bothers me is that they have a "real-world" examples and then they create a table Products that holds the data for both books and coffee!

So, even if there is a store that sells books and coffee (I guess it's possible), wouldn't it be better if there was a general "Products" table and then two separate tables for "Books" and "Coffee" with specific columns?

Somebody enlighten me please why they put such example on their official page and tell me if I'm right. What if the store sold just 10 different product and each product has only 10 specific columns - a table with 100+ columns! I am 98% sure this is really bad table design and should be avoided.

p.s.: A link with better real-world examples possible with tables?
Christopher Stobbs
Christopher Stobbs
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5356 Visits: 2233
Other thing is to maybe create a ProductsBook and ProductsFood table?

What do people think of this?

----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley

w00t
Posting Best Practices
Numbers / Tally Tables

SQL-4-Life
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)

Group: General Forum Members
Points: 92013 Visits: 38954
Not knowing the full details of the example it is difficult to make a judgement. One thing to remember is that while designing a database for a production application (as opposed to one for database class) you will make decisions to denormalize a design for performance reasons. Although it may make sense to split off those aspects of the data that relate only to books or coffee into their own table, you may experience performance issues as you increase the number of tables you have to join in a query.

Cool

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
okkko
okkko
Valued Member
Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)

Group: General Forum Members
Points: 67 Visits: 82
Lynn Pettis (6/12/2008)
Not knowing the full details of the example it is difficult to make a judgement. One thing to remember is that while designing a database for a production application (as opposed to one for database class) you will make decisions to denormalize a design for performance reasons. Although it may make sense to split off those aspects of the data that relate only to books or coffee into their own table, you may experience performance issues as you increase the number of tables you have to join in a query.

Cool


As in? Like when you'd want to see all data of all products that were ordered on a certain date? If it's just one Products table this is fast as opposed to each product in a separate table? Wouldn't that query look a mess and all columns irrelevant to a product (book_author for coffee) would be null?
What if you have 50 products?
Christopher Stobbs
Christopher Stobbs
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5356 Visits: 2233
WEll you need to remember that you shouldn't use SELECT * so you should return the book columns in a food query

----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley

w00t
Posting Best Practices
Numbers / Tally Tables

SQL-4-Life
okkko
okkko
Valued Member
Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)

Group: General Forum Members
Points: 67 Visits: 82
Christopher Stobbs (6/12/2008)
WEll you need to remember that you shouldn't use SELECT * so you should return the book columns in a food query


Hehe, yes of course. BigGrin How would you return just the relevant product data for each product?

Anyway, so this example diagram is not so bad after all? And just because of the performance issues?
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)SSC Guru (92K reputation)

Group: General Forum Members
Points: 92013 Visits: 38954
I'm not making any judgements on the design. I was trying to point out that somethings that don't seem right could be based on other factors.

You could desgin a database system that totally eliminates all null values in tables. It has a name, 6th normal form. Would I implement such a design for an OLTP system, no. Biggest reason, performance. The number of table joins required to pull data together would be costly.

Also, in this design, you are only looking at the database schema. I have no idea what the UI design is. It may take into account the different products and use different screens or web pages dependent on the product type. From what was posted, that is unknown.

Also, you should never use a SELECT * FROM ... in your production code.

Cool

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)SSC Guru (95K reputation)

Group: General Forum Members
Points: 95653 Visits: 33013
Unless there's a pretty major application or performance reason, I'd have to agree that this is a crappy "real world" example.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Matt Miller (4)
Matt Miller (4)
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28533 Visits: 19002
Grant Fritchey (6/12/2008)
Unless there's a pretty major application or performance reason, I'd have to agree that this is a crappy "real world" example.


Not fully understanding the background on how that was used - was it being portrayed as being a crappy model example or was this the final result? Because that's a fairly ugly example to be sure.

----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
okkko
okkko
Valued Member
Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)Valued Member (67 reputation)

Group: General Forum Members
Points: 67 Visits: 82
It seems that some of you have missed my link:
source page
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search