Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10: Designing Databases Chapter 13 Systems Analysis and Design in a Changing World, 3 rd Edition.

Similar presentations


Presentation on theme: "Chapter 10: Designing Databases Chapter 13 Systems Analysis and Design in a Changing World, 3 rd Edition."— Presentation transcript:

1 Chapter 10: Designing Databases Chapter 13 Systems Analysis and Design in a Changing World, 3 rd Edition

2 Databases and Database Management Systems Databases (DB) – integrated collections of stored data that are centrally managed and controlled Database management system (DBMS) – system software that manages and controls access to database u Databases described by a schema: description of structure, content, and access controls

3 Components of a DB and DBMS

4 DBMS Important Capabilities u Simultaneous access by multiple users and applications u Access to data without application programs (via a query language) u Managing organizational data with uniform access and content controls

5 Database Models u Impacted by technology changes since 1960s u Model Types l Hierarchical l Network l Relational l Object-oriented u Most current systems use relational or object- oriented data models

6 Relational Databases u Relational database management system (RDBMS) organizes data into tables or relations u Tables are two dimensional data structures l Tuples: rows or records l Fields: columns or attributes u Tables have primary key field(s) which can be used to identify unique records u Keys relate tables to each other

7 Partial Display of Relational Database Table

8 Designing Relational Databases u Create table for each entity type u Choose or invent primary key for each table u Add foreign keys to represent one-to-many relationships u Create new tables to represent many-to-many relationships

9 Designing Relational Databases ( continued ) u Define referential integrity constraints u Evaluate schema quality and make necessary improvements u Choose appropriate data types and value restrictions (if necessary) for each field

10 Relationship Between Data in Two Tables

11 RMO Entity-Relationship Diagram

12 Representing Relationships u Relational databases use foreign keys to represent relationships u One-to-many relationship Add primary key field of one entity type as foreign key in table that represents many entity type u Many-to-many relationship l Use the primary key field(s) of both entity types l Use (or create) an associate entity table to represent relationship

13 Entity Tables with Primary Keys

14 Represent One-to-Many Relationships

15 Enforcing Referential Integrity u Consistent relational database state u Every foreign key also exists as a primary key value u DBMS enforces referential integrity automatically once schema designer identifies primary and foreign keys

16 DBMS Referential Integrity Enforcement u When rows containing foreign keys are created: l DBMS ensures that value also exists as a primary key in a related table u When row is deleted: l DBMS ensures no foreign key in related tables have same value as primary key of deleted row u When primary key value is changed: l DBMS ensures no foreign key values in related tables contain the same value

17 Evaluating Schema Quality u High quality data model has: l Uniqueness of table rows and primary keys l Ease of implementing future data model changes (flexibility and maintainability) l Lack of redundant data (database normalization) u Database design is not objective or quantitatively measured; it is experience and judgment based

18 Database Normalization u Normal forms minimize data redundancy First normal form (1NF) – no repeating fields or groups of fields Functional dependency – one-to-one relationship between the values of two fields 2NF – in 1NF and if each non-key element is functionally dependent on entire primary key 3NF – in 2NF and if no non-key element is functionally dependent on any other non-key element

19 Decomposition of 1NF Table into 2NF Tables

20 Conversion of 2NF Table into 3NF Tables

21 Object-Oriented Databases u Direct extension of OO design and programming paradigm u ODBMS stores data as objects or classes u Direct support for method storage, inheritance, nested objects, object linking, and programmer- defined data types u Object definition language (ODL) l Standard language for describing structure and content of an object database

22 Designing Object Databases u Determine which classes require persistent storage u Define persistent classes u Represent relationships among persistent classes u Choose appropriate data types and value restrictions (if necessary) for each field

23 Representing Classes u Transient object l Exist only during lifetime of program or process l Examples: view layer window, pop-up menu u Persistent object l Not destroyed when program or process ceases execution l Exist independently of program or process l Examples: customer information, employee information

24 Representing Relationships u Object identifiers l Used to identify objects uniquely l Physical storage address or reference l Relate objects of one class to another u ODBMS uses attributes containing object identifiers to find objects that are related to other objects u Keyword relationship can be used to declare relationships between classes

25 Representing Relationships ( continued ) u Advantages include: l ODBMS assumes responsibility for determining connection among objects l ODBMS assumes responsibility for maintaining referential integrity u Type of relationships l 1:1, 1:M, M:M l (one-to-one, one-to-many, many-to-many) l Association class used with M:M

26 RMO Class Diagram

27 1:1 Relationship Represented with Attributes Containing Object Identifiers

28 1:M Relationship Between Customer and Order Classes

29 1:M Represented with Attributes Containing Object Identifiers

30 M:M Relationship between Employee and Project Classes

31 M:M Relationship Represented with two 1:M Relationship

32 Generalization Hierarchy within the RMO Class Diagram

33 Hybrid Object-Relational Database Design u RDBMS (hybrid DBMS) used to store object attributes and relationships u Design complete relational schema and simultaneously design equivalent set of classes u Mismatches between relational data and OO l Class methods cannot be directly stored or automatically executed l Relationships are restricted compared to ODBMS l ODBMS can represent wider range of data types

34 Classes and Attributes u Designers store classes and object attributes in RDBMS by table definition u Relational schema can be designed based on class diagram u Table is created for each class u Fields of each table same as attributes of class u Row holds attribute values of single object u Key field is chosen for each table

35 Views of Stored Data

36 Relationships u Relationships are represented with foreign keys u Foreign key values serve same purpose as object identifiers in ODBMS 1:M relationship: add primary key field of class on one side of the relationship to table representing class on many side u M:M relationship: create new table that contains primary key fields of related class tables and attributes of the relationship itself

37 Data Access Classes u OO design based on a three-layer architecture u Data access classes are implementation bridge between data stored in program objects and data in relational database u Methods add, update, find, and delete fields and rows in table or tables that represent the class u Methods encapsulate logic needed to copy data values from problem domain class to database and vice versa

38 Interaction Between Classes

39 Data Types u Storage format and allowable content of program variable, object state variable, or database field or attribute u Primitive data types: directly implemented l Memory address (pointer), Boolean, integer, etc. u Complex data types: user-defined l Dates, times, audio streams, video images, URLs

40 Relational DBMS Data Types u Designer must choose appropriate data type for each field in relational database schema u Choice for many fields is straightforward l Names and addresses use a set of fixed- or variable-length character arrays l Inventory quantities can use integers l Item prices can use real numbers u Complex data types (DATE, LONG, LONGRAW)

41 Subset of Oracle RDBMS Data Types

42 Object DBMS Data Types u Uses set of primitive and complex data types comparable to RDBMS data types u Schema designer can create new data types and associated constraints u Classes are complex user-defined data types that combines traditional concept of data with processes (methods) to manipulate data u Flexibility to define new data types is one reason that OO tools are widely used

43 Distributed Databases u Rare for all organizational data to be stored in one location in a single database u Different information systems in an organization are developed at different times Parts of an organization s data may be owned and managed by different units u System performance is improved when data is near primary applications

44 Single Database Server Architecture

45 Replicated Database Server Architecture

46 Partitioning Database Schema into Client Access Subsets

47 Partitioned Database Server Architecture

48 Federated Database Server Architecture

49 RMO Distributed Database Architecture u Starting point for design is information about data needs of geographically dispersed users u RMO gathered information during analysis phase u RMO decided to manage database using Park City data center mainframe u RMO is evaluating single-server vs. replicated and partitioned database server architectures u Information on network traffic and costs needed

50 Single-Server Database Server Architecture for RMO

51 Replicated and Partitioned Database Server Architecture for RMO

52 Summary u Modern information systems store data in database, access and manage data using DBMS u Relational DBMS is commonly used u Object DBMS is increasing in popularity u Key activity of systems design is developing relational or object database schema u Relational database is collection of data stored in tables and is developed from entity-relationship diagram

53 Summary ( continued ) u Object database stores data as collection of related objects and is developed from class diagram u Objects can also be stored within RDBMS l RDBMS cannot store methods l RDBMS cannot directly represent inheritance u Medium and larger information systems typically use multiple databases or database servers in various geographic locations


Download ppt "Chapter 10: Designing Databases Chapter 13 Systems Analysis and Design in a Changing World, 3 rd Edition."

Similar presentations


Ads by Google