Download presentation
Presentation is loading. Please wait.
Published byBlaise Sutton Modified over 8 years ago
1
12
2
Chapter 12: Designing Databases Systems Analysis and Design in a Changing World, Fourth Edition 12
3
Systems Analysis and Design in a Changing World, 4th Edition 3 Learning Objectives u Describe the differences and similarities between relational and object-oriented database management systems u Design a relational database schema based on an entity-relationship diagram u Design an object database schema based on a class diagram
4
12 Systems Analysis and Design in a Changing World, 4th Edition 4 Learning Objectives ( continued ) u Design a relational schema to implement a hybrid object-relational database u Describe the different architectural models for distributed databases
5
12 Systems Analysis and Design in a Changing World, 4th Edition 5 Overview u This chapter describes design of relational and OO data models u Developers transform conceptual data models into detailed database models l Entity-relationship diagrams (ERDs) for traditional analysis l Class diagrams for object-oriented (OO) analysis u Detailed database models are implemented with database management system (DBMS)
6
12 Systems Analysis and Design in a Changing World, 4th Edition 6 Databases and Database Management Systems u Databases (DB) – integrated collections of stored data that are centrally managed and controlled o Entity or class attribute( eg. names, prices ). o Relationships among the entities or classes ( eg. which orders belong to which customers). o Stores descriptive information about data, such as field names, restrictions on allowed data and access control to sensitive information.
7
12 Databases and Database Management Systems (Cont.) u The database (DB) consists of two related information store: o The physical data store: used by DBMS to store the raw bits and bytes of a database. o The schema: description of structure, content, and access controls of a physical data store or DB. u Database management system (DBMS) – system software that manages and controls access to database (eg. Microsoft access, Oracle, DM2) Systems Analysis and Design in a Changing World, 4th Edition 7
8
12 Systems Analysis and Design in a Changing World, 4th Edition 8 Components of a DB and DBMS
9
12 Systems Analysis and Design in a Changing World, 4th Edition 9 Important DBMS Capabilities u Simultaneous access by multiple users and applications. u Access to data without writing application programs (via a query language). u Organizational data management with uniform access and content controls
10
12 Systems Analysis and Design in a Changing World, 4th Edition 10 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
11
12 Systems Analysis and Design in a Changing World, 4th Edition 11 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) that can be used to identify unique row of relational database table. u Keys: A field that contains a value that is unique within each row of a RDBMS.
12
12 Systems Analysis and Design in a Changing World, 4th Edition 12 Partial Display of Relational Database Table (Figure 12-2)
13
12 Systems Analysis and Design in a Changing World, 4th Edition 13 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
14
12 Systems Analysis and Design in a Changing World, 4th Edition 14 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
15
12 Systems Analysis and Design in a Changing World, 4th Edition 15 RMO Entity-Relationship Diagram (Figure 12-5)
16
12 Systems Analysis and Design in a Changing World, 4th Edition 16 Entity Tables with Primary Keys (Figure 12-7)
17
12 Systems Analysis and Design in a Changing World, 4th Edition 17 Represent One-to-Many Relationships by Adding Foreign Keys (in italics) (Figure 12-8)
18
12 Systems Analysis and Design in a Changing World, 4th Edition 18 Representing Relationships u Relational databases use foreign keys to represent relationships u One-to-many relationship l 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 associative entity table to represent relationship (Figure 12-9 in text book)
19
12 Systems Analysis and Design in a Changing World, 4th Edition 19 Relationship Between Data in Two Tables
20
12 20 Enforcing Referential Integrity u Referential Integrity: describes a consistent state among foreign key and primary key( eg. An order must be from a customer). u Every foreign key value also exists as a primary key value u DBMS enforces referential integrity automatically after schema designer identifies primary and foreign keys
21
12 Systems Analysis and Design in a Changing World, 4th Edition 21 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 keys 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
22
12 Systems Analysis and Design in a Changing World, 4th Edition 22 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
23
12 23 Database Normalization u Normalization: Ensures relational database schema quality by minimizing data redundancy. u Normal forms minimize data redundancy l First normal form (1NF) – no repeating fields or groups of fields. l Functional dependency – one-to-one relationship between the values of two fields. l The relationship is formally stated as follows: Field A is functionally depend on field B if for each value of B there is only one corresponding value of A
24
12 Database Normalization (Cont.) l 2NF – in 1NF and if each non-key element is functionally dependent on entire primary key l 3NF – in 2NF and if no non-key element is functionally dependent on any other non-key element Systems Analysis and Design in a Changing World, 4th Edition 24
25
12 Systems Analysis and Design in a Changing World, 4th Edition 25 Decomposition of 1NF Table into 2NF Tables IssueDate is determined by CatalogID alone, not by both CatalogID and ProductID
26
12 Systems Analysis and Design in a Changing World, 4th Edition 26 Conversion of 2NF Table into 3NF Tables ZipCode determines the value for State, and ZipCode is not the key to the table
27
12 27 Object-Oriented Databases u Direct extension of OO design and programming paradigm u ODBMS stores data as objects or class instances and to interface with OO programming languages u Direct support for method storage, inheritance, nested objects, object linking, and programmer- defined data types u Object Definition Language (ODL) l Standard object database description language for describing structure and content of an object database
28
12 Systems Analysis and Design in a Changing World, 4th Edition 28 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
29
12 29 Representing Classes u There are two types of classes for purpose of DM u Transient classes l Objects exist only during lifetime of program or process l Examples: view layer window, pop-up menu u Persistent classes l Objects not destroyed when program or process ceases execution. State must be remembered. l Exist independently of program or process l Examples: problem domain( customer information, employee information).
30
12 Systems Analysis and Design in a Changing World, 4th Edition 30 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
31
12 Systems Analysis and Design in a Changing World, 4th Edition 31 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 (one-to-one, one-to-many, many-to- many) l Association class used with M:M
32
12 Systems Analysis and Design in a Changing World, 4th Edition 32 RMO Domain Model Class Diagram (Figure 12-15)
33
12 Systems Analysis and Design in a Changing World, 4th Edition 33 One-to-One Relationship Represented with Attributes Containing Object Identifiers
34
12 Types of relationships Systems Analysis and Design in a Changing World, 4th Edition 34
35
12 Systems Analysis and Design in a Changing World, 4th Edition 35 One-to-Many Relationship Between Customer and Order Classes
36
12 Systems Analysis and Design in a Changing World, 4th Edition 36 One-to-Many Relationship Represented with Attributes Containing Object Identifiers
37
12 Systems Analysis and Design in a Changing World, 4th Edition 37 Many-to-Many Relationship between Employee and Project Classes (Figure 12-19)
38
12 Systems Analysis and Design in a Changing World, 4th Edition 38 Generalization Hierarchy within the RMO Class Diagram (Figure 12-21)
39
12 Systems Analysis and Design in a Changing World, 4th Edition 39 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
40
12 Systems Analysis and Design in a Changing World, 4th Edition 40 Classes and Attributes u Designers store classes and object attributes in RDBMS by table definition u For new system :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
41
12 Systems Analysis and Design in a Changing World, 4th Edition 41 Views of Stored Data
42
12 Systems Analysis and Design in a Changing World, 4th Edition 42 Relationships u Relationships are represented with foreign keys u Primary key values serve same purpose as object identifiers in ODBMS u 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
43
12 Systems Analysis and Design in a Changing World, 4th Edition 43 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
44
12 Systems Analysis and Design in a Changing World, 4th Edition 44 Interaction Among a Domain Class, a Data Access Class, and the DBMS (Figure 12-25)
45
12 Systems Analysis and Design in a Changing World, 4th Edition 45 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, and so on u Complex data types – user-defined l Dates, times, audio streams, video images, URLs
46
12 Systems Analysis and Design in a Changing World, 4th Edition 46 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)
47
12 Systems Analysis and Design in a Changing World, 4th Edition 47 Subset of Oracle RDBMS Data Types
48
12 Systems Analysis and Design in a Changing World, 4th Edition 48 Object DBMS Data Types u Use 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 combine 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
49
12 Systems Analysis and Design in a Changing World, 4th Edition 49 Distributed Databases u Rare for all organizational data to be stored in a single database in one location u Different information systems in an organization are developed at different times u 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
50
12 Systems Analysis and Design in a Changing World, 4th Edition 50 Single Database Server Architecture (Figure 12-27)
51
12 Single Database Server Architecture (Cont.) u Primary Advantages: Simplicity, because there are only one server to manage. u Primary Disadvantages: o Server failure o Possible load of the server o No back up capabilities in the event of server failure. u Poorly suited to applications that must be available on 24/7 Systems Analysis and Design in a Changing World, 4th Edition 51
52
12 Systems Analysis and Design in a Changing World, 4th Edition 52 Replicated Database Server Architecture (Figure 12-28)
53
12 Replicated Database Server Architecture u Designers can eliminate delay in accessing distance database server. u More fault tolerance. u Load balancing. u Primary Disadvantage: o Data inconsistency u Database Synchronization: The process of ensuring consistency among two or more database copies. Systems Analysis and Design in a Changing World, 4th Edition 53
54
12 Systems Analysis and Design in a Changing World, 4th Edition 54 Partitioning Database Schema into Client Access Subsets
55
12 Systems Analysis and Design in a Changing World, 4th Edition 55 Partitioned Database Server Architecture
56
12 Systems Analysis and Design in a Changing World, 4th Edition 56 Federated Database Server Architecture
57
12 Systems Analysis and Design in a Changing World, 4th Edition 57 RMO Distributed Database Architecture u Starting point for design was 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
58
12 Systems Analysis and Design in a Changing World, 4th Edition 58 Single-Server Database Server Architecture for RMO
59
12 Systems Analysis and Design in a Changing World, 4th Edition 59 Replicated and Partitioned Database Server Architecture for RMO
60
12 Systems Analysis and Design in a Changing World, 4th Edition 60 Summary u Modern information systems store data in database and 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
61
12 Systems Analysis and Design in a Changing World, 4th Edition 61 Summary ( continued ) u Object database stores data as collection of related objects and is developed from class diagram u Objects can also be stored in 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.