1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen 2002-2008 Conditions & Roles These slides are licensed.

Slides:



Advertisements
Similar presentations
CMSC 414 Computer (and Network) Security Lecture 13 Jonathan Katz.
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5 More SQL: Complex Queries, Triggers, Views, and Schema Modification.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Design Principles: Faithfulness
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
Copyright W. Howden1 Lecture 13: Programming by Contract.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
9 1 Chapter 9 Database Design Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
Systems Analysis I Data Flow Diagrams
Database Auditing Models Dr. Gabriel. 2 Auditing Overview Audit examines: documentation that reflects (from business or individuals); actions, practices,
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
DB Audit Expert v1.1 for Oracle Copyright © SoftTree Technologies, Inc. This presentation is for DB Audit Expert for Oracle version 1.1 which.
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
1 Some Patterns of Novice Programs Author : Eugene Wallingford ; Dan Steinberg ; Robert Duvall ; Ralph Johnson Source : PLoP 2004 Advisor : Ku-Yaw Chang.
CSC271 Database Systems Lecture # 6. Summary: Previous Lecture  Relational model terminology  Mathematical relations  Database relations  Properties.
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Relational Database Concepts. Let’s start with a simple example of a database application Assume that you want to keep track of your clients’ names, addresses,
Copyright © Ellis Cohen
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen M:N Relationships & Bridge Classes These.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Relationship Classes & N-ary Relationships.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
2/6/01D-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Using PARTS to Illustrate Requirements Concepts.
TxEIS Security A role-based solution October 2010.
IS 221: DATABASE ADMINISTRATION Lecture 6:Create Users & Manage Users. Information Systems Department 1.
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
Moodle (Course Management Systems). Managing Your class In this Lecture, we’ll cover course management, including understanding and using roles, arranging.
…using Git/Tortoise Git
Ad Hoc Constraints Objectives of the Lecture : To consider Ad Hoc Constraints in principle; To consider Ad Hoc Constraints in SQL; To consider other aspects.
Lecture 8 – Cookies & Sessions SFDV3011 – Advanced Web Development 1.
Requirements Documentation CSCI 5801: Software Engineering.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen :1 Relationships These slides are licensed.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
1 A Guide to MySQL 2 Database Design Fundamentals.
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Union Subclasses & Disjoint 1:M Relationships.
Database Beginnings. Scenario so far In our scenario we have people registering for training sessions. –The data about the training sessions was placed.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Maintaining Session State in the Data.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
M1G Introduction to Database Development 4. Improving the database design.
Today’s Agenda  Reminder: HW #1 Due next class  Quick Review  Input Space Partitioning Software Testing and Maintenance 1.
Use Cases Use Cases are employed to describe the functionality or behavior of a system. Each use case describes a different capability that the system.
1 Kyung Hee University Statecharts Spring Kyung Hee University Specifying Objects’ Behaviour  Interaction diagrams show message-passing behaviour.
DBT544. DB2/400 Advanced Features Level Check Considerations Database Constraints File Overrides Object and Record Locks Trigger Programs.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Maintaining Session State in the Data.
Object-Oriented Analysis and Design CHAPTERS 9, 31: DOMAIN MODELS 1.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
CS212: Object Oriented Analysis and Design Lecture 32: Use case and Class diagrams.
Systems Analysis and Design in a Changing World, Fourth Edition
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Mastering the AS/400, Third Edition, author Jerry Fottral 1 Week 12 Lesson Overview Introduce the idea of object authorization and see how library and.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Relational State Assertions These slides.
Use Case Diagram Lecture # 1. Use Case Diagram Use-cases are descriptions of the functionality of a system from a user perspective.  Depict the behaviour.
ITM © Port,Kazman 1 ITM 352 Cookies. ITM © Port,Kazman 2 Problem… r How do you identify a particular user when they visit your site (or any.
1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Roles & Constraints These slides are licensed.
1 Kyung Hee University Interaction Diagrams Spring 2001.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
SQL Triggers, Functions & Stored Procedures Programming Operations.
Database Planning Database Design Normalization.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Use Case Diagrams A Detailed Description. Use Case Diagrams Use case diagrams describe relationships between users and use cases A use case is a (usually.
Copyright © Ellis Cohen Consistency & Initialization
Lecture 8 Object Concepts
Presentation transcript:

1 Theory, Practice & Methodology of Relational Database Design and Programming Copyright © Ellis Cohen Conditions & Roles These slides are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. For more information on how you may use them, please see

2© Ellis Cohen Overview of Lecture Pre-Conditions Post-Conditions Using Operation Conditions User Roles Roles & Entity Classes

3© Ellis Cohen Pre-Conditions

4© Ellis Cohen Pre-Conditions A Pre-Condition is a condition that should be checked immediately BEFORE a specific operation is permitted to execute. Pre-conditions are used to determine whether an operation should be permitted to execute

5© Ellis Cohen Pre-conditions for Update Job Entry UpdateJobEntry( :jobno, :compid, :loc, :startdate, :enddate, :descr ) –Updates the current user's :jobno'th job entry Pre-Conditions: Current user must be a job candidate with an existing job entry numbered by :jobno :compid must be the id of a company in the database :enddate must be after :startdate

6© Ellis Cohen Enforcing Pre-Conditions Pre-conditions are typically enforced by Adding code at beginning of an operation which checks whether the condition is satisfied (often involving a database query) If an error would be raised (e.g. by the database) if the operation would allowed to proceed, let it, and handle the error appropriately.

7© Ellis Cohen Types of Pre-Conditions Pre-conditions are (in order of weakest to strongest) Soundness Pre-Conditions –determine whether the operation makes sense, strictly based on the parameters to the operation Status Pre-Conditions –determine whether the operation can take place based on the current status of the database or the environment, but not based on the user (or client) User Pre-Conditions –determine whether the current user (or client) is allowed to perform the operation

8© Ellis Cohen Soundness & Status Examples Soundness-Based example –AddJobEntry( :compid, :title, :location, :startDate, :endDate, :details ) :enddate must be after :startdate Status-Based example –AddJobEntry( :compid, :title, :location, :startDate, :endDate, :details ) :compid must be the id of a company in the database

9© Ellis Cohen User Pre-Conditions Determines whether the current user (or client) is authorized to perform the operation, or whether the parameters are appropriate for that user –Always refers to the role or (some DB information tied to the) identity of the current user/client Role-Based User Pre-Conditions –Only requires checking the role of the current user Identity-Based User Pre-Conditions –Requires checking (some DB information tied to the) identity of the current user

10© Ellis Cohen User Pre-Condition Examples Role-Based example –AddJobEntry( :compid, :title, :location, :startDate, :endDate, :details) The current user's role must be a JobCandidate Identity-Based example –UpdateJobEntry( :jobno, :compid, :title, :location, :startDate, :endDate, :details ) The current user must have a jobno'th job entry

11© Ellis Cohen Post-Conditions

12© Ellis Cohen Post-Conditions A Post-Condition is a condition that you expect to be true immediately AFTER a specific operation executes Post-conditions are used to ensure that an operation executed correctly, and to characterize everything that it needs to do

13© Ellis Cohen Post-Conditions for RemoveCandidate RemoveCandidate –Removes the current user as a candidate Post-Conditions: The current user is no longer a candidate There are no remaining job entries for the current user Boring Interesting What makes a post-condition interesting?

14© Ellis Cohen Interesting Post-Conditions Interesting Post-Conditions have one or more of the following characteristics Don't obviously or immediately follow from a simple description of the operation Not a condition that is invariant (i.e. always true); the operation made it true Involve changes to entity classes or relationships other than the one that the operation obviously needs to affect Ensure that redundant data is kept consistent

15© Ellis Cohen Types of Post-Conditions State-Related Post-Conditions –characterizes resulting changes to the database state -- e.g. the candidate's job entries must have all been deleted Output-Related Post-Conditions –characterizes resulting properties of the operation output -- usually situations under which less information than expected was displayed External Post-Conditions –characterizes resulting changes to the external environment -- e.g. a message was sent, etc. Main Focus

16© Ellis Cohen Output-Related Post-Condition for ShowCompaniesWithPostings ShowCompaniesWithPostings –Shows companies which have job postings Output-Related Post-Condition: if current user is not a premium member, only shows companies with postings more than 5 days old

17© Ellis Cohen Using Operation Conditions

18© Ellis Cohen Operation Conditions Pre-Condition: Condition that should be checked before an operation is executed Used to determine if an operation should be allowed to execute Post-Condition: Condition that can be checked after an operation is executed Used to ensure that an operation executed correctly characterize everything it needed to do

19© Ellis Cohen Enforcing Operation Conditions There are two places to enforce operation conditions Application Enforcement: –Enforce constraints through code executed by an operation Database Enforcement: –Use built-in database features to automatically enforce constraints in the data-tier column constraints, table constraints, assertions, views, triggers & access control

20© Ellis Cohen Value of Operation Conditions Why is it important to specify operation conditions? –They often correspond to business rules (in the requirements), perhaps added in a later revision –Clarifies intent and semantics of user operations –Helps discover deficiencies in the conceptual ER model –Enforcing conditions helps ensure that database applications work correctly!

21© Ellis Cohen Operation Conditions & Business Rules Business Rules specify/ determine 1.Conceptual Model 2.User Operation Functionality 3.Behavior Constraints & Operation Conditions constraints and conditions on the behavior of user and database operations 4.State Constraints constraints on the state of the data that's allowed to be stored in the database 5.Performance Requirements Operation Conditions are just part of the business rules of a database application

22© Ellis Cohen User Roles

23© Ellis Cohen User Roles A user role characterizes a kind of user who uses a particular database application Users who take on different roles (are allowed to) use different sets of operations What are the roles (i.e. names for different groups of users) for the Job Board application?

24© Ellis Cohen Job Board User Roles Different users of the system play different roles. The two roles we've discussed are –Job Candidate –Company Representative There are other roles as well (which we won't discuss now) –Administrator (too complicated) –UnknownUser (someone who is not logged in, but perhaps can still get some job board information)

25© Ellis Cohen Organizing User Operations Why use roles?  Organizing operations by role & by operation type helps ensure that the list of operations is complete, and that we really understand what we expect the application to be able to support Roles QueriesActions Job Candidate Show Company Postings Show Company Info … Add Job Entry … Company Representative Show Company Postings Show Company Info … Add Job Posting …

26© Ellis Cohen Common Operations Are there any operations that are common to both roles (i.e. to both groups of users)? YES  Use super-roles so that an operation can be associated with just a single role!

27© Ellis Cohen Super-Roles and Sub-Roles Job Candidate User Means two things (BOTH are important!) A Job Candidate is a kind of User (but not every User is a Job Candidate) Every operation that a User is allowed to perform can also be performed by a Job Candidate User Role Diagram User is a super-role of Job Candidate Job Candidate is a sub-role of User

28© Ellis Cohen Multiple Subroles User Job Candidate Company Representative User is a super-role of Company Representative and Job Candidate User Role Diagrams show the roles used in an application and the relationships among them. They are a simplification of UML Use Case Diagrams in which just the actors are shown User Role Diagram

29© Ellis Cohen Reorganizing User Operations Roles QueriesActions User Show Company Postings Show Company Info … … Job Candidate …Add Job Entry … Company Representative …Add Job Posting … Allows common operations to be associated with the common super-role

30© Ellis Cohen Designing with Role Hierarchies Role hierarchies simplify design. They allow an operation to be associated with just a single role. Suppose an operation can be performed by (1) a Company Representative, (2) a Job Candidate and (3) potentially any other kind of User Instead of having to associate the operation with all 3 roles, we simply note that Job Candidate and Company Representatives are subroles of User, and just associate the operation with the User role. Why use role hierarchies?

31© Ellis Cohen Disjoint Subroles Job Candidate Company Representative User Means that the same user can't play the roles of Job Candidate and Company Representative simultaneously. User is a super-role of Company Representative and Job Candidate User Role Diagram

32© Ellis Cohen Overlapping Subroles User Job Candidate Company Representative User is a super-role of Company Representative and Job Candidate Because Company Representative and Job Candidate are not disjoint, a user can perform operations associated with either role at the same time, without having to explicitly change roles, or log out and log back in. User Role Diagram

33© Ellis Cohen Role Reorganization Problem Suppose there were three groups of users: Job Candidates, Company Representatives & Administrators. Suppose there was a new operation added that Company Representatives & Administrators could do, but not Job Candidates. If so, how would we reorganize this diagram so that an operation is still only assigned to a single role? Job Candidate Company Representative User Administrator User Role Diagram

34© Ellis Cohen Role Reorganization Solution Job Candidate Company Representative User Administrator Privileged User Define new common role & assign operation to this role User Role Diagram Does this meet the "kind-of" requirement?

35© Ellis Cohen Known & Unknown Users Job Candidate Company Representative Known User User Role Diagram User Anyone with access to the system A logged-in user Unknown User A user who is not logged-in

36© Ellis Cohen Logout and Login Why is it important to distinguish –a KnownUser (who is logged in) from –an UnknownUser (who isn't)? We do not know who a user is before she logs in, or after she logs out –The Login operation changes the current user's role from UnknownUser to KnownUser (or a subrole of it) –The Logout operation changes the current user's role back to UnknownUser A user who is already logged in should not be able to log in again –This is enforced automatically if we only allow Login to be performed by a user whose role is UnknownUser A user should not be able to logout if they are already logged out –This is enforced automatically if we only allow Logout to be performed by a user whose role is KnownUser (or a subrole of it) Note: More generally, a result of an action can be a change to the user's role

37© Ellis Cohen Known vs Unknown User Operations Roles QueriesActions Unknown User Login Register Candidate Register Company Known User Show Company Postings Show Company Info … Logout … Job Candidate …Add Job Entry … Company Representative …Add Job Posting …

38© Ellis Cohen Role-Based User Pre-Conditions Assigning an Operation to a Role implicitly defines a role-based user pre-condition –Assigning ShowMatchingCompanies to the JobCandidate role is equivalent to –ShowMatchingCompanies Pre-Condition: The user must be a job candidate

39© Ellis Cohen Roles & Entity Classes

40© Ellis Cohen Entity-Relationship Diagrams Entity-Relationship diagrams –Reflect the static relationships between data persistently stored in the database They do NOT need to reflect –Temporary data structures –Users or roles (unless information is retained about them beyond what is needed for authentication, or if authentication info is stored in the DB) –Operations users might be able to do or have done, unless needed for auditing purposes –Flow of information among tables or between tables and users (i.e. they are not process modeling diagrams)

41© Ellis Cohen Job Board Application: Easy Crow Magnum Diagram Candidate JobPosting job history includes open at postid candid JobEntry Company occurred at compid entryid

42© Ellis Cohen Possibly Expanded ER Diagram Candidate JobPosting job history includes open at postid candid JobEntry Company occurred at compid entryid Company Rep repid has views Is this a better ER model?

43© Ellis Cohen Questionable ER Diagram Expansion Candidate JobPosting job history includes open at postid candid JobEntry Company occurred at compid entryid Company Rep repid has views 1)Adding CompanyRep might make sense, but only so that when a CompanyRep logs in, we can find out their associated company. That's not even necessary if all company reps can login with the same company id, or if authentication & basic user info is managed outside the database (e.g. LDAP, Active Directory, etc.) 2)While company representatives certainly view candidate job entries, nothing suggests that we need to persistently keep track of that information.

44© Ellis Cohen Relationships & Persistence A relationship represents information which needs to be persistently stored in a database! If the information doesn't need to be stored and queried, don't represent it as a relationship Don't include relationships which simply show what a user can do or keep track of what a user has done, unless it is clear that information will be needed later! *