1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.

Slides:



Advertisements
Similar presentations
Chapter 3 Data Modeling Copyright © 2014 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent.
Advertisements

Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Accounting System Design
Systems Development Life Cycle
Data Modeling is an Analysis Activity
PowerPoint Presentation by Charlie Cook Copyright © 2004 South-Western. All rights reserved. Chapter 3 Database Management Systems Database Management.
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
Modeling the Data: Conceptual and Logical Data Modeling
Database Design & Mapping
System Analysis - Data Modeling
Chapter 3: Modeling Data in the Organization
Entity-Relationship Model and Diagrams (continued)
Chapter 4 ENTITY-RELATIONSHIP MODELLING.
Chapter 3: Modeling Data in the Organization
CHAPTER 2: MODELING DATA IN THE ORGANIZATION © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey.
Implementing an REA Model in a Relational Database
Chapter 4 Entity-Relationship modeling Transparencies © Pearson Education Limited 1995, 2005.
Chapter 3 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Importance of data modeling Importance of data modeling Write good.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Entity Relationship Diagrams (ERDs)
1 © Prentice Hall, 2002 CMIS564: E/R Modeling Dr. Bordoloi Based on Chapter 3; Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
ระบบฐานข้อมูลขั้นสูง (Advanced Database Systems) Lecturer AJ. Suwan Janin Phone:
Chapter 3: Modeling Data in the Organization
Chapter 4 The Relational Model.
Web-Enabled Decision Support Systems
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Introduction to Accounting Information Systems
Chapter 5 Entity–Relationship Modeling
The REA Model. The REA model provides structure for developing an accounting database It helps to identify It helps to The REA Model.
DATABASEMODELSDATABASEMODELS  A database model ◦ defines the logical design of data. ◦ Describes the relationships between different parts of data.
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
© 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 2: Modeling Data in the Organization.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Entity-Relationship Modeling Based on Chapter 12.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Carnegie Mellon University © Robert T. Monroe Management Information Systems Data Modeling Management Information Systems Robert.
Databases Illuminated Chapter 3 The Entity Relationship Model.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 2: MODELING DATA.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
IS 4420 Database Fundamentals Chapter 3: Modeling Data in the Organization Leon Chen.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Lecture 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Data Modeling Using the Entity- Relationship (ER) Model
COP Introduction to Database Structures
Logical Database Design and the Rational Model
Chapter 4: Logical Database Design and the Relational Model
Chapter 4: Part B Logical Database Design and the Relational Model
Database Design Using the REA Data Model
Entity-Relationship Model and Diagrams (continued)
Accounting System Design
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Design Chapters 17 and 18.
Accounting System Design
Entity-Relationship Diagram (ERD)
Presentation transcript:

1 Relational Databases and SQL

Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams that model effective accounting database structures using the REA approach Recognize the components of relational tables and the keys to effective relational database design Understand use of SQL commands to create relational tables during implementation or the model Be able to manipulate relational tables to extract the necessary data during decision making Relational Databases and SQL

3 Relational Databases Relational databases form the center of the AIS wheel and the center of the many accounting applications In this chapter we describe the REA (Resources, Events, Agents) approach for developing models of accounting databases and using those models to build relational databases. We also describe SQL, a database query language used to construct and manipulate relational databases. At the conclusion of your study of this chapter you should understand how enterprise databases, including database controls, are constructed and used in modern organizations.

4 The REA Model William McCarthy – 1979, 1982 Based on E-R Modeling Reaction to older AIS design –Models things that accountants did REA design –Models Business Events

5 REA Modeling - Entities REA helps database designers define a complete set of entities and attributes Entity: anything in which we are interested that exists independently. –Resources - Inventory, equipment, cash –Events - Orders, sales, purchases –Agents - Customers, employees, vendors –Location – Where resources, events or agents reside An instance of an entity is one specific thing of the type defined by the entity.

6 REA Modeling – Attributes Attribute - item of data that characterizes and entity or relationship –To fully describe a CLIENT we need to record several attributes such as: –Name, Address, Contact_Person, and Phone_Number. –Sometimes, attributes are a combination of parts that have unique meanings of their own. –Attributes that consist of multiple subattributes are referred to as composite attributes.

7 Attribute Hierarchy for Entity Client: Figure 6.1 Attributes describe an entity – a client has a name, address, contact_person and phone-number.

8 Key Attributes A unique attribute/value is needed to locate the desired record in the database –An attribute with a unique value is known as a key attribute –In implementing the database, the key attribute becomes the primary key

9 Symbols used in E-R and REA Diagrams

10 Relationships Relationships are associations between entities. Entities must be logically linked to show the relationships between them These relationships map and define how data can be extracted from the database This mapping is the development of the E-R diagram A three-step strategy is generally most effective in identifying all the relationships that should be included in a model. 1.Identify users’ existing and desired information requirements to determine whether relationships in the data model can fulfill those requirements. 2.Evaluate each of the entities in pairs to determine whether one entity in the pair provides a better description of an attribute contained in the other entity in the pair. 3.Evaluate each entity to determine if there would be any need for two occurrences of the same entity type to be linked.

11 Types of Relationships Unary –Relationship between instances of one Entity Binary –Relationship between instances of two Entities Tertiary –Relationship between instances of three Entities

12 Unary Relationship PERSON COURSE EMPLOYEE married to is a prerequisite for has as a prerequisite managed by manage Each PERSON may be married to one and only one PERSON. Each COURSE may have zero, one, or many prerequisite COURSEs. Each COURSE may be a prerequisite for zero, one, or many COURSEs. Each EMPLOYEE must be managed by one and only one EMPLOYEE. Each EMPLOYEE may manage zero, one, or many EMPLOYEEs.

13 Binary Relationship EMPLOYEE STUDENT COURSE assigned to Each EMPLOYEE must be assigned to one and only one OFFICE. Each OFFICE may be assigned to one and only one EMPLOYEE. Each STUDENT may be registered for zero, one, or many COURSEs. Each COURSE may be taken by for zero, one, or many STUDENTs. Each CUSTOMER may place zero, one, or many ORDERs. Each ORDER must be placed by one and only one CUSTOMER. OFFICE CUSTOMER ORDER registered for taken by place placed by

14 Ternary Relationship STUDENT MAJOR ADVISOR Each STUDENT must have declared one or more MAJORs and be assigned to one or more ADVISORs. Each ADVISOR must be assigned to one or more STUDENTs and be responsible for one or more MAJORS. Each MAJOR must be declared by one or more STUDENTs and be assigned to one or more ADVISORs.

15 Relationship Types in the REA Model of the Client Billing Business Process

16 Constraints in the E-R Diagram Cardinality is the most common business rule (constraint) specified in E- R diagrams. The other meaningful business rule that may be specified is participation. –The participation constraint (or optionality) specifies the degree of minimum participation of one entity in the relationship with the other entity.

17 Constraints in the E-R Diagram In Figure 6.4 part (b), the participation constraints appear in the diagram. –In the Works relationship, not all employees are billable –Some employees are new and are not yet billable –Others might be involved with training or new business development. The “many” cardinality in part (a) of the diagram only specifies the maximum participation in the relationship, not the minimum. –The minimum participation in the relationship can be zero or one. –The notation (0,N) on the line on the right in part (b) reflects the range of zero to many occurrences of work being completed on client projects, where the numbers reflect (minimum, maximum). –The notation (1,1) on the line on the left side in part (b), illustrates that for any given occurrence of work completed for a client, the maximum of one employee providing the specific service still holds. –The (1,1) relationship reflects that there is a required participation of one, and only one, employee.

18 Relationship Constraints in the Client Billing Business Process Figure 6.4

19 Developing an REA Model The objective in the development of an REA model is to integrate the data in a way that allows managers and other users access to the information they need to perform effectively. Figure 6.5 presents the integrated REA data model for the billing and human resources business processes.

20 An Integrated REA Model for the Client Billing and Human Resources Processes

21 Relational Database Concepts A relation is a collection of data representing multiple occurrences of a resource, event, or agent. –These relations correspond to the entities in the E-R model and the REA model. A tuple (record) is a set of data that describes a single instance of the entity represented by a relation –For example, one employee is an instance of the EMPLOYEE relation. Attributes, as in an E-R model, represent an item of data that characterizes an object, event, or agent. –Attributes are often called fields.

22 Example of a Relation Figure 6.6

23 Steps in Mapping an REA Model to a Relational DBMS 1.Create separate relational table for each entity. 2.Determine primary key for each relation. The primary key must uniquely identify any row within table. 3.Determine the attributes for each of the entities 4.Implement the relationships among the entities by ensuring that the primary key in one table also exists as an attribute in every table for which there is a relationship specified in the REA diagram. 5.Determine attributes, if any, for relationship tables

24 Steps 1 and 2: Mapping an REA Model to a Relational DBMS 1.Create separate relational table for each entity. –First specify the database schema before expanding the relations to account for specific tuples. –Notice that each of the entities in Figure 6.5 has become a relation in Figure 6.8 –To complete the schema, however, steps 2 and 3 also must be completed. 2.Determine primary key for each relation. The primary key must uniquely identify any row within table.

25 Step 3: Mapping an REA Model to a Relational DBMS 3.Determine attributes for each of the entities –In Figure 6.5, a complete REA model includes all the attributes, including the key attribute –The key attribute specified in the REA model is matched to the corresponding attribute in the relation An example is Employee_Number in the EMPLOYEE agent entity shown in Figure 6.5 –To create a composite primary key, you simply break the key down into its component subattributes. For instance, in the implementation of the WORK_COMPLETED event relation, Employee_No, Date, and Client_No are three distinct attributes in the relation, but also combine to form the composite primary key. –Note the direct mapping between the entities and attributes in the REA model and the relations and attributes, respectively, in the relational schema The completed schema is presented in Figure 6.8

26 Schema for the Client Billing and Human Resources Portion of the Database

27 Step 4: Mapping an REA Model to a Relational DBMS 4.Implement the relationships among the entities by ensuring that the primary key in one table also exists as an attribute in every table for which there is a relationship specified in the REA diagram. –With the availability of the full REA model, the mapping of the relationships in the model to the relationships in the relational schema is straightforward. –References to the key attributes of one entity are captured by including a corresponding attribute in the other entity that participates in the relationship. –All of the relationships in Figure 6.5 are 1:N relationships, which simplifies the process. The REA model for the client billing and human resource process

28 Step 4 continued One-to-many (1:N or N:1) relationships are implemented by including the primary key of the table on the one side of the relationship as an attribute in the table on the many side of the relationship –This is the situation we have for all the relationships in Figure 6.5: The Integrated REA Model for the Client Billing and Human Resources Process The linking between these relationships in the schema are drawn in Figure 6.9 –The recursive relationship with EMPLOYEE uses Supervisor_No identifies the correct EMPLOYEE as the supervisor One-to-one (1:1) relationships are even easier –Follow the same steps used for 1:N relationships, but you can start with either table.

29 Referential Constraints for the Relational Schema

30 Step 4 continued Many-to-many (M:N) relationships are implemented by creating a new relation whose primary key is a composite of the primary keys of the relations to be linked. –We don’t have any M:N relationships in the current REA Model –We would need a relationship between the EMPLOYEE and CLIENT entities, which would then be an M:N relationship. –This creates problems because these tables (that have been normalized) cannot store multiple client numbers in a single EMPLOYEE tuple. –Similarly, a single CLIENT tuple cannot store multiple employee numbers. –In that situation, we would need to develop a M:N relation to link the EMPLOYEE and CLIENT relations as shown Figure 6.10

31 Linking Two Relations in a Many-to-Many Relationship

32 Step 5: Mapping an REA Model to a Relational DBMS 5.Determine attributes, if any, for relationship tables. –Again, in the extended version of the REA model, the attributes map directly to the relations. –The implementation of the schema is shown in Figure 6.11

33 Implemented Relational Schema