Structured Design and Modeling CS 123/CS 231
Design Models Revisited zUML: Modeling Language for OO Systems zFor the Procedural (Structured) Paradigm ÕData and processes are separately considered ÕData Model: Entity-Relationship Diagram ÕProcess Model: Data-Flow Diagram zSome modeling techniques apply to both paradigms Õe.g., use case diagram and state diagrams
ERDs zEntity-Relationship Diagrams zUsed to produce a data model for an enterprise zDatabase Design
Entities and Attributes zEntity Õthing, person, place Õexamples: Book, Sales Invoice, Student, Customer, Employee, Department, Airport zAttribute Õfeature of an entity Õexamples: Name, Address, Age, QCA, Title, Author, Amount, City
Relationships zRelationship Õan association between (at least) two entities Õexamples: student borrows a book zCardinality ÕOne-to-one, one-to-many, many-to-many zIntersection Data Õattribute resulting from relationship Õexample: date-borrowed
The Notation zRectangles - Entities zEllipses - Attributes zDiamonds - Relationships zLinks zLabels
Example: The University Setting zDescription ÕStudents enroll in classes. Each class is a section of a particular course. zEntities ÕStudent, Section, Course
Student id number name address year qca
StudentenrollsSection Coursehas MM M 1 grade index room sched cat num title desc
Example 2: Library zStudent borrows book Õmany to many relationship between students and books Õsee first diagram zFurther analysis reveals there could be several copies of a book Õstudent borrows copy, book has copy Õsee second diagram
StudentborrowsBook MM
StudentborrowsCopy Bookhas MM M 1 Exercise: Complete Diagram by filling in attributes
ERDs and the Software Life Cycle zUsed at the design phase of the software life cycle for database systems, although it is often used as early as the analysis phase zIn design, it precedes table definition
From ERD to Tables zCreate a table for each entity Õattributes associated to entity are columns of the table (a primary key should exist per table) zFor each 1:M relationship Õadd the primary key of the “1” participant as an attribute of the “M” participant (foreign key); intersection data is also added to the “M” participant
ERD to Tables, continued zFor each 1:1 relationship Õadd primary key of one table plus intersection data to the other table zFor each M:M relationship Õcreate a new table Õattributes are the primary keys of the participants plus intersection data
University Setting Example zStudent Õid number, name, address, year, qca zSection Õindex, room, sched, cat num zCourse Õcat num, title, desc zEnroll Õid number, index, grade
DFDs zData Flow Diagrams zModels Operations (Processes) zAlso used in analysis and design
Processes zAn operation or function in a system Õexample: Borrow Book zInvolves Õdata flow (input and results) Õdata sources and sinks Example: student and book-copy info are data that flow into the process; results stored in borrow table
Notation zCircle (Bubble) - Process zArrows - Data Flows zRectangles - Sources and Sinks zLabels
1 Borrow Book Student Copy Borrow id num, copy numborrow confirmation
DFD Levels zA process may involve sub-processes Õprovides detail about the process zDFD levels emerge zProcess hierarchy also depicted using a structure chart
1.1 Check Student Status id numborrower status copy numcopy status 1.2 Check Book Copy Status Student Copy
1.3 Record Borrow id num, copy num Borrow borrower status, copy status borrow confirmation Copy
About DFDs zData flows should “balance” between levels zNumber label format X.X.X provides level information zContext Diagram ÕLevel 0 (or system-level) DFD zNotational Variations
Summary zModeling techniques and notation Õneeded in analysis and design Õmodels data and processes of a system zOther techniques and notation Õstate diagrams, structure charts, flowcharts, document flow diagrams, more... zStructured vs OO Paradigm Õsome techniques specific to the paradigm