data driven designs 99% of enterprise applications operate on database data or at least interface...

12
Data Driven Designs Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server, Oracle, MySQL. Most development environments (including Visual Studio) support database integration and / or interface with data modeling tools. Tight and accurate data model is essential for a good data-driven design. Data modeler / data analyst and DBA has to be on the development team. Database server is required for the application development and deployment. Application load may become an issue due to database server licensing limitations.

Upload: cleopatra-gallagher

Post on 04-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Data Driven DesignsData Driven Designs

99% of enterprise applications operate on database data or at least interface databases.

Most common DBMS are Microsoft SQL Server, Oracle, MySQL.

Most development environments (including Visual Studio) support database integration and / or interface with data modeling tools.

Tight and accurate data model is essential for a good data-driven design.

Data modeler / data analyst and DBA has to be on the development team.

Database server is required for the application development and deployment.

Application load may become an issue due to database server licensing limitations.

Page 2: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Database DiagramsDatabase Diagrams

Page 3: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Foreign Key RelationForeign Key Relation

+-----+ One-to-one relation +o----+ Zero/one-to-one relation +o---+o< One-to-zero/many relation +o----+o< Zero/one-to-zero/many relation

AllFusion® Erwin® is a popular data modeling tool

Page 4: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Foreign Key RelationForeign Key Relation

SQL Server Foreign Key Relation Diagram

Page 5: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Foreign Key ConstraintsForeign Key Constraints

Linked to foreign primary key / key values.

Primary key values should never change.

Must be enforced to preserve data integrity.

Prevent orphaned child records.

Prevent childless parent records.

Can be enforced via cascade delete / cascade update mechanism.

Page 6: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Data ConstraintsData Constraints

Useful for limiting the range of column values. Must use!

Example: Grade IN ('A','B','C','D','F')

Page 7: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

IndexesIndexes

Greatly improve query performance especially when joining tables and sorting.

Page 8: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Stored ProceduresStored Procedures

Data manipulation code stored in the database.

Stored procedures can result in select queries, update or insert operations or any other non-trivial data manipulation / calculation.

Many believe that it is not a good idea to encode business rules into a database hence stored procedures should never be used or at least should be minimized.

Page 9: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

TriggersTriggers

Triggers are stored procedures that are executed based on specific events.

For instance you can define for a particular table a trigger, which would be fired when a row is in that table is inserted, deleted or updated.

Triggers are notoriously hard to see and hard to remember. They cause numerous problems when used excessively.

Page 10: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

General Data Design RulesGeneral Data Design Rules

1. Store as little data as possible.

2. Create as tight as possible of a database structure preserving and controlling data integrity in the strictest possible way.

- Enforce foreign key constraints- Enforce data constraints- Use NOT NULL attributes

Page 11: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

Specific Data Design RulesSpecific Data Design Rules

1. Avoid Duplication by Normalizing Your Data2. Consolidate Related Non-Shared Information by

Denormalizing Your Data3. Always Define Data Relations and Foreign-Key

Constraints4. Always Define Primary Keys for All Tables 5. Declare User-Defined Types for Range-Limited and

Enumerated Values 6. Declare Required Columns as NOT NULL7. Assign Default Values to Columns When Possible 8. Define Indexes For Foreign Keys and Frequent Filter

Criteria Columns9. Do Not Embed Business Rules in Database: Avoid Stored

Procedures, Complex Check Constraints, Triggers10. Validate Data Both on Client Side and on Database Side

Page 12: Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,

ReadRead

Chapter 11 from my book.