Transcript
Page 1: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 1

Yes! Database Design can be this fun

Mark Abramson, CEO, Forward Thought, Inc.10/9/2011

@mark__a

Page 2: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 2

THEORY & ELEMENTS

DEMO

Q&A

10/9/2011

Edgar F Codd

Page 3: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 3

• Microsoft BizSpark Startup Partner• Organizer of BizSparkSF

Meetup Group• Regular customer of all

tools used in demo• Schema-first kind of guy

10/9/2011

Disclosures

Page 4: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 4

What is a database design?

10/9/2011

Page 5: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 5

Why Database Design?

• Gives everyone a clear picture of your business rules and the data behind it

• Build consensus across business units• Separation of

concerns• Ensure data

accuracy• Fun

10/9/2011

Page 6: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 6

Entity / Relationship Model

• An Entity is some “thing” of interest• A Relationship defines the interaction

between one or more Entities

10/9/2011

Page 7: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 7

What’s the data look like?

10/9/2011

SalesOrderId OrderStatus OrderDate PlacedBy IsPriorityOrder CustomerId CurrencyId20001 Shipped 1/5/2011 Bob Smith 0 3 220002 Fulfillment 5/5/2011 John Doe 1 2 220003 Placed 5/7/2011 Brenda Lee 0 3 2

CustomerId CustomerName AccountNumber1 Woolworths 8383822 Rick's Café 2911013 Mill Valley Market 957588

Page 8: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 8

Entity

• Definition• Attributes• Data Types• NULL option• Primary Key• Foreign Key• Identity Columns

10/9/2011

Page 9: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 9

Relationship

• Definition• Identifying• Non-Identifying

10/9/2011

Non-Identifying Relationship

Page 10: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 10

Relationship (2)

• Recursive references• Associative / Many-To-Many /

“Join Tables”

10/9/2011

Page 11: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 11

Cardinality• How many instances of each entity may be

involved or must be involved?

10/9/2011

Page 12: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 12

Keys

• Primary Keys• Foreign Keys• Candidate Keys• Composite Keys

10/9/2011

Page 13: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 13

Normalization

10/9/2011

SalesOrderId OrderStatus OrderDate PlacedBy CustomerAccountNumber CreditLimit

20001 Shipped 1/5/2011 Bob Smith 838382 5000

20002 Fulfillment 5/5/2011 John Doe 291101 10000

20003 Placed 5/7/2011 Brenda Lee 957588 7500

Denormalization

Normalization

Page 14: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 14

Getting Fancy

• First, second, third-normal form• Generalization• Nonspecific relations• Three-way relationships• Constraints• Referential Integrity actions• Zachman’s Framework

10/9/2011

Page 15: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 15

Exercise! Legacy Baggage

10/9/2011

Page 16: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 16

Tools for Creating Your Model

• Paper + Pen / Whiteboard• Drawing Tools: PowerPoint, Visio• ER Tools: Open Source / Community Editions– CA ERWin; Toad; SSMS; MySQL Workbench

• ER Tools: Midrange– Sparx Systems EA $199; Toad $479

• ER Tools: High End– CA ERWin $4000; Embarcadero $2000

10/9/2011

Page 17: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 17

Demo time!

• SQL Server Management Studio (“free”)– http://www.microsoft.com/download/en/details.aspx?id=7593

• RedGate SQL Data Generator ($295)– http://www.red-gate.com/products/sql-development/sql-data-generator/

• RedGate SQL Prompt Pro ($295)

– http://www.red-gate.com/products/sql-development/sql-prompt/

10/9/2011

Page 18: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 18

Resources

10/9/2011

Designing Quality Databases With Idef1X Information ModelsThomas A., M.D. Bruce$3.91 on Amazon!

The Data Model Resource Book, Vol. 1: A Library of Universal Data Models for All EnterprisesLen Silverston$45(also check out Vol. 2 and Vol. 3)

Image CreditsSlide 1: flickr/besser.jetztSlide 2: IBMSlide 3: flickr/Pete ReedSlide 4: flickr/Artful MagpieSlide 14: Amazon.comSlide 15: flickr/Jon AshcroftAll ER diagrams: Mark Abramson

SQL in a Nutshell: A Desktop Quick ReferenceKevin Kline, Brand Hunt, Daniel Kline$18 on Amazon

http://www.databaseanswers.org/data_modelsRepository of simple examples of db modelsFree!

http://publib.boulder.ibm.com/infocenter/wchelp/v5r6/index.jsp?topic=/com.ibm.commerce.data.doc/refs/rdmindex.htmIBM WebSphere data modelAlso search for ER Diagrams for other large systems to see how someone else addressed a set of entities and relationships (MS Dynamics, SAP, etc.)

www.StackOverflow.com

Page 19: Introduction to Database Design with Entity Relationship Diagrams

Introduction to Database Design / ER Diagrams

© 2011 Mark Abramson / #svcc 1910/9/2011

SV Code CampPeter Kellner

Attendees

Mom + Dad

Loving WifeThomas Bruce

Edgar Codd


Top Related