Your SlideShare is downloading. ×
Db design
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Db design


Published on

I am not the author of this file but wanted to collect it for study purpose.

I am not the author of this file but wanted to collect it for study purpose.

  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Database Design Patterns
    Stephen Forte
  • 2. Speaker.Bio.ToString()
    CTO and co-Founder of Corzen, Inc.
    Sold to Wanted Technologies (TXV: WAN)
    International Conference Speaker for 10+ Years
    RD, MVP and INETA Speaker
    Wrote a few books
    SQL Server 2005 Developers Guide (Microsoft Press)
    Co-moderator & founder of NYC .NET Developers Group
    Former CTO of Zagat Survey
  • 3. What Are Design Patterns?
    What Are Design Patterns?
    Design Patterns for Databases?
    Data Model Patterns
    Infrastructure Patterns
  • 4. What Are Design Patterns?
    Standard solutions to common problems in software design
    Real-world, proven techniques
    About design and interaction of objects
    Provide a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges
  • 5. Where Did They Come From?
    Roots in architecture field for following patterns in building buildings and cities
    Urban planning
    Christopher Alexander (1950s)
    Started to develop for IT in the 1970s
    Smalltalk contributed patterns
    In 1987 Kent Beck and Ward Cunningham presented their “patterns” at the OOPSLA
    Classic book: Steve Burbeck
    Application Programming in Smalltalk-80 (1992)
  • 6. Gang of Four
    The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns
    Classic Text: Design Patterns: Elements of Reusable Object-Oriented Software (1994)
  • 7. Why Use Design Patterns?
    Can speed up the development process by providing tested, proven development paradigms
    Proven design elements
    Used from other software engineering projects
    Withstood scrutiny from the software development community
    Mitigates a project’s risk
    Makes a project more predictable
    Allow developers to communicate using well-known and well understood names for software interactions
  • 8. General Solution Templates
    Design patterns provide general solutions
    Documented in a format that doesn't require specifics tied to a particular problem
    Design patterns are only a template
    Up to you to apply to a problem and implement
  • 9. What Are Design Patterns?
    Design Patterns for Databases?
    Design Patterns for Databases?
    Data Model Patterns
    Infrastructure Patterns
  • 10. Design Patterns for Databases?
    Why not?
    All the logic applies to database design as to software
    They exist but have not been documented as well as they have for software development
    Not for C# code, but for actual databases
  • 11. Database Design Patterns
    Data model patterns
    Multi-User Highly Transactional design pattern
    Slowly Changing Dimensions design pattern
    Data Warehouse design pattern
    Infrastructure patterns
    Highly-available patterns
    Point of Failure design pattern
    Data partitioning patterns
    Horizontal Partitioning
    Vertical Partitioning
  • 12. What Are Design Patterns?
    Design Patterns for Databases?
    Data Model Patterns
    Infrastructure Patterns
    Data Model Patterns
  • 13. Data Model Patterns
    Choosing the most efficient physical database design should be easy
    Almost every database you design should fall into one of three patterns
    The most common mistake is mixing different models into the same database
  • 14. Data Model Patterns
    Multi-User Highly Transactional (OLTP)
    Slowly Changing Dimensions (SCD)
    Data Warehouse (OLAP)
  • 15. Transactional Design Pattern
    Any data model that collects data
    Your typical OLTP
    Even if “transactions” (BEGIN TRANS) are not used
    Standard database normalization
    First normal form
    Second normal form
    Third normal form
    Can explore templates for data models based on the category of data you are collecting
  • 16. Data Model Categories
    Order Entry
    People and Organizations
    Sports Scores 
    Time/Item Tracking
  • 17. Slowly Changing Dimension Design Pattern
    Anything that can be derived from an OLTP database for reporting or web view
    Biggest mistake is to run a query against loads of normalized “raw” data
    Traditionally “flatter”
    Some de-normalized aspects
    Good implementation of XML
    Highly indexed since the data is “published”
  • 18. SCD Design Pattern
    Optimized for reporting, Web access
    Usually the #1 mistake is to try to merge this into one system
    ETL becomes very important in this design pattern
    Published Database
  • 19. SCD Databases
    My former employer: Zagat
    Raw data OLTP of about 4 million records
    Published SCD of about 200K records, updated nightly as reviews came in
    My current employer: Corzen
    Raw data OLTP of about 800 million records
    Published SCD data of about 12 million records, updated weekly as the time series dictates
    Even a pure play e-commerce site like has a OLTP and SCD pattern:
    OLTP: All ordering
    SCD: Product catalog
  • 20. demo
    Building an SCD Database
  • 21. Data Warehouse Design Pattern
    DSS data with pre-calculated rollups
    Star schema
    Simplest data warehouse schema
    Consisting of a single "fact table" with a compound primary key
    One segment for each "dimension,“ with additional columns of additive, numeric facts
  • 22. Star Schema
    Fact tables and dimension tables
    Fact tables in star schema are mostly in third normal form, but dimensional tables are in de-normalized second normal form
    If you want to normalize dimensional tables, they look like snowflakes (another pattern)
    The same problems of relational databases arise!
    Need complex queries!
    Avoid the temptation to normalize the dimensional tables!!!
  • 23. Star Schema
  • 24. demo
    Populating Fact Tables
  • 25. What Are Design Patterns?
    Design Patterns for Databases?
    Data Model Patterns
    Infrastructure Patterns
    Infrastructure Patterns
  • 26. Infrastructure Patterns
    Highly-available patterns
    Data partitioning data patterns
    Horizontal Partitioning
    Vertical Partitioning
  • 27. Highly-Available Patterns
    “% 9s” uptime: 99.999%
    Less than 5 minutes of unscheduled downtime a year
  • 28. HA Patterns
    PoF pattern avoids a single point of failure
    Redundancy on all fronts-database, hardware
    Log shipping
    Microsoft SQL Server 2005 changes the equation
    Always on Technologies available with SP1
    Point of Failure Pattern
  • 29. Data Partitioning Data Patterns
    Solving the problem of data bloat
    Advantages of moving less frequently accessed data to different disks
  • 30. Data Partitioning Data Patterns
    Horizontal Partitioning
    Vertical Partitioning
  • 31. Horizontal Partitioning
    Table Partitioning
    The process of splitting a table into pieces with the same structure but fewer rows
    Annual, Quarterly, Region
  • 32. Horizontal Partitioning
    Good for archived data over a time series
    Move to a separate device-can be a read only device
    Will drive a developer crazy if you have to UNION it all back-but usually worth the tradeoff
  • 33. Horizontal Partitioning
    SQL Server 2005 Table and Index Partitioning
    Keep data in one table
    Groups of data stored in other files
    Only get a benefit if you have more than one disk
  • 34. DEMO
    Horizontal Partitioning
  • 35. Data Partitioning Data Patterns
    Horizontal Partitioning
    Vertical Partitioning
  • 36. Vertical Partitioning
    The process of splitting the table into different parts, with fewer columns, but the same amount of rows
    Use a One-to-One relationship
  • 37. Vertical Partitioning
    Great for larger data that is not often needed or changed
    Will help with inserts, updates and deletes performance
    Used by MySpace to break out audio, video, images, HTML, etc,1540,2082921,00.asp
  • 38. DEMO
    Vertical Partitioning
  • 39. Choosing the Correct Partitioning
    Horizontal v Vertical Partitioning-When to use?
    Horizontal good for archived data
    Vertical good for inconsistent data that can be separated but still related to the primary key
    You can use both-depending on your table
  • 40. Summary
    Design patterns are useful for database design
    Designing a table schema follows one of three patterns:
    Infrastructure patterns help before and after your initial design
  • 41. Q&A
  • 42. Thanks
    Please fill out your evaluation form!Remember to put “Design Patterns” in the subject