250 likes | 425 Views
Structured Design and Modeling. CS 123/CS 231. Design Models Revisited. UML: Modeling Language for OO Systems For the Procedural (Structured) Paradigm Data and processes are separately considered Data Model: Entity-Relationship Diagram Process Model: Data-Flow Diagram
E N D
Structured Designand Modeling CS 123/CS 231
Design Models Revisited • UML: Modeling Language for OO Systems • For the Procedural (Structured) Paradigm • Data and processes are separately considered • Data Model: Entity-Relationship Diagram • Process Model: Data-Flow Diagram • Some modeling techniques apply to both paradigms • e.g., use case diagram and state diagrams
ERDs • Entity-Relationship Diagrams • Used to produce a datamodel for an enterprise • Database Design
Entities and Attributes • Entity • thing, person, place • examples: Book, Sales Invoice, Student, Customer, Employee, Department, Airport • Attribute • feature of an entity • examples: Name, Address, Age, QCA, Title, Author, Amount, City
Relationships • Relationship • an association between (at least) two entities • examples: student borrows a book • Cardinality • One-to-one, one-to-many, many-to-many • Intersection Data • attribute resulting from relationship • example: date-borrowed
The Notation • Rectangles - Entities • Ellipses - Attributes • Diamonds - Relationships • Links • Labels
Example: The University Setting • Description • Students enroll in classes. Each class is a section of a particular course. • Entities • Student, Section, Course
address name year id number qca Student
room index sched M M Student enrolls Section M grade 1 Course has cat num desc title
Example 2: Library • Student borrows book • many to many relationship between students and books • see first diagram • Further analysis reveals there could be several copies of a book • student borrows copy, book has copy • see second diagram
M M Student borrows Book
M M Student borrows Copy M 1 Book has Exercise: Complete Diagram by filling in attributes
ERDs and the Software Life Cycle • Used at the design phase of the software life cycle for database systems, although it is often used as early as the analysis phase • In design, it precedes table definition
From ERD to Tables • Create a table for each entity • attributes associated to entity are columns of the table (a primary key should exist per table) • For 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 • For each 1:1 relationship • add primary key of one table plus intersection data to the other table • For each M:M relationship • create a new table • attributes are the primary keys of the participants plus intersection data
University Setting Example • Student • id number, name, address, year, qca • Section • index, room, sched, cat num • Course • cat num, title, desc • Enroll • id number, index, grade
DFDs • Data Flow Diagrams • Models Operations (Processes) • Also used in analysis and design
Processes • An operation or function in a system • example: Borrow Book • Involves • 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 • Circle (Bubble) - Process • Arrows - Data Flows • Rectangles - Sources and Sinks • Labels
1 Borrow Book id num, copy num borrow confirmation Student Borrow Copy
DFD Levels • A process may involve sub-processes • provides detail about the process • DFD levels emerge • Process hierarchy also depicted using a structure chart
1.1 Check Student Status id num borrower status Student 1.2 Check Book Copy Status copy num copy status Copy
borrower status, copy status 1.3 Record Borrow borrow confirmation id num, copy num Borrow Copy
About DFDs • Data flows should “balance” between levels • Number label format X.X.X provides level information • Context Diagram • Level 0 (or system-level) DFD • Notational Variations
Summary • Modeling techniques and notation • needed in analysis and design • models data and processes of a system • Other techniques and notation • state diagrams, structure charts, flowcharts, document flow diagrams, more... • Structured vs OO Paradigm • some techniques specific to the paradigm