2 Learning ObjectivesExplain the importance and advantages of databases, as well as the difference between database and file-based legacy systems.Explain the difference between logical and physical views of a database.Explain fundamental concepts of database systems such as DBMS, schemas, the data dictionary, and DBMS languages.Describe what a relational database is and how it organizes data.Create a set of well-structured tables to properly store data in a relational database.
3 What Is a Database?Efficiently and centrally coordinates information for a related group of files
4 Let’s examine some basic principles about how data are stored in computer systems. An entity is anything about which the organization wishes to store data. At your college or university, one entity would be the student.STUDENTStudent IDStudent Last NameStudent First NameStudent Phone NumberStudent Birth DateSimpsonAlice10/11/84SandersNed11/24/86MooreArtie04/20/85
5 A field is the physical space where an attribute is stored. Information about the attributes of an entity (e.g., the student’s ID number and birth date) are stored in fields.A field is the physical space where an attribute is stored.STUDENTStudent IDStudent Last NameStudent First NameStudent Phone NumberStudent Birth DateSimpsonAlice10/11/84SandersNed11/24/86MooreArtie04/20/85
6 The example below shows the record for Artie Moore. All the fields containing data about one entity (e.g., one student) form a record.A record is the set of attributes stored for a particular instance of an entity.The example below shows the record for Artie Moore.STUDENTStudent IDStudent Last NameStudent First NameStudent Phone NumberStudent Birth DateSimpsonAlice10/11/84SandersNed11/24/86MooreArtie04/20/85
7 A data value is the intersection of the row and column. The data value for Ned Sanders’ birth date is 11/24/86.STUDENTStudent IDStudent Last NameStudent First NameStudent Phone NumberStudent Birth DateSimpsonAlice10/11/84SandersNed11/24/86MooreArtie04/20/85
8 A set of all related records forms a file (e.g., the student file). If this university only had three students and five fields for each student, then the entire file would be depicted below.STUDENTStudent IDStudent Last NameStudent First NameStudent Phone NumberStudent Birth DateSimpsonAlice10/11/84SandersNed11/24/86MooreArtie04/20/85
9 Student File Class File Advisor File A set of interrelated, centrally coordinated files forms a database.When files about students are integrated with files about classes and files about advisors, we have a database.StudentFileClassFileAdvisorFile
10 Database systems were developed to address the problems associated with the proliferation of master files.For years, each time a new information need arose, companies created new files and programs.The result: a significant increase in the number of master files.
11 This proliferation of master files created problems: Fact AFact BFact CThis proliferation of master files created problems:Often the same information was stored in multiple master files.Made it more difficult to effectively integrate data and obtain an organization-wide view of the data.Also, the same information may not have been consistent between files.If a student changed his phone number, it may have been updated in one master file but not another.EnrollmentProgramMaster File 2Fact AFact DFact FFin. AidProgramMaster File 3Fact AFact BFact FGradesProgram
12 DatabaseFact A Fact BFact C Fact DFact E Fact FThe combination of the database, the DBMS, and the application programs that access the database is referred to as the database system.DatabaseManagementSystemEnrollmentProgramFin. AidProgramGradesProgram
13 Advantages of Databases Data is integrated and easy to shareMinimize data redundancy and data inconsistencyData is independent of the programs that use the dataData is easily accessed for reporting and cross- functional analysis
14 Database Users and Designers At one level of the database is the physical view of the data which is how the data is actually physically stored in the system.Designers of a database also need to understand user’s needs and the logical view of the entire database as well as the physical view.
15 DBMS Database Logical View—User A Logical View—User B Enrollment by ClassDBMSThe DBMS translates users’ logical views into instructions as to which data should be retrieved from the database.OperatingSystemDatabase
16 Schemas A schema describes the logical structure of a database. There are three levels of schema.Conceptual levelExternal levelInternal level
17 Schemas Describe the logical structure of a database Conceptual Level Organization wide view of the dataExternal LevelIndividual users view of the dataEach view is a subschemaInternal LevelDescribes how data are stored and accessedDescription of: records, definitions, addresses, and indexes
18 Database DesignThe data dictionary is a “blueprint” of the structure of the database and includes data elements, field types, programs that use the data element, outputs, and so on.
19 DBMS Languages Data Definition Language (DDL) Builds the data dictionaryCreates the databaseDescribes logical views for each userSpecifies record or field security constraintsData Manipulation Language (DML)Changes the content in the databaseCreates, updates, insertions, and deletionsData Query Language (DQL)Enables users to retrieve, sort, and display specific data from the database
20 RELATIONAL DATABASESA DBMS is characterized by the type of logical data model on which it is based.A data model is an abstract representation of the contents of a database.Most new DBMSs are called relational databases because they use the relational model developed by E.F. Codd in 1970.The relational data model represents everything in the database as being stored in the forms of tables (aka, relations).
21 A primary key is the attribute or combination of attributes that uniquely identifies a specific row in a table.
22 STUDENTStudent IDLast NameFirst NamePhone No.Advisor No.SimpsonAlice1418SandersNedMooreArtie1503ADVISORAdvisor No.Last NameFirst NameOffice No.1418HowardGlen4201419MeltonAmy3161503ZhangXi2021506RadowskiJ.D.203A foreign key is an attribute in one table that is a primary key in another table. Used to link the two tables.
23 Database Design Errors If database is not designed properly data errors can occur.Update AnomalyChanges to existing data are not correctly recorded.Due to multiple records with the same data attributesInsert AnomalyUnable to add a record to the database.Delete AnomalyRemoving a record also removes unintended data from the database.
24 RELATIONAL DATABASES Alternatives for Storing Data One possible alternate approach would be to store all data in one uniform table.For example, instead of separate tables for students and classes, we could store all data in one table and have a separate line for each student - class combination.
25 In the above, simplified example, a number of problems arise. Student IDLast NameFirst NamePhone No.Course No.SectionDayTimeSimpsonAliceACCT-36031M9:00 AMFIN-32133Th11:00 AMMGMT-302111TH12:00 PMSandersNedACCT-34332T10:00 AM5W8:00 AMANSI-14227FMooreArtieUsing the suggested approach, a student taking three classes would need three rows in the table.In the above, simplified example, a number of problems arise.
26 This problem is referred to as an update anomaly. Student IDLast NameFirst NamePhone No.Course No.Sect.DayTimeSimpsonAliceACCT-36031M9:00 AMFIN-32133Th11:00 AMMGMT-302111TH12:00 PMSandersNedACCT-34332T10:00 AM5W8:00 AMANSI-14227FMooreArtieSuppose Alice Simpson changes her phone number. You need to make the change in three places. If you fail to change it in all three places or change it incorrectly in one place, then the records for Alice will be inconsistent.This problem is referred to as an update anomaly.
27 This problem is referred to as an insert anomaly. Student IDLast NameFirst NamePhone No.Course No.Sect.DayTimeSimpsonAliceACCT-36031M9:00 AMFIN-32133Th11:00 AMMGMT-302111TH12:00 PMSandersNedACCT-34332T10:00 AM5W8:00 AMANSI-14227FMooreArtieWhat happens if you have a new student to add, but he hasn’t signed up for any courses yet?Or what if there is a new class to add, but there are no students enrolled in it yet? In either case, the record will be partially blank.This problem is referred to as an insert anomaly.
28 This problem is referred to as a delete anomaly. Student IDLast NameFirst NamePhone No.Course No.Sect.DayTimeSimpsonAliceACCT-36031M9:00 AMFIN-32133Th11:00 AMMGMT-302111TH12:00 PMSandersNedACCT-34332T10:00 AM5W8:00 AMANSI-14227FMooreArtieIf Ned withdraws from all his classes and you eliminate all three of his rows from the table, then you will no longer have a record of Ned. If Ned is planning to take classes next semester, then you probably didn’t really want to delete all records of him.This problem is referred to as a delete anomaly.
29 RELATIONAL DATABASES Alternatives for Storing Data Another possible approach would be to store each student in one row of the table and create multiple columns to accommodate each class that he is taking.
30 This approach is also fraught with problems: Student IDLast NameFirst NamePhone No.Class 1Class 2Class 3Class 4SimpsonAliceACCT-3603FIN-3213MGMT-3021SandersNedACCT-3433ANSI-1422MooreArtieThis approach is also fraught with problems:How many classes should you allow for in building the table?The above table is quite simplified. In reality, you might need to allow for 20 or more classes (assuming a student could take many 1-hour classes). Also, more information than just the course number would be stored for each class. There would be a great deal of wasted space for all the students taking fewer than the maximum possible number of classes.Also, if you wanted a list of every student taking MGMT-3021, notice that you would have to search multiple attributes.
31 The solution to the preceding problems is to use a set of tables in a relational database. Each entity is stored in a separate table, and separate tables or foreign keys can be used to link the entities together.
32 Add a student here.Leaves no blank spaces.Add a course here.Leaves no blank spaces.When a particular student enrolls for a particular course, add that info here.
33 Ned still exists in the student table. Even if Ned was the only student in the class, ACCT-3603 still exists in the course table.If Ned Sanders drops ACCT-3603, remove Ned’s class from this table.
34 Relational Database Design Rules Every column in a row must be single valuedPrimary key cannot be null (empty) also known as entity integrityIF a foreign key is not null, it must have a value that corresponds to the value of a primary key in another table (referential integrity)All other attributes in the table must describe characteristics of the object identified by the primary keyFollowing these rules allows databases to be normalized and solves the update, insert, and delete anomalies.
35 STUDENTStudent IDLast NameFirst NamePhone No.Advisor No.SimpsonAlice1418SandersNedMooreArtie1503ADVISORAdvisor No.Last NameFirst NameOffice No.1418HowardGlen4201419MeltonAmy3161503ZhangXi2021506RadowskiJ.D.203Advisor No. is a foreign key in the STUDENTS table. Every incident of Advisor No. in the STUDENTS table either matches an instance of the primary key in the ADVISORS table or is null.
36 RELATIONAL DATABASESThere are two basic ways to design well- structured relational databases.NormalizationSemantic data modeling
37 RELATIONAL DATABASES Normalization Starts with the assumption that everything is initially stored in one large table.A set of rules is followed to decompose that initial table into a set of normalized tables.Objective is to produce a set of tables in third- normal form (3NF) because such tables are free of update, insert, and delete anomalies.Approach is beyond the scope of this book but can be found in any database textbook.
38 RELATIONAL DATABASESSemantic data modeling (covered in detail in Chapters 17 and 18)Database designer uses knowledge about how business processes typically work and the information needs associated with transaction processing to draw a graphical picture (ERD) of what should be included in the database.The resulting graphic is used to create a set of relational tables that are in 3NF.
39 RELATIONAL DATABASESAdvantages over simply following normalization rules:Semantic data modeling uses the designer’s knowledge about business processes and practices; it therefore facilitates efficient design of transaction processing databases.The resulting graphical model explicitly represents information about the organization’s business processes and policies and facilitates communication with intended users.
40 As accountants, you are likely to audit or work for companies that use database technology to store, process, and report accounting transactions.Many accountants work directly with databases and will enter, process, and query databases.Some will develop and evaluate internal controls necessary to ensure database integrity.Others will be involved in the design and management of databases.