Quick viewing(Text Mode)

Database Planning and Database Architecture

Database Planning and Database Architecture

06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 25

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC CHAPTERNOT FOR SALE OR DISTRIBUTION NOT FOR2 SALE OR DISTRIBUTION © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT DatabaseFOR SALE OR DISTRIBUTION Planning NOT FOR SALE OR DISTRIBUTION and © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,Chapter LLC Objectives NOT FOR SALE ORChapter DISTRIBUTION Objectives NOT FOR SALE OR DISTRIBUTIONIn this chapter you will 2.1 Data as a Resource learn the following: 2.2 Characteristics of Data The distinction 2.2.1 Data© Jones and Information & Bartlett Learning, LLC © Jonesbetween & dataBartlett and Learning, LLC 2.2.2 LevelsNOT ofFOR Discussing SALE Data OR DISTRIBUTION NOTinformation FOR SALE OR DISTRIBUTION

2.2.3 Data Sublanguages The four levels of 2.3 Stages in Database discussion about data © Jones2.4 Design & Bartlett Tools Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR2.4.1 SALEData ORDictionary DISTRIBUTION NOT FOR SALE ORThe DISTRIBUTIONsteps in staged 2.4.2 Project Management Software database design 2.5 The functions of a database 2.5.1 Planning and Design administrator © Jones & Bartlett Learning,2.5.2 Developing LLC the Database © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION The distinction 2.5.3 Database Management between DDL and 2.6 The Three- Database Architecture DML 2.6.1 External Views The rationale for 2.6.2 Logical© Jones and &Conceptual Bartlett Models Learning, LLC © Jonesand contents & Bartlett of the Learning, LLC 2.6.3 InternalNOT FOR Model SALE OR DISTRIBUTION NOTthree-level FOR SALE database OR DISTRIBUTION 2.6.4 Data Independence architecture 2.7 Overview of Data Models The meaning of © Jones2.7.1 & BartlettThe Entity-Relationship Learning, LLC Model © Jones & Bartlettlogical Learning, and physical LLC data independence NOT FOR2.7.2 SALERelational OR DISTRIBUTION Model NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 26

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

26 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Characteristics of NOT FOR SALE2.7.3 ORObject-Oriented DISTRIBUTION Model NOT FOR SALE OR DISTRIBUTION various data models 2.7.4 Object- 2.7.5 Semistructured © Jones & Bartlett Learning,2.8 Chapter LLC Summary © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONExercises NOT FOR SALE OR DISTRIBUTION On the Companion Website: Lab Exercises

© Jones & Bartlett Learning, LLC Sample Project© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION Student ProjectsNOT FOR SALE OR DISTRIBUTION

2.1 Data as a Resource © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORIf you SALE were askedOR DISTRIBUTION to identify the resources of a typical businessNOT FOR organiza- SALE OR DISTRIBUTION tion, you would probably include capital equipment, financial assets, and personnel, but you might not think of data as a resource. When a corpo- rate database exists, the data it contains is a genuine corporate resource. © Jones & Bartlett Learning,Since the database LLC contains data about© theJones organization’s & Bartlett operations Learning, LLC NOT FOR SALE OR(called DISTRIBUTION operational data) that is used by NOTmany FORdepartments, SALE andOR since DISTRIBUTION it is professionally managed by a DBA, there is an increased appreciation of the value of the data itself, independent of the applications that use it. A resource is any asset that is of value to an organization and that incurs © Jones & Bartlett Learning, LLCcosts. An organization’s© operational Jones & Bartlettdata clearly Learning, fits this definition. LLC To NOT FOR SALE OR DISTRIBUTIONappreciate the value ofNOT an organization’s FOR SALE data OR more DISTRIBUTION fully, imagine what would happen if the data were lost or fell into the hands of a competitor. Many organizations, such as banks and brokerage houses, are heavily dependent on data, and would fail very quickly if their data were lost. © JonesMost & Bartlettbusinesses Learning, would suffer LLC heavy losses if their operational© Jones data & were Bartlett Learning, LLC NOT FORunavailable. SALE InOR fact, DISTRIBUTION an organization depends on the availabilityNOT FOR of opera- SALE OR DISTRIBUTION tional data in managing its other resources. For example, decisions about the purchase, lease, or use of equipment; financial investments and finan- cial returns; and staffing needs should be made on the basis of informa- © Jones & Bartlett Learning,tion about theLLC organization’s operations.© Jones The recognition & Bartlett of Learning, data as a LLC NOT FOR SALE ORcorporate DISTRIBUTION resource is an important objectiveNOT inFOR developing SALE anOR integrated DISTRIBUTION database environment. The database protects the data resource by provid- ing data security, integrity, and reliability controls through the DBMS.

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 27

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.2 Characteristics of Data 27

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC 2.2 CharacteristicsNOT FOR SALE of Data OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

In order to appreciate the importance of data as a corporate resource, we need to examine its characteristics more closely. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC 2.2.1 Data and Information NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION We often think of data as information, but these two terms have slightly dif- ferent meanings. The term data refers to the bare facts recorded in the data- base. Information is processed data that is in a form that is useful for making © Jones & Bartlettdecisions. Learning, Information LLC is derived from the stored© Jones data by & re-arranging, Bartlett Learning, select- LLC NOT FOR SALE ORing, DISTRIBUTION combining, summarizing, or performingNOT other FOR operations SALE on OR the DISTRIBUTION data. For example, if we simply print out all the stored items in the database shown in Figure 1.1, without the headings that identify what they represent, we have data. However, if we print a formatted report such as the one in Fig- ure 1.3, showing© Jones the data & Bartlett in some orderLearning, that helps LLC us make a decision, we © Jones & Bartlett Learning, LLC have information.NOT FOR In practice, SALE most OR people DISTRIBUTION use the two terms interchangeably. NOT FOR SALE OR DISTRIBUTION 2.2.2 Levels of Discussing Data When we discuss data, it is important to distinguish between the real © Jonesworld, & the Bartlett small part Learning, of the real LLC world that the database is concerned© Jones with, & Bartlett Learning, LLC NOT theFOR inherent SALE structure OR DISTRIBUTION of that portion of the world, the structureNOT FOR of the SALE OR DISTRIBUTION database, and the data stored in the database. There are actually four levels of discussion or abstraction to be considered when we talk about . We begin with the real world, or reality. On this first level, we talk about © Jones & Bartlettthe Learning, enterprise, LLC the organization for which© the Jones database & Bartlettis designed. Learning, The LLC NOT FOR SALE ORenterprise DISTRIBUTION might be a corporation, governmentNOT agency,FOR SALE university, OR bank,DISTRIBUTION brokerage house, school, hospital, or other organization. As the enterprise functions in the real world, there is too much detail involved to keep track of all the facts needed for decision making by direct observation. Instead, we identify© those Jones facets & of Bartlett the enterprise Learning, that we LLC need to keep track of for © Jones & Bartlett Learning, LLC decision making.NOT FOR The part SALE of the OR real DISTRIBUTION world that will be represented in the NOT FOR SALE OR DISTRIBUTION database is called a miniworld or a universe of discourse. For the mini- world, we begin to develop a conceptual model, which forms the second level of data discussion. We identify entities which are persons, places, © Jonesevents, & objects,Bartlett or Learning,concepts about LLC which we collect data. For© the Jones organiza- & Bartlett Learning, LLC NOT tionsFOR mentioned SALE OR previously, DISTRIBUTION we could choose entities suchNOT as customers, FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 28

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

28 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORemployees, SALE students,OR DISTRIBUTION bank accounts, investments, classes,NOT or patients. FOR SALE We OR DISTRIBUTION group similar entities into entity sets. For example, for the set of all cus- tomers we form the entity set we might call Customers. Similarly, we might have entity sets called Employees, Students, Accounts, Investments, © Jones & Bartlett Learning,Classes, and LLCPatients—each consisting of© all Jones entity instances& Bartlett of theLearning, corre- LLC NOT FOR SALE ORsponding DISTRIBUTION type. A conceptual model may NOThave many FOR entity SALE sets. OR Each DISTRIBUTION entity has certain attributes, which are characteristics or properties to describe the entity and that the organization considers important. For the Student entity set, attributes might include student ID, name, address, telephone number, major, credits passed, grade point average, and adviser. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Some entities may have relationships or associations with other entities. NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION For example, in a university, students are related to classes by being enrolled in those classes, and faculty members are related to classes by teaching them. The conceptual model will represent these relationships by connecting the entity sets in some manner. The concepts of entity, © Jonesattribute, & Bartlett and relationship Learning, will LLC be discussed in more detail© Jones in Chapter & Bartlett 3. Learning, LLC NOT FORThe conceptualSALE OR model DISTRIBUTION is often represented by a diagram NOTsuch asFOR an ER SALE or OR DISTRIBUTION UML diagram. The model should be designed to be a useful picture of the organization and its operations for the miniworld of interest.

© Jones & Bartlett Learning,The structure LLC of the database, called the© logical Jones model & Bartlettof the database, Learning, is LLC NOT FOR SALE ORthe DISTRIBUTION third level of discussion. The logical NOTmodel FORis also SALE called the OR intension DISTRIBUTION of the database, and it is relatively permanent. The is a written description of the logical model. The schema may change occa- sionally if new data needs arise, a process called schema evolution.On this level, we talk about , or data about data. For each entity set in © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC the conceptual model, we have a record type (or equivalent representation, NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION such as a class) in the logical model of the database. For example, for the Student entity set in the university, we would have a Student record type. A record type contains several data item types, each of which represents an attribute of an entity. For the Student record type, the data item types © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC could be stuId, stuName, address, phone, major, credits, gpa, and NOT FORadviser SALE.A ORdata DISTRIBUTION item is the smallest named unit of storedNOT data. FOR Other SALE OR DISTRIBUTION words sometimes used for data item are data element, field, or attribute. Data items are sometimes grouped together to form data aggregates, which are named groups of data items within a record. Data aggregates © Jones & Bartlett Learning,allow us to refer LLC to the group of data items© Jones as a whole & Bartlettor to the individualLearning, LLC NOT FOR SALE ORitems DISTRIBUTION in the group. A record is a namedNOT collection FOR ofSALE related OR data DISTRIBUTION items

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 29

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.2 Characteristics of Data 29

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC and/or dataNOT aggregates. FOR SALE Relationships OR DISTRIBUTION must also be represented in the logi- NOT FOR SALE OR DISTRIBUTION cal model. Information about the logical structure of the database is stored in a DBMS , also called a data directory or system catalog. © JonesThis repository& Bartlett of Learning, information LLCcontains descriptions of the© record Jones types, & Bartlett Learning, LLC NOTdata FOR item SALE types, OR and DISTRIBUTION data aggregates in the database, as well NOTas other FOR infor- SALE OR DISTRIBUTION mation. The data dictionary is actually a database about the database. However, a DBMS system catalog usually does much more than simply store the description of the database structure. For some systems, the sys- © Jones & Bartletttem Learning, catalog is actively LLC involved in all database© accesses.Jones & Bartlett Learning, LLC NOT FOR SALE ORThe DISTRIBUTION fourth level of discussion concerns actualNOT data FOR in the SALE database OR itself. DISTRIBUTION It consists of data instances or occurrences. For each entity occurrence in the miniworld, there will be an occurrence of a corresponding record in the database. For each student in the university, there is a student record occurrence.© So,Jones while & there Bartlett is only Learning, one Student LLCrecord type, which is © Jones & Bartlett Learning, LLC described inNOT the dataFOR dictionary SALE OR and DISTRIBUTIONcorresponds to the Student entity set, NOT FOR SALE OR DISTRIBUTION there may be thousands of Student record occurrences, corresponding to individual student entities, in the database itself. Similarly, there will be many instances of each of the data item types that correspond to attrib- © Jonesutes. A& fileBartlett(sometimes Learning, called aLLC data set) is a named collection© Jones of record & Bartlett Learning, LLC NOT occurrences.FOR SALE For OR example, DISTRIBUTION the Student file may contain 5000NOT Student FOR SALE OR DISTRIBUTION records. Finally, the database may be thought of as a named collection of related files. The data stored in the database at a given moment is called an extension of the database, or a database instance or database state.The © Jones & Bartlettextension Learning, changes LLC whenever records are added,© Jones deleted, & Bartlett or updated. Learning, The LLC NOT FOR SALE ORextension DISTRIBUTION should always be a valid state, whichNOT means FOR it SALE should OR satisfy DISTRIBUTION all the constraints specified in the schema. The intension of the database is actually a complex abstract that formally defines all possible extensions. Figure 2.1 summarizes the four levels of discussion of data.

2.2.3 Data© SublanguagesJones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION The language that is used to describe a database to a DBMS is part of a data sublanguage. A data sublanguage consists of two parts: a (DDL) and a data manipulation language (DML). The DDL is © Jonesused to& Bartlettdescribe the Learning, database, whileLLC the DML is used to process© Jones the data- & Bartlett Learning, LLC NOT base.FOR These SALE languages OR DISTRIBUTION are called sublanguages because theyNOT have FOR limited SALE OR DISTRIBUTION functionality, lacking many features of general purpose programming

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 30

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

30 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORRealm SALE OR DISTRIBUTIONObjects Examples NOT FOR SALE OR DISTRIBUTION Real World Enterprise Corporation,university,bank Containing Miniworld Some aspects Human resources © Jones & Bartlett Learning, LLC of the enterprise© Jones Student & enrollment Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOTCustomers FOR SALE and accounts OR DISTRIBUTION Conceptual Model Entity a student,a class Attribute name,schedule Entity set all students,all classes © Jones & Bartlett Learning, LLC ©Relationship Jones & Bartlett Student Learning, entity relates LLC to Class NOT FOR SALE OR DISTRIBUTION NOT FOR SALE ORentity DISTRIBUTION by being enrolled in it Logical Model Record type Student record type, Metadata: Class record type © Jones &data Bartlett definitions, Learning, LLC © Jones & Bartlett Learning, LLC NOT FORstored SALE in OR DISTRIBUTIONData item type stuId,classNumberNOT FOR SALE OR DISTRIBUTION Data Dictionary Data aggregate address,consisting of street,city,state,ZIP © Jones & Bartlett Learning,Data LLC Student record© Jones Record of& student Bartlett Tom Smith Learning, LLC NOT FOR SALE OR OcurrencesDISTRIBUTION occurrence NOT FOR SALE OR DISTRIBUTION stored in the database Data item ‘S1001’,‘Smith’,‘Tom’,‘History’,90 occurrence © Jones & Bartlett Learning, LLC ©File Jones & BartlettStudent Learning, file with 5000 LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE ORStudent DISTRIBUTION records Database University database containing Student file, Class file,Faculty file,... © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORFIGURE SALE 2.1 OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Four Levels of Discussing Data

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 31

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.3 Stages in Database Design 31

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC languages.NOT The data FOR sublanguage SALE OR commands DISTRIBUTION can be embedded within a NOT FOR SALE OR DISTRIBUTION host program, a general purpose language program in, for example, C, C++, C#, Java, COBOL, Fortran, or Ada. There are standards for most of the widely used general purpose languages as host languages for standard © Jonesdata sublanguages. & Bartlett Learning, In addition, mostLLC data sublanguages allow© non-embed-Jones & Bartlett Learning, LLC NOTded FOR or interactiveSALE OR commands DISTRIBUTION for access from workstations. NOT FOR SALE OR DISTRIBUTION

2.3 Stages in Database Design

© Jones & BartlettThe Learning, process of LLC analyzing the organization© and Jones its environment, & Bartlett develop- Learning, LLC NOT FOR SALE ORing DISTRIBUTION a , and implementing thatNOT model FOR requires SALE anOR appro- DISTRIBUTION priate methodology. Traditional systems analysis provides a possible approach, but a staged database design approach offers a better solution. The database should be designed in such a way that it can evolve, chang- ing to meet© the Jones future & information Bartlett Learning, needs of the LLC organization. This evolu- © Jones & Bartlett Learning, LLC tion is possibleNOT whenFOR theSALE OR developsDISTRIBUTION a true conceptual model of NOT FOR SALE OR DISTRIBUTION the organization with the following characteristics:

The model faithfully mirrors the operations of the organization. © Jones & ItBartlett is flexible Learning, enough to allow LLC changes as new information© Jones needs arise. & Bartlett Learning, LLC NOT FOR SALEIt supports OR manyDISTRIBUTION different user views. NOT FOR SALE OR DISTRIBUTION

It is independent of physical implementation.

It does not depend on the data model used by a particular data- © Jones & Bartlett Learning,base management LLC system. © Jones & Bartlett Learning, LLC NOT FOR SALE ORA well-designed DISTRIBUTION conceptual database modelNOT protects FOR the SALE data resource OR DISTRIBUTION by allowing it to evolve so that it serves both today’s and tomorrow’s infor- mation needs. Even if the database management system chosen for imple- mentation is replaced, the logical model may change, but the conceptual model of the© Jonesenterprise & canBartlett survive. Learning, The staged LLCdatabase design approach © Jones & Bartlett Learning, LLC is a top-downNOT method FOR thatSALE begins OR with DISTRIBUTION general statements of needs, and NOT FOR SALE OR DISTRIBUTION progresses to more and more detailed consideration of problems. Differ- ent problems are considered at different phases of the project. Each stage

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 32

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

32 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC FIGURE 2.2 NOT FOR SALE OR DISTRIBUTIONAnalyze User NOT FOR SALE OR DISTRIBUTION Steps in Staged Database Environment Design

© Jones & Bartlett Learning, LLC Develop © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION Conceptual Model NOT FOR SALE OR DISTRIBUTION

Choose DBMS © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

Develop Logical Model © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Develop Physical Model

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION Evaluate Physical NOT FOR SALE OR DISTRIBUTION Model

© Jones & Bartlett Learning, LLC ©Tune Jones System & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

Implement System © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

uses design tools that are appropriate to the problem at that level. Figure 2.2 shows the major design stages. They are © Jones & Bartlett Learning,1. Analyze LLC the user environment. © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONThe first step in designing a databaseNOT FOR is to determine SALE OR the DISTRIBUTION current user environment. The designer studies all current applications,

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 33

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.3 Stages in Database Design 33

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC determinesNOT FOR their SALE input OR and DISTRIBUTION output, examines all reports gener- NOT FOR SALE OR DISTRIBUTION ated by the present system, and interviews users to determine how they use the system. After the present system is thoroughly understood, the designer works closely with present users and © Jones & potentialBartlett usersLearning, of the newLLC system to identify their© needsJones using & Bartlett Learning, LLC NOT FOR SALEthese sameOR DISTRIBUTION methods. The designer considers notNOT only FOR present SALE OR DISTRIBUTION needs but possible new applications or future uses of the data- base. The result of this analysis is a model of the user environ- ment and requirements. © Jones & Bartlett Learning,2. Develop LLC a conceptual data model. © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONUsing the model of the user environment,NOT FOR the designer SALE developsOR DISTRIBUTION a detailed conceptual model of the database—identifying the enti- ties, attributes, and relationships that will be represented. In addi- tion to the conceptual model, the designer has to consider how the© database Jones is& to Bartlett be used. Learning, The types of LLC applications and transac- © Jones & Bartlett Learning, LLC tions,NOT the FOR kinds SALE of access, OR the DISTRIBUTION volume of transactions, the volume NOT FOR SALE OR DISTRIBUTION of data, the frequency of access, and other quantitative data must be specified. Other constraints such as budgetary restrictions and performance requirements must also be identified. The result of © Jones & thisBartlett phase Learning, is a set of database LLC specifications. © Jones & Bartlett Learning, LLC NOT FOR3. SALE Choose OR a DBMS. DISTRIBUTION NOT FOR SALE OR DISTRIBUTION The designer uses the specifications and knowledge of available hardware and software resources to evaluate alternative database management systems and chooses the system that best satisfies the © Jones & Bartlett Learning,specifications. LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR 4.DISTRIBUTION Develop the logical model. NOT FOR SALE OR DISTRIBUTION The designer maps the conceptual model to the data model used by the chosen DBMS, creating the logical model. 5. Develop the physical model. The© designerJones &plans Bartlett the layout Learning, of data consideringLLC the structures © Jones & Bartlett Learning, LLC supportedNOT FOR by theSALE chosen OR DBMS,DISTRIBUTION and hardware and software NOT FOR SALE OR DISTRIBUTION resources available. 6. Evaluate the physical model. The designer estimates the performance of all applications and © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC transactions, considering the quantitative data previously identi- NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION fied, information about the performance characteristics of hard- ware and software to be used, and priorities given to applications

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 34

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

34 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALEand OR transactions. DISTRIBUTION It can be helpful to develop a prototypeNOT FOR, imple- SALE OR DISTRIBUTION menting a selected portion of the database so that user views can be validated and performance measured more accurately. 7. Perform tuning if indicated by the evaluation. © Jones & Bartlett Learning,Adjustments LLC such as modifying ©physical Jones structures & Bartlett or optimizing Learning, LLC NOT FOR SALE OR DISTRIBUTIONsoftware can be done to improveNOT performance. FOR SALE OR DISTRIBUTION 8. Implement the physical model. If the evaluation is positive, the designer then implements the physical design and the database becomes operational. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONThe loops in Figure 2.2 provideNOT FOR opportunities SALE OR for DISTRIBUTIONfeedback and changes at various stages in the design process. For example, after developing the conceptual model, the designer communicates with user groups to make sure their data requirements are represented properly. If not, the concep- © Jonestual & model Bartlett must Learning, be adjusted. LLC If the conceptual model does© Jones not map & wellBartlett Learning, LLC NOT FORto a particularSALE OR data DISTRIBUTION model, another should be considered.NOT For aFOR particular SALE OR DISTRIBUTION DBMS, there might be several possible logical mappings that can be evalu- ated. If the physical model is not acceptable, a different mapping or a dif- ferent DBMS can be considered. If the results of the performance evaluation are not satisfactory, additional tuning and evaluation may be © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC performed. The physical model can be changed if tuning does not produce NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION the required performance. If repeated tuning and optimization are not sufficient, it might be necessary to change the way the logical model is mapped to the DBMS or to consider a different database management sys- tem. Even after the system is implemented, changes might be needed to © Jones & Bartlett Learning, LLCrespond to changing user© needs Jones or a& changing Bartlett environment. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.4 Design Tools

Many methodologies exist that can make the database design process © Joneseasier & Bartlett for both designersLearning, and LLC users. They vary from general© Jones techniques & Bartlett Learning, LLC NOT FORdescribed SALE in OR the softwareDISTRIBUTION literature to commercialNOT FOR products SALE OR DISTRIBUTION to automate the design process. For example, CASE (Computer-Aided Software Engineering) packages include various tools for system analy- sis, project management, and design that can be very useful in the data- © Jones & Bartlett Learning,base design LLC process. They are helpful for© Jones collecting & andBartlett analyzing Learning, data, LLC NOT FOR SALE ORdesigning DISTRIBUTION the data model, designing applications,NOT FOR SALE and implementing OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 35

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.4 Design Tools 35

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC the database,NOT including FOR SALE prototyping, OR DISTRIBUTION data conversion, generating appli- NOT FOR SALE OR DISTRIBUTION cation code, generating reports, and testing. Project management soft- ware is another type of tool that can be applied effectively to database development. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT2.4.1 FOR SALE Data Dictionary OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION A DBMS data dictionary, as discussed in Section 2.2.2, is a repository of information that describes the logical structure of the database. It contains metadata, or data about the data in the database. It has entries for all the © Jones & Bartletttypes Learning, of objects LLC that exist in the database. If© theJones data dictionary& Bartlett is partLearning, of LLC NOT FOR SALE ORthe DBMS,DISTRIBUTION it is referred to as an integratedNOTdata dictionary FOR SALE or system OR DISTRIBUTION cat- alog. A system catalog is always consistent with the actual database struc- ture, because it is maintained automatically by the system. It can perform many functions throughout the life of the database. If the data dictionary is available© without Jones a &particular Bartlett DBMS, Learning, we refer LLC to it as a freestanding © Jones & Bartlett Learning, LLC data dictionary.NOT AFOR freestanding SALE dataOR dictionaryDISTRIBUTION can be a commercial prod- NOT FOR SALE OR DISTRIBUTION uct or a simple file developed and maintained by the designer. For exam- ple, CASE packages often include a data dictionary tool, and freestanding data dictionaries are available even for non-database environments. Both © Jonesintegrated & Bartlett and freestanding Learning, data LLC dictionaries have advantages© Jones and disad- & Bartlett Learning, LLC NOT vantages,FOR SALE but aOR freestanding DISTRIBUTION dictionary is helpful in theNOT initial FOR design SALE OR DISTRIBUTION stages, before the designer has chosen a particular DBMS. It allows the designer to enjoy the advantages of having this tool without committing to a particular implementation. A major disadvantage is that once the database is created, adjustments to its structure may not be entered into © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC the freestanding data dictionary and, over time, the dictionary will not be NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION an accurate reflection of the database structure. A freestanding data dictionary is useful in the early design stages for col- lecting and organizing information about data. Each data item, its source(s), its© name(s),Jones & its Bartlett uses, its meaning, Learning, its relationship LLC to other items, © Jones & Bartlett Learning, LLC its format,NOT and the FOR identity SALE of the OR person DISTRIBUTION or group responsible for entering NOT FOR SALE OR DISTRIBUTION it, updating it, and maintaining its correctness must be determined. The data dictionary provides an effective tool for accomplishing these tasks. The (DBA) can begin development of the data dic- © Jonestionary & byBartlett identifying Learning, data items, LLC securing agreement from users© Jones on a defi- & Bartlett Learning, LLC NOT nitionFOR SALE of each OR item, DISTRIBUTION and entering the item in the dictionary.NOT Since FOR users SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 36

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

36 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORshould SALE not be OR aware DISTRIBUTION of other users’ data, the DBA shouldNOT control FOR access SALE to OR DISTRIBUTION the dictionary. A freestanding data dictionary is useful for the following:

© Jones & Bartlett Learning, Collecting LLC and storing information© aboutJones data & inBartlett a central Learning, location. LLC NOT FOR SALE OR DISTRIBUTIONThis helps management to gain controlNOT overFOR data SALE as a resource. OR DISTRIBUTION Securing agreement from users and about the meanings of data items. An exact, agreed-upon definition of each item should be developed for storage in the data dictionary. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Communicating with users. The data dictionary greatly facilitates NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION communication, since exact meanings are stored. The dictionary also identifies the persons, departments, or groups having access to or interest in each item.

© Jones & BartlettIdentifying Learning, redundancy LLC and inconsistency in data© itemJones names. & Bartlett In Learning, LLC NOT FOR SALEthe processOR DISTRIBUTION of identifying and defining data items,NOT the FOR DBA SALEmay OR DISTRIBUTION discover synonyms, which are different names for the same item. The database can accept synonyms, but the system must be aware of them. The DBA might also discover homonyms, which are © Jones & Bartlett Learning,identical LLC names for different data© items.Jones These & Bartlett are never Learning, permit- LLC NOT FOR SALE OR DISTRIBUTIONted in a database. NOT FOR SALE OR DISTRIBUTION Keeping track of changes to the database structure. Changes such as creation of new data items and record types or alter- ations to data item descriptions should be recorded in the data © Jones & Bartlett Learning, LLC dictionary. © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Determining the impact of changes to the database structure. Since the data dictionary records each item, all its - ships, and all its users, the DBA can see what effects a change would have. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE Identifying OR DISTRIBUTION the sources of and responsibility for theNOT correctness FOR SALE of OR DISTRIBUTION each item. A general rule for data entry is that data should be cap- tured as near to its source as possible. The persons or departments that generate or capture values for each data item and those © Jones & Bartlett Learning,responsible LLC for updating each item© Jones should & be Bartlett listed in Learning, the data LLC NOT FOR SALE OR DISTRIBUTIONdictionary. NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 37

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.5 Database Administration 37

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC RecordingNOT FOR the external, SALE OR logical, DISTRIBUTION and internal schemas and the map- NOT FOR SALE OR DISTRIBUTION pings between them. This aspect will be discussed in Section 2.6.

Recording access control information. A data dictionary can record the identities of all those who are permitted to access each © Jones & item,Bartlett along Learning, with the type LLC of access-retrieval, insertion,© Jones update, & or Bartlett Learning, LLC NOT FOR SALEdeletion. OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

A DBMS system catalog can also perform all these functions, but it is also useful for providing audit information. The system cata- log can be used to record each access, allowing usage statistics to © Jones & Bartlett Learning,be collected LLC for auditing the system© and Jones spotting & Bartlett attempted Learning, secu- LLC NOT FOR SALE OR DISTRIBUTIONrity violations. NOT FOR SALE OR DISTRIBUTION Note that not all data dictionaries provide support for all of these func- tions, and some provide additional functions. Some just store the schema, some control© Jones documentation, & Bartlett while Learning, some system LLC catalogs are “meta- © Jones & Bartlett Learning, LLC systems” that control access to the database, generate system code, and NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION keep statistics on database usage as well.

2.4.2 Project Management Software © JonesThis type& Bartlett of software Learning, provides LLC a set of tools that can be© used Jones to plan & Bartlett Learning, LLC NOT andFOR manage SALE a OR project, DISTRIBUTION especially when there are many peopleNOT workingFOR SALE OR DISTRIBUTION on it. There are usually several types of graphs and charts available, such as Gantt charts and PERT charts, which are similar. The user specifies the objectives and scope of the project, identifies the major tasks and phases, indicates dependencies among the tasks, identifies the © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC resources available, and sets a timeline for completion of the tasks and NOT FOR SALE ORphases DISTRIBUTION of the project. The software can beNOT used FOR to generate SALE calendars,OR DISTRIBUTION to produce graphs with many different views of the progress of the project, and to provide a means of communication among the project staff, using either intranet or Internet access. An example is Microsoft Project. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.5 Database Administration

The database administrator is responsible for the design, operation, and © Jonesmanagement & Bartlett of the Learning, database. In LLC many cases, the conceptual© design Jones is done & Bartlett Learning, LLC NOT byFOR a database SALE designer, OR DISTRIBUTION and the DBA implements the design,NOT develops FOR the SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 38

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

38 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORsystem, SALE and ORmanages DISTRIBUTION it. The DBA must be technically competent,NOT FOR a goodSALE OR DISTRIBUTION manager, a skilled communicator, and must have excellent interpersonal and communication skills. The DBA has many functions that vary accord- ing to the stage of the database project. Major functions include planning, © Jones & Bartlett Learning,designing, developing, LLC and managing the© database. Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.5.1 Planning and Design

Preliminary Database Planning. If the DBA or database designer is chosen early enough in the project, he or she should © Jones & Bartlett Learning, LLC participate in© the Jones preliminary & Bartlett investigation Learning, and LLC feasibility NOT FOR SALE OR DISTRIBUTION study. NOT FOR SALE OR DISTRIBUTION

Identifying User Requirements. The DBA or designer examines all transactions and all reports generated by the present system and consults with users to determine whether they satisfy their © Jones & Bartlettinformation Learning, needs. HeLLC or she works with present© Jones and potential & Bartlett Learning, LLC NOT FOR SALEusers OR to designDISTRIBUTION new reports and new transactions.NOT The FOR frequency SALE OR DISTRIBUTION of reports and transactions and the timeframe within which they must be produced are also recorded. The DBA uses his or her knowledge of the long-term and short-term objectives of the © Jones & Bartlett Learning,organization LLC to prioritize user requirements.© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Developing and Maintaining the Data Dictionary. As he or she determines data needs of users, the DBA or designer stores data item names, sources, meanings, usage, and synonyms in the data dictio- nary. The DBA revises the data dictionary as the project progresses. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION Designing the ConceptualNOT FOR Model. SALEThe OR DBA DISTRIBUTION or designer identifies all entities, attributes, and relationships that are to be represented in the database, and develops a conceptual model that is an accu- rate reflection of the miniworld. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Choosing a DBMS. The DBA considers the conceptual model and NOT FOR SALEother OR database DISTRIBUTION specifications and the hardware andNOT software FOR avail- SALE OR DISTRIBUTION able, and chooses the DBMS that best fits the environment and meets the specifications.

© Jones & Bartlett Learning, Developing LLC the Logical Model.©There Jones may & beBartlett several Learning, ways the LLC NOT FOR SALE OR DISTRIBUTIONconceptual model could be mappedNOT toFOR the SALE data model OR DISTRIBUTION used by the DBMS. The DBA chooses the one that appears to be most appropriate.

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 39

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.5 Database Administration 39

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC DevelopingNOT FOR the SALE Physical OR Model. DISTRIBUTIONThere may be several ways the NOT FOR SALE OR DISTRIBUTION logical model could be mapped to the data structures provided by the DBMS and to physical devices. The DBA evaluates each map- ping by estimating performance of applications and transactions. © Jones & TheBartlett best mapping Learning, becomes LLC the physical model. © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.5.2 Developing the Database

Creating and Loading the Database. Once the physical model is developed, the DBA creates the structure of the database using the © Jones & Bartlett Learning,data definition LLC language for the chosen© Jones DBMS. & HeBartlett or she Learning,estab- LLC NOT FOR SALE OR DISTRIBUTIONlishes physical data sets, creates libraries,NOT FOR and loads SALE the ORdata DISTRIBUTION into the database.

Developing User Views. The DBA attempts to satisfy the data needs of all users. A user’s may be identical to the one requested© Jones in &the Bartlett initial design Learning, stages. LLC Often, however, users’ © Jones & Bartlett Learning, LLC requestsNOT changeFOR SALE as they OR begin DISTRIBUTION to understand the system better. If NOT FOR SALE OR DISTRIBUTION the view does not coincide with the user’s request, the DBA should present cogent reasons why the request has not been met and secure agreement on the actual view. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Writing and Maintaining Documentation. When the database is NOT FOR SALEcreated, OR the DISTRIBUTION DBA makes sure all documentation accuratelyNOT FOR reflects SALE OR DISTRIBUTION the structure of the database. Some database documentation is writ- ten automatically by the system catalog as the database is created.

© Jones & Bartlett Learning,Developing LLC and Enforcing Data Standards.© JonesSince & Bartlett the database Learning, is LLC shared by many users, it is important that standards be defined NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION and enforced for the benefit of all. Users who are responsible for inserting and updating data must follow a standard format for entering data. The user interface should be designed to make it easy for users to follow the standards by displaying default values, © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC showing acceptable ranges for items, and so on. Typical data stan- NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION dards include specifications for values, abbreviations, codes, punctuation, and capitalization. The system can automatically check for errors and range restrictions, uniqueness of key values, and relationships between data values in a single record, between © Jones & Bartlettrecords in Learning, the same file, LLC and between records in different© Jones files. & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Developing and Enforcing Application Program Standards. The DBA must develop security and privacy standards for applications

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 40

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

40 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALEand ORmake DISTRIBUTION sure they are subject to the audit mechanism,NOT FOR make SALE OR DISTRIBUTION proper use of the high-level data manipulation language, and fit the application development facilities provided by the DBMS. These standards apply both to old applications that are converted © Jones & Bartlett Learning,for use LLC with the database and to new© Jones applications. & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION Developing Operating Procedures.NOTThe FOR DBA SALE is responsible OR DISTRIBUTION for establishing procedures for daily startup of the DBMS (if necessary), smooth running of database operations, logging of transactions, periodic backups, security and authorization procedures, recording © Jones & Bartlett Learning, LLC hardware and software© Jones failures, & Bartlett taking performance Learning, measurements, LLC NOT FOR SALE OR DISTRIBUTION shutting down theNOT database FOR in SALE an orderly OR fashionDISTRIBUTION in case of failure, restarting and recovering after failure, and shutting down at the end of each day (if necessary). Since these procedures are performed by operators, the DBA must consult with the operations manager to © Jones & Bartlettensure thatLearning, operators areLLC trained in all aspects of database© Jones operations. & Bartlett Learning, LLC NOT FOR SALE Doing OR User DISTRIBUTION Training. End users, application programmers,NOT FOR SALE and OR DISTRIBUTION systems programmers who access the database should participate in training programs so that they can learn to use it most effectively. Sessions may be conducted by the DBA, the vendor of the DBMS, © Jones & Bartlett Learning,or other LLC technical trainers, either© onsite Jones or in & a trainingBartlett center. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.5.3 Database Management

Monitoring Performance. The DBA is responsible for collecting and analyzing statistics on database performance and responding © Jones & Bartlett Learning, LLC to user complaints© Jones and suggestions & Bartlett regarding Learning, performance. LLC The NOT FOR SALE OR DISTRIBUTION running time forNOT applications FOR SALE and the OR response DISTRIBUTION time for interac- tive queries should be measured, so that the DBA can spot prob- lems in database use. Usually, the DBMS provides facilities for recording this information. The DBA continually compares per- © Jones & Bartlettformance Learning, to requirements LLC and makes adjustments© when Jones necessary. & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Tuning and Reorganizing. If performance begins to degrade as changes are made to the stored data, the DBA can respond by adding or changing indexes, reorganizing files, using faster stor- age devices, or optimizing software. For serious performance © Jones & Bartlett Learning,problems, LLC he or she may have to© reorganize Jones & the Bartlett entire database. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Keeping Current on Database Improvements. The DBA should be aware of new features and new versions of the DBMS that become

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 41

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.6 The Three-Level Database Architecture 41

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC available.NOT FOR He or SALE she should OR evaluateDISTRIBUTION these new products and other NOT FOR SALE OR DISTRIBUTION hardware and software developments to determine whether they would provide substantial benefits to the organization. 2.6 The Three-Level Database Architecture © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOTIn FOR Section SALE 2.3, OR we presented DISTRIBUTION a staged database design processNOT that FOR began SALE OR DISTRIBUTION with the development of a conceptual model and ended with a physical model. Now we are ready to examine these and related concepts more closely. When we discuss a database, we need some means of describing dif- © Jones & Bartlettferent Learning, aspects of LLC its structure. An early proposal© Jones for a standardized & Bartlett vocabu- Learning, LLC NOT FOR SALE ORlary DISTRIBUTION and architecture for database systems wasNOT developed FOR SALE and published OR DISTRIBUTION in 1971 by the Database Task Group appointed by the Conference on Data Systems and Languages, or CODASYL DBTG. As a result of this and later reports, databases can be viewed at three levels of abstraction. The levels form a layered© Jonesthree-level & Bartlett architecture Learning,and are described LLC by three schemas, © Jones & Bartlett Learning, LLC which are writtenNOT FOR descriptions SALE of OR their DISTRIBUTION structures. The purpose of the three- NOT FOR SALE OR DISTRIBUTION level architecture is to separate the user’s model from the physical structure of the database. There are several reasons why this separation is desirable:

Different users need different views of the same data. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC The way a particular user needs to see the data may change over time. NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Users should not have to deal with the complexities of the data- base storage structures.

The DBA should be able to make changes to the conceptual model © Jones & Bartlett Learning,of the database LLC without affecting all© users. Jones & Bartlett Learning, LLC

NOT FOR SALE OR DISTRIBUTION The DBA should be able to changeNOT the logicalFOR SALEmodel, OR including DISTRIBUTION data structures and file structures, without affecting the concep- tual model or users’ views.

Database structure should be unaffected by changes to the physi- © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC cal aspects of storage, such as changes to storage devices. NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Figure 2.3 shows a simplified version of the three-level architecture of data- base systems. The way users think about data is called the external level.The internal level is the way the data is actually stored using standard data struc- © Jonestures & and Bartlett file organizations. Learning, However, LLC there are many different© Jones users’ views & Bartlett Learning, LLC NOT andFOR many SALE physical OR structures,DISTRIBUTION so there must be some methodNOT of mappingFOR SALE OR DISTRIBUTION the external views to the physical structures. A direct mapping is undesirable, since changes made to physical structures or storage devices would require a

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 42

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

42 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC FIGURE 2.3 NOT FOR SALE OR DISTRIBUTIONExternal NOT FOR SALE OR DISTRIBUTION Simplified Three-Level Level Architecture for Database Systems

© Jones & Bartlett Learning, LLC Logical © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION Level NOT FOR SALE OR DISTRIBUTION

Internal © Jones & Bartlett Learning, LLC © JonesLevel & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION corresponding change in the external to physical mapping. Therefore there is a middle level that provides both the mapping and the desired independence between the external and physical levels. This is the logical level. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR2.6.1 SALE External OR ViewsDISTRIBUTION NOT FOR SALE OR DISTRIBUTION The external level consists of many different external views or external models of the database. Each user has a model of the real world repre- sented in a form that is suitable for that user. Figure 2.4 presents a more © Jones & Bartlett Learning,detailed picture LLC of the three-level database© Jones architecture. & Bartlett The top Learning, level of LLC NOT FOR SALE ORFigure DISTRIBUTION 2.4 shows several external views.NOT A particular FOR SALE user interacts OR DISTRIBUTION with only certain aspects of the miniworld, and is interested in only some enti- ties, and only some of their attributes and relationships. Therefore, that user’s view will contain only information about those aspects. Other enti- © Jones & Bartlett Learning, LLCties or other attributes or© relationshipsJones & Bartlett may actually Learning, be represented LLC in the NOT FOR SALE OR DISTRIBUTIONdatabase, but the user willNOT be unaware FOR SALE of them. OR Besides DISTRIBUTION including different entities, attributes, and relationships, different views may have different representations of the same data. For example, one user may believe dates are stored in the form month, day, year, while another may believe they are © Jonesrepresented & Bartlett as year, Learning, month, day.LLC Some views might include© Jonesvirtual or& cal-Bartlett Learning, LLC NOT FORculated SALE data, OR data DISTRIBUTION not actually stored as such, but createdNOT when FOR needed. SALE OR DISTRIBUTION For example, age may not be actually stored, but dateOfBirth may be, and age may be calculated by the system when the user refers to it. Views may even include data combined or calculated from several records. An exter- © Jones & Bartlett Learning,nal record isLLC a record as seen by a particular© Jones user, & aBartlett part of hisLearning, or her LLC NOT FOR SALE ORexternal DISTRIBUTION view. An external view is actuallyNOT a collection FOR SALE of external OR DISTRIBUTIONrecords. The external views are described in external schemas (also called sub- schemas) that are written in the data definition language (DDL). Each

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 43

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.6 The Three-Level Database Architecture 43

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

External External External External View D View A View B View C Interactive DML External C++ Java COBOL Schemas + DML + DML + DML © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION User Interface External/Logical Mapping

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Logical Logical NOT FOR SALE OR DISTRIBUTION Model NOT FOR SALE OR DISTRIBUTIONSchema DBMS

Logical/Internal Mapping © Jones & BartlettLogical Learning, Record Interface LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

Internal Internal Model Schema © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Stored Record Interface

Physical OS Level © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

Physical Record Interface

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION • • • File 1 File 2 File n

© JonesFIGURE & 2.4 Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT Three-LevelFOR SALE Database OR Architecture DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 44

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

44 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORuser’s SALE schema OR gives DISTRIBUTION a complete description of each type ofNOT external FOR record SALE OR DISTRIBUTION that appears in that user’s view. The schemas are stored for use by the sys- tem data catalog in retrieving records. They should also be kept in source form as documentation. The DBMS uses the external schema to create a © Jones & Bartlett Learning,user interface LLC, which is both a facility and© Jones a barrier. & Bartlett An individual Learning, user LLC NOT FOR SALE ORsees DISTRIBUTION the database through this interface. ItNOT defines FOR and SALE creates ORthe workingDISTRIBUTION environment for that user, accepting and displaying information in the format the user expects. It also acts as a boundary below which the user is not permitted to see. It hides the logical, internal, and physical details from the user. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.6.2 Logical and Conceptual Models The middle level in the three-level architecture is the logical level,as shown in Figure 2.4. This model includes the entire information structure © Jonesof the& Bartlett database, Learning, as seen by the LLC DBA. It is the “community© Jones view” of & data, Bartlett Learning, LLC NOT FORand includesSALE OR a description DISTRIBUTION of all of the data that is availableNOT to FOR be shared. SALE OR DISTRIBUTION It is a comprehensive model or view of the workings of the organization in the miniworld. All the entities, with their attributes and relationships, are represented in the logical model using the data model that the DBMS © Jones & Bartlett Learning,supports. The LLC model includes any constraints© Jones on the& Bartlett data and Learning, semantic LLC NOT FOR SALE ORinformation DISTRIBUTION about the data meanings.NOT The logicalFOR SALE model supportsOR DISTRIBUTION the external views, in that any data available to any user must be present in or derivable from the logical model. The logical model is relatively constant. When the DBA originally it, he or she tries to determine present © Jones & Bartlett Learning, LLCand future information© needs Jones and attempts& Bartlett to develop Learning, a lasting LLC model of NOT FOR SALE OR DISTRIBUTIONthe organization. Therefore,NOT asFOR new SALE data needs OR arise,DISTRIBUTION the logical model might already contain the objects required. If that is not the case, the DBA expands the logical model to include the new objects. A good logical model will be able to accommodate this change and still support the old external views. Only users who need access to the new data should be © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC affected by the change. The is a complete description of NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION the information content of the database. It is written in DDL, compiled by the DBMS, and stored in the system catalog and in source form as doc- umentation. The DBMS uses the logical schema to create the logical record interface, which is a boundary below which everything is invisible © Jones & Bartlett Learning,to the logical LLC level and which defines and© Jones creates & the Bartlett working Learning, environ- LLC NOT FOR SALE ORment DISTRIBUTION for the logical level. No internalNOT or physical FOR SALE details OR such DISTRIBUTION as how

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 45

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.6 The Three-Level Database Architecture 45

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC records areNOT stored FOR or sequenced SALE OR cross DISTRIBUTION this boundary. The logical model is NOT FOR SALE OR DISTRIBUTION actually a collection of logical records. The logical data model is the heart of the database. It supports all the external views and is, in turn, supported by the internal model. However, © Jonesthe internal & Bartlett model Learning, is merely the LLC physical implementation© of Jones the logical & Bartlett Learning, LLC NOTmodel. FOR SALE The logical OR DISTRIBUTIONmodel is itself derived from the conceptualNOT FOR model. SALE OR DISTRIBUTION Developing the conceptual model is the most challenging, interesting, and rewarding part of database design. The database designer must be able to identify, classify, and structure elements in the design. The process of © Jones & Bartlettabstraction Learning,, which LLC means identifying common© Jones properties & Bartlett of a Learning,set of LLC NOT FOR SALE ORobjects DISTRIBUTION rather than focusing on details, is usedNOT to FORcategorize SALE data. OR In com-DISTRIBUTION puter science, abstraction is used to simplify concepts and hide complex- ity. For example, abstract data types are considered apart from their implementation; the behavior of queues and stacks can be described with- out considering© Jones how they& Bartlett are represented. Learning, The designer LLC can look at differ- © Jones & Bartlett Learning, LLC ent levels ofNOT abstraction, FOR SALE so that OR an abstract DISTRIBUTION object on one level becomes a NOT FOR SALE OR DISTRIBUTION component of a higher level abstraction. During the process, there might be many errors and several false starts. Like many other problem-solving processes, conceptual database design is an art, © Jonesguided & by Bartlett knowledge. Learning, There may LLC be many possible solutions,© butJones some &are Bartlett Learning, LLC NOT betterFOR thanSALE others. OR TheDISTRIBUTION process itself is a learning situation.NOT The designerFOR SALE OR DISTRIBUTION gradually comes to understand the workings of the organization and the meanings of its data, and expresses that understanding in the chosen model. If the designer produces a good conceptual model, it is a relatively easy task to convert it to a logical model and complete the internal and physical © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC design. If the conceptual model is a good one, the external views are easy to NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION define as well. If any data that a user might be interested in is included in the conceptual model, it is an easy task to put it into the user’s external view. On the other hand, a poor conceptual model can be hard to implement, partic- ularly if data and relationships are not well defined. It will also be inade- quate to provide© Jones all the & neededBartlett external Learning, models. LLC It will continue to cause © Jones & Bartlett Learning, LLC problems duringNOT FORthe lifetime SALE of OR the DISTRIBUTION database, because it will have to be NOT FOR SALE OR DISTRIBUTION “patched up” whenever different information needs arise. The ability to adjust to change is one of the hallmarks of good conceptual design. There- fore, it is worthwhile to spend all the time and energy necessary to produce © Jonesthe best & Bartlettpossible conceptual Learning, design. LLC The payoff will be felt ©not Jones only at &the Bartlett Learning, LLC NOT logicalFOR andSALE internal OR designDISTRIBUTION stages but in the future. NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 46

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

46 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR2.6.3 SALE Internal OR ModelDISTRIBUTION NOT FOR SALE OR DISTRIBUTION The internal level covers the physical implementation of the database. It includes the data structures and file organizations used to store data on physical storage devices. The DBMS chosen determines, to a large extent, © Jones & Bartlett Learning,what structures LLC are available. It works with© Jones the operating & Bartlett system Learning, access LLC NOT FOR SALE ORmethods DISTRIBUTION to lay out the data on the storageNOT devices,FOR SALE build ORthe indexes,DISTRIBUTION and/or set the pointers that will be used for data retrieval. Therefore, there is actually a physical level below the one the DBMS is responsible for— one that is managed by the operating system under the direction of the © Jones & Bartlett Learning, LLCDBMS. The line between© the Jones DBMS & responsibilities Bartlett Learning, and the operating LLC sys- NOT FOR SALE OR DISTRIBUTIONtem responsibilities is notNOT clear FOR cut andSALE can ORvary DISTRIBUTIONfrom system to system. Some DBMSs take advantage of many of the operating system access method facilities, while others ignore all but the most basic I/O managers and create their own alternative file organizations. The DBA must be © Jonesaware & Bartlett of the possibilities Learning, for LLC mapping the logical model© toJones the internal & Bartlett Learning, LLC NOT FORmodel, SALE and chooseOR DISTRIBUTION a mapping that supports the logical viewNOT and FOR provides SALE OR DISTRIBUTION suitable performance. The internal schema, written in DDL, is a complete description of the internal model. It includes such items as how data is represented, how records are sequenced, what indexes exist, what pointers © Jones & Bartlett Learning,exist, and what LLC hashing scheme, if any, is© used. Jones An internal & Bartlett record Learning,is a sin- LLC NOT FOR SALE ORgle DISTRIBUTION stored record. It is the unit that is passedNOT up FOR to the SALE internal OR level. DISTRIBUTION The stored record interface is the boundary between the physical level, for which the operating system may be responsible, and the internal level, for which the DBMS is responsible. This interface is provided to the DBMS by the operating system. In some cases where the DBMS performs some © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC operating system functions, the DBMS itself may create this interface. The NOT FOR SALE OR DISTRIBUTIONphysical level below this NOTinterface FOR consists SALE of OR items DISTRIBUTION only the operating sys- tem knows, such as exactly how the sequencing is implemented and whether the fields of internal records are actually stored as contiguous bytes on the disk. The operating system creates the physical record inter- © Jonesface &, whichBartlett is a lowerLearning, boundary LLC where storage details, such© asJones exactly & what Bartlett Learning, LLC NOT FORportion SALE of what OR track DISTRIBUTION contains what data, are hidden. NOT FOR SALE OR DISTRIBUTION The data dictionary/directory not only stores the complete external, logi- cal, and internal schemas, but it also stores the mappings between them. © Jones & Bartlett Learning,The external/logical LLC mapping tells the DBMS© Jones which & objects Bartlett on theLearning, logical LLC NOT FOR SALE ORlevel DISTRIBUTION correspond to which objects in a particularNOT FOR user’s SALE external OR view. DISTRIBUTION There

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 47

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.6 The Three-Level Database Architecture 47

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC may be differencesNOT FOR in record SALE names, OR dataDISTRIBUTION item names, data item order, data NOT FOR SALE OR DISTRIBUTION types, and so forth. If changes are made to either an external view or the logical model, the mappings must be changed. Similarly, the logical/inter- nal mapping gives the correspondence between logical objects and inter- © Jonesnal ones, & Bartlett in that it tellsLearning, how the logicalLLC objects are physically© represented. Jones & If Bartlett Learning, LLC NOTthe FOR stored SALE structure OR isDISTRIBUTION changed, the mapping must be changedNOT accordingly. FOR SALE OR DISTRIBUTION To understand the distinctions among the three levels, we will examine what each level receives and passes on when we request the record of a par- ticular employee. Refer to Figure 2.5 along with Figure 2.6. When User A © Jones & Bartlettrequests Learning, a record LLC such as the (external) record© Jonesof Employee & Bartlett 101, the DBMSLearning, LLC NOT FOR SALE ORintercepts DISTRIBUTION the request. Once the DBMS receivesNOT theFOR request, SALE it checksOR DISTRIBUTION the user’s external view and the external/logical mapping. Both the views and the mapping are stored in object form in the system catalog, so the check- ing can be accomplished easily. The DBMS also checks the user’s authoriza- tion to access© Jonesthe items & and Bartlett to perform Learning, the operations LLC requested. If there is © Jones & Bartlett Learning, LLC no such authorization,NOT FOR theSALE request OR is DISTRIBUTION denied. If the user is authorized, the NOT FOR SALE OR DISTRIBUTION DBMS notes what logical level objects are needed, and the request is passed down to the logical level. Next, the logical/internal mapping is checked to see what internal structures correspond to the logical items. Once again, © Jonesthe system & Bartlett catalog Learning, has stored both LLC of the models and the ©mapping. Jones The& Bartlett Learning, LLC NOT DBMSFOR SALEidentifies OR the DISTRIBUTION internal objects that are required, andNOT it passes FOR the SALE OR DISTRIBUTION request to the operating system. On the physical level, an employee record is contained in a physical record, a page or block that can hold several employee records. This is the unit that © Jones & Bartlettis broughtLearning, to the LLC buffer from the disk. The ©operating Jones system & Bartlett is responsible Learning, LLC NOT FOR SALE ORfor performingDISTRIBUTION the basic job of locating the NOTcorrect FOR block SALE for the ORrequested DISTRIBUTION record and managing its retrieval. When the retrieval is complete, the proper block is in the buffer, and the operating system passes to the DBMS the exact location within the buffer at which the stored record appears. The DBMS reads© onlyJones the requested& Bartlett employee Learning, record, LLC not all the records in the © Jones & Bartlett Learning, LLC block. However,NOT itFOR sees theSALE complete OR storedDISTRIBUTION record, exactly as it is coded or NOT FOR SALE OR DISTRIBUTION encrypted, together with any embedded blanks and pointers that may appear in it, but without its header. This is a description of an internal record, which is the unit that passes up through the stored record interface. © JonesThe DBMS & Bartlett uses the Learning, logical/internal LLC mapping to decide what© itemsJones to pass& Bartlett Learning, LLC NOT upFOR through SALE the ORlogical DISTRIBUTION record interface to the logical level. NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 48

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

48 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC FIGURE 2.5 NOT FOR SALE OR DISTRIBUTIONUser A requests record of employee NOT FOR SALE OR DISTRIBUTION Retrieving Record of E101 E101 through User Interface for User A

DBMS receives request © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION DBMS checks user A’s NOTexternal FOR SALE OR DISTRIBUTION schema, external/logical mapping, logical schema in DD

DBMS checks to see if user A is © Jones & Bartlett Learning, LLC authorized.© Jones If not, & rejects Bartlett request Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION DBMS checks logical/internal mapping, determines corresponding internal structures

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC DBMS uses stored record interface to NOT FOR SALE OR DISTRIBUTIONrequest stored record from OS NOT FOR SALE OR DISTRIBUTION

OS identifies desired physical record and asks access method to retrieve it © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC

NOT FOR SALE OR DISTRIBUTION Access method retrievesNOT block ofFOR SALE OR DISTRIBUTION records to buffer, passes address of stored record to DBMS

DBMS checks logical/internal © Jones & Bartlett Learning, LLC mapping,© Jones edits stored & Bartlett record, passes Learning, LLC NOT FOR SALE OR DISTRIBUTION logicalNOT record FOR to logical SALE level OR DISTRIBUTION

DBMS checks external/logical mapping, edits logical record, passes external record to User A © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION At the logical level, the record appears as a logical record, with encryption and special coding removed. Pointers that are used for establishing rela- tionships do not appear on the logical level, since that level is only con- © Jones & Bartlett Learning,cerned with LLCthe existence of relationships,© notJones how &they Bartlett are implemented. Learning, LLC NOT FOR SALE ORSimilarly, DISTRIBUTION pointers used for sequencing NOTare not FOR of interest SALE on OR the DISTRIBUTION logical level, nor are indexes. The logical level record therefore contains only the

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 49

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.6 The Three-Level Database Architecture 49

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC External EmployeeNOT FORRecord: SALE OR DISTRIBUTION NOTFIGURE FOR 2.6 SALE OR DISTRIBUTION Differences in External, employeeName empNumber dept Logical, Stored, and Phys- JACK JONES E101 Marketing ical Record © JonesLogical & Employee Bartlett Record: Learning, LLC © Jones & Bartlett Learning, LLC NOT empIdFOR SALE lastNameOR DISTRIBUTION firstName deptNOT salary FOR SALE OR DISTRIBUTION E101 Jones Jack 12 55000 Stored Employee Record: © Jones & Bartlett Learning, LLC © Jonesforward & Bartlett backward Learning, LLC NOT FOR SALE ORempId DISTRIBUTION lastName firstName deptNOT salary FOR pointer SALE OR pointer DISTRIBUTION E101bbbbbbJonesbbbbbbJackbbbbbbbbb12bbbbbbbb55000bbbb10101bbbbbb10001 Physical Record: Block header© Jones rec of & E90 Bartlett recLearning, of E95 LLCrec of E101 rec of E125 © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

information for that particular employee, but it contains all the fields stored for the employee, in the order in which they are stored. The DBMS © Joneschecks & theBartlett external/logical Learning, mapping LLC to decide what the user’s© Jones external & Bartlett Learning, LLC NOT recordFOR shouldSALE look OR like.DISTRIBUTION NOT FOR SALE OR DISTRIBUTION When the record is passed up through the user interface to the external level, certain fields can be hidden, some can have their names changed, some can be rearranged, some can appear in a form different from their © Jones & Bartlettstored Learning, form, and LLC some can be virtual, created© Jones from & the Bartlett stored record.Learning, LLC NOT FOR SALE ORSome DISTRIBUTION external records might be combinationsNOT ofFOR stored SALE records, OR or DISTRIBUTION the result of operations such as calculations on stored records. The user then performs operations on the external record. That is, he or she can manipulate only those items that appear in the external record. These changes, if© legal, Jones are & eventually Bartlett made Learning, to the storedLLC record. Figure 2.5 © Jones & Bartlett Learning, LLC summarizesNOT the stepsFOR in SALE this process, OR DISTRIBUTION and Figure 2.6 illustrates the differ- NOT FOR SALE OR DISTRIBUTION ences in the appearance of the employee record as it is passed up to the external level. 2.6.4 Data Independence © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT AFOR major SALE reason OR for theDISTRIBUTION three-level architecture is to provideNOT data indepen- FOR SALE OR DISTRIBUTION dence, which means that upper levels are unaffected by changes to lower

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 50

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

50 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC FIGURE 2.7 NOT FOR SALE ORExternal DISTRIBUTION Views NOT FOR SALE OR DISTRIBUTION Logical and Physical Data Independence User Interface Logical Data Independence © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONLogical Model NOT FOR SALE OR DISTRIBUTION

Logical Record Interface Physical Data Independence © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC

NOT FOR SALE OR DISTRIBUTION Internal ModelNOT FOR SALE OR DISTRIBUTION

levels. There are two kinds of data independence: logical and physical. © JonesLogical & Bartlett data independence Learning, refers LLC to the immunity of external© Jones models & Bartlett to Learning, LLC NOT FORchanges SALE in the OR logical DISTRIBUTION model. Logical model changes suchNOT as additionFOR SALE of OR DISTRIBUTION new record types, new data items, and new relationships should be possi- ble without affecting existing external views. Of course, the users for whom the changes are made need to be aware of them, but other users © Jones & Bartlett Learning,should not be.LLC In particular, existing application© Jones &programs Bartlett should Learning, not LLC NOT FOR SALE ORhave DISTRIBUTION to be rewritten when logical level changesNOT FORare made. SALE OR DISTRIBUTION Physical data independence refers to the immunity of the logical model to changes in the internal model. Internal or physical changes such as a different physical sequencing of records, switching from one © Jones & Bartlett Learning, LLCaccess method to another,© Jones changing & Bartlett the hashing Learning, algorithm, LLC using dif- NOT FOR SALE OR DISTRIBUTIONferent data structures,NOT and using FOR new SALE storage OR devicesDISTRIBUTION should have no effect on the logical model. On the external level, the only effect that may be felt is a change in performance. In fact, deterioration in perfor- mance is the most common reason for internal model changes. Figure © Jones2.7 & shows Bartlett where Learning, each type of LLC data independence occurs.© Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.7 Overview of Data Models

A data model is a collection of tools often including a type of diagram © Jones & Bartlett Learning,and specialized LLC vocabulary for describing© Jonesthe structure & Bartlett of the Learning,database. LLC There is much disagreement over what constitutes a data model, and that is NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION reflected in the dozens of proposed models and methodologies found in the literature. A data model provides a description of the database structure

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 51

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.7 Overview of Data Models 51

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC including NOTthe data, FOR the SALE relationships, OR DISTRIBUTION constraints, and sometimes data NOT FOR SALE OR DISTRIBUTION semantics or meanings.

2.7.1 The Entity-Relationship Model © JonesThe Entity-Relationship & Bartlett Learning, model isLLC an example of a semantic model© Jones. Seman- & Bartlett Learning, LLC NOTtic FOR models SALE are usedOR DISTRIBUTION to describe the conceptual and externalNOT levels FOR of data, SALE OR DISTRIBUTION and are independent of the internal and physical aspects. In addition to specifying what is to be represented in the database, they attempt to incor- porate some meanings or semantic aspects of data such as explicit represen- © Jones & Bartletttation Learning, of objects, LLC attributes, and relationships,© Jones categorization & Bartlett of objects, Learning, LLC NOT FOR SALE ORabstractions, DISTRIBUTION and explicit data constraints. SomeNOT of FOR the concepts SALE ofOR the DISTRIBUTION E-R model were introduced in Section 2.2.2, when we described the four levels of abstraction in the discussion of data. The model was introduced by Chen in the mid 1970s and is widely used for conceptual design. It is based on identifying©entities Jonesthat & areBartlett representations Learning, of real LLC objects in the miniworld. © Jones & Bartlett Learning, LLC Entities areNOT described FOR by SALE their attributes OR DISTRIBUTION and are connected by relationships. NOT FOR SALE OR DISTRIBUTION We described entities as persons, places, events, objects, or concepts about which we collect data. A more abstract description is that an entity is any object that exists and is distinguishable from other objects. The attributes © Jonesare qualities & Bartlett or characteristics Learning, that LLC describe the entities and distinguish© Jones them & Bartlett Learning, LLC NOT fromFOR one SALE another. OR We DISTRIBUTION defined an entity set as a collection ofNOT entities FOR of the SALE OR DISTRIBUTION same type. Now we also define a relationship set as a set of relationships of the same type, and we add the fact that relationships themselves might have descriptive attributes. The E-R model also allows us to express constraints, or restrictions, on the entities or relationships. Chapter 3 contains a more © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC complete description of the E-R model, including details about constraints. NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION One of the most useful and attractive features of the E-R model is that it provides a graphical method for depicting the conceptual structure of the database. E-R diagrams contain symbols for entities, attributes, and rela- tionships. Figure© Jones 2.8 shows & Bartlett some of Learning, the symbols, LLC along with their names, © Jones & Bartlett Learning, LLC meanings, andNOT usages. FOR Figure SALE 2.9 OR illustrates DISTRIBUTION a simple E-R diagram for a stu- NOT FOR SALE OR DISTRIBUTION dents and classes database similar to the one we discussed in Section 1.2. It shows an entity set called Student, with the attributes stuId (the primary key, which is a unique identifier for each student entity instance), last- © JonesName, & firstName,Bartlett Learning, major, and credits.LLC Class information,© to Jonesbe kept &for Bartlett Learning, LLC NOT eachFOR class SALE offered OR during DISTRIBUTION the current term, includes the classNumberNOT FOR (pri- SALE OR DISTRIBUTION mary key), the schedule, and the room. The Student and Class entity sets are connected by a relationship set, Enroll, which tells us which students

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 52

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

52 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC SYMBOLNOT FOR NAME SALE OR MEANINGDISTRIBUTION EXAMPLE NOT FOR SALE OR DISTRIBUTION

Rectangle Entity Set Student

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC

NOT FOR SALE OR DISTRIBUTIONOval Attribute NOTstuld FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC Diamond Relationship© Jones & BartlettEnroll Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

stuld Line Links: Attribute to Entity © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Student

© Jones & Bartlett Learning, LLCEntity Set to © Jones & Bartlett Learning, LLC Relationship Student Enroll NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

grade

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC Attribute to NOT FOR SALE OR DISTRIBUTION RelationshipNOT FOR SALE EnrollOR DISTRIBUTION

FIGURE 2.8 Basic Symbols for E-R© Diagrams Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION are enrolled in which classes. It has its own descriptive attribute, grade. Note that grade is not an attribute of Student, since knowing the grade for a student is meaningless unless we know the course as well. Similarly, © Jones & Bartlett Learning,grade is not LLCan attribute of Class, since© knowing Jones that& Bartlett a particular Learning, grade LLC NOT FOR SALE ORwas DISTRIBUTION given for a class is meaningless unlessNOT we FORknow SALEto which OR student DISTRIBUTION the grade was given. Therefore, since grade has meaning only for a particular combination of student and class, it belongs to the relationship set. Since

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 53

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.7 Overview of Data Models 53

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION ClassNOT FOR SALE OR DISTRIBUTION lastName stuld Number

© Jones & BartlettStudent Learning, LLC Enroll © Jones & BartlettClass Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

schedule firstName credits grade room © Jones & Bartlett Learning, LLCmajor © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION FIGURE 2.9 Simplified E-R Diagram

the E-R model© Jones describes & Bartlett only a conceptual Learning, structure LLC for the database, we © Jones & Bartlett Learning, LLC do not attemptNOT to FOR describe SALE how ORthe modelDISTRIBUTION could or should be represented NOT FOR SALE OR DISTRIBUTION internally. Therefore, the material in Section 2.2.2 in which we described data items, records, and files is not part of the E-R model itself.

© Jones2.7.2 & RelationalBartlett Learning, Model LLC © Jones & Bartlett Learning, LLC NOT TheFOR relational SALE ORmodel DISTRIBUTION is an example of a record-based modelNOT, oneFOR that SALE OR DISTRIBUTION essentially pictures what the logical records will look like. Record-based models are used to describe the external, logical, and to some extent the internal levels of the database. They allow the designer to develop and © Jones & Bartlettspecify Learning, the logical LLC structure and provide some© Jonesoptions &for Bartlett implementation Learning, LLC NOT FOR SALE ORof theDISTRIBUTION design. However, they do not provideNOT much FOR semantic SALE information OR DISTRIBUTION such as categorization of objects, relationships, abstraction, or data con- straints. The relational model was proposed by Codd in 1970 and is widely used, because of its simplicity and its power. The relational model began by using the© theoryJones of & relations Bartlett in mathematicsLearning, LLCand adapting it for use in © Jones & Bartlett Learning, LLC .NOT TheFOR same SALE type ORof theoretical DISTRIBUTION development of the subject, NOT FOR SALE OR DISTRIBUTION complete with formal notation, definitions, theorems, and proofs that we usually find in mathematics can be applied to databases using this model. The results of this theoretical development are then applied to practical © Jonesconsiderations & Bartlett of Learning, implementation. LLC In the relational model,© Jones entities &are Bartlett Learning, LLC NOT representedFOR SALE as ORrelations, DISTRIBUTION which are physically representedNOT as tables, FOR and SALE OR DISTRIBUTION attributes as columns of those tables. Some relationships may also be rep- resented as relations or tables. Figure 1.1 (a)–(d) showed a sample relational

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 54

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

54 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORdatabase SALE for ORdata DISTRIBUTIONabout students, faculty, and their classes.NOT We will FOR study SALE the OR DISTRIBUTION relational model, including SQL, the standard language for the model, in later chapters. Two older record-based models are the network and the hierarchi- cal models mentioned in Section 1.6. They are primarily of historic interest, © Jones & Bartlett Learning,since they are LLC no longer widely used for developing© Jones new & Bartlettdatabases. Learning, However, LLC NOT FOR SALE ORmany DISTRIBUTION legacy databases based on these modelsNOT still FOR exist, SALE with code OR that DISTRIBUTION is still being used and that must be maintained.

2.7.3 Object-Oriented Model © Jones & Bartlett Learning, LLCThe object-oriented model© Jones is a semantic & Bartlett model. ItLearning, is based on theLLC notion of NOT FOR SALE OR DISTRIBUTIONan object, which, like anNOT entity, FOR is a representationSALE OR DISTRIBUTION of some person, place, event, or concept in the real world that we wish to represent in the database. While entities have only attributes, objects have both a state and a behavior. The state of an object is determined by the values of its attributes (instance © Jonesvariables). & Bartlett The behaviorLearning, is the LLC set of functions (methods)© definedJones for& Bartlett the Learning, LLC NOT FORobject. SALE A class ORis DISTRIBUTION similar to an entity set and consists ofNOT the set FOR of objects SALE OR DISTRIBUTION having the same structure and behavior. The object-oriented model uses encapsulation, incorporating both data and functions in a unit where they are protected from modification from outside. Classes can be grouped into © Jones & Bartlett Learning,hierarchies, ForLLC example, we could define© a PersonJones class & Bartlett with attributes Learning, such LLC NOT FOR SALE ORas DISTRIBUTION FirstName, LastName, and ID and methodsNOT FOR such SALE as ChangeName. OR DISTRIBUTION We could then create a Student class and a Faculty class as subclasses of Person. The subclasses inherit the attributes and methods of the parent, so in this example, every Student object and every Faculty object has the attributes © Jones & Bartlett Learning, LLCand methods of Person.© They Jones can also & Bartlett have their Learning, own attributes LLC and meth- NOT FOR SALE OR DISTRIBUTIONods. For example, the StudentNOT FOR class canSALE have OR its own DISTRIBUTION additional attribute, Major, and a method changeMajor. Classes can also participate in relation- ships of various types. For example, the Student class can be related to the Course class. Unified Modeling Language (UML) class diagrams are usually used for representing object-oriented data models. Figure 2.10 shows an © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC example of a simple OO data model. Every object in a database must have a NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION unique object identifier that functions as a permanent primary key, but that does not take its value from any of the object’s attributes. An important dif- ference between program objects and database objects is persistence. Unlike a program object that exists only while the program is executing, a database © Jones & Bartlett Learning,object remains LLC in existence after execution© ofJones an application & Bartlett program Learning, com- LLC NOT FOR SALE ORpletes. DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 55

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.7 Overview of Data Models 55

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR PersonSALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION –id : string –lastName : string –firstName : string +changeName() © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

Faculty Student –rank : string –major : string –credits : int +changeRank() © Jones & Bartlett Learning, LLC +changeMajor()© Jones & Bartlett Learning, LLC +addCredits() NOT FOR SALE OR DISTRIBUTION1 –taughtBy NOT FOR SALE OR DISTRIBUTION

0..* –takenBy 0..* –takes

© Jones & Bartlett Learning, LLC © JonesCourse & Bartlett Learning, LLC –classNumber : string NOT FOR SALE OR DISTRIBUTION NOT–schedule FOR : string SALE OR DISTRIBUTION –room : string

© Jones & Bartlett Learning, LLC © Jones & Bartlett–teaches Learning,0..* LLC NOT FigureFOR 2.10 SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION A Class Diagram

2.7.4 Object-Relational Model © Jones & BartlettThe Learning, object-relational LLC model extends the relational© Jones model & Bartlett by adding Learning, com- LLC NOT FOR SALE ORplex DISTRIBUTION data types and methods as well as otherNOT advanced FOR features. SALE OR Instead DISTRIBUTION of atomic, single-valued attributes as required in the relational model, this model allows attributes to be structured and have sets or arrays of values. It also permits methods and type inheritance. The SQL language was extended to© create Jones and & manipulate Bartlett Learning,the more complex LLC data types and facil- © Jones & Bartlett Learning, LLC ities that thisNOT model FOR supports. SALE ThereforeOR DISTRIBUTION the language used to manage an NOT FOR SALE OR DISTRIBUTION object-relational database is closer to the type of language used for rela- tional databases than that used for strictly object-oriented databases. 2.7.5 Semistructured Data Model © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT MostFOR data SALE models OR require DISTRIBUTION that entity sets (or classes or records,NOT depending FOR SALE OR DISTRIBUTION on the model) have the same structure. The structure is defined in the

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 56

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

56 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORschema, SALE and OR remains DISTRIBUTION unchanged unless the DBA changesNOT the schema.FOR SALE By OR DISTRIBUTION contrast, the semi-structured model allows a collection of nodes, each con- taining data, possibly with different schemas. The node itself contains infor- mation about the structure of its contents. Semi-structured databases are © Jones & Bartlett Learning,especially useful LLC when existing databases© having Jones different & Bartlett schemas Learning, must be LLC NOT FOR SALE ORintegrated. DISTRIBUTION The individual databases can beNOT viewed FOR as documents,SALE OR and DISTRIBUTION XML (Extensible Markup Language) tags can be attached to each document to describe its contents. XML is a language similar to HTML (Hypertext Markup Language), but is used as a standard for data exchange rather than data presentation. XML tags are used to identify elements, sub-elements, and © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC attributes that store data. The schema can be specified using a Document NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Type Definition (DTD) or by an XML schema that identifies the elements, their attributes, and their relationships to one another.

© Jones2.8 & Bartlett Chapter Learning, Summary LLC © Jones & Bartlett Learning, LLC NOT FORA corporation’s SALE OR operationalDISTRIBUTION data is a corporate resource,NOT an asset FOR that SALE is OR DISTRIBUTION of value to the organization and incurs cost. A database, which is shared by many users, protects operational data by providing data security, integrity constraints, reliability controls, and professional management © Jones & Bartlett Learning,byaDBA. LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Data means facts, while information is processed data. There are four lev- els of discussion about data: reality (the real world) containing the mini- world (Universe of Discourse) that we are modeling, the abstract conceptual model of the miniworld, the logical model or intention of the © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC database with its metadata (data about data), and the database extension, NOT FOR SALE OR DISTRIBUTIONwith data instances. NOT FOR SALE OR DISTRIBUTION A staged approach to database design is a top-down approach that allows the designer to develop a conceptual model that mirrors the operations of © Jonesthe & organization, Bartlett Learning, allows changes, LLC supports many user views,© Jones is indepen- & Bartlett Learning, LLC NOT FORdent SALEof physical OR implementation, DISTRIBUTION and does not depend onNOT the modelFOR SALEof a OR DISTRIBUTION particular DBMS. This approach allows the database to evolve as needs change. In staged database design the designer must analyze the user envi- ronment, develop a conceptual data model, choose the DBMS, create the © Jones & Bartlett Learning,logical model LLC by mapping the conceptual© modelJones to & the Bartlett data model Learning, of the LLC NOT FOR SALE ORDBMS, DISTRIBUTION develop the internal and physicalNOT models, FOR evaluateSALE ORthe physicalDISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 57

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

2.8 Chapter Summary 57

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC model, performNOT FORtuning SALE if needed, OR DISTRIBUTION and implement the physical model. NOT FOR SALE OR DISTRIBUTION Steps may be repeated until the design is satisfactory. Design methodologies can be general techniques or commercial products such as CASE packages. A data dictionary can be integrated (the DBMS © Jonessystem & catalog) Bartlett or Learning,freestanding LLC(independent of a DBMS).© A Jones data dictio- & Bartlett Learning, LLC NOTnary FOR is aSALE valuable OR tool DISTRIBUTION for collecting and organizing informationNOT about FOR data. SALE OR DISTRIBUTION The DBA must be technically competent, a good manager, and have excel- lent interpersonal and communication skills. He or she has primary responsibility for planning, designing, developing, and managing the © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC operating database. NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Standard database architecture uses three levels of abstraction: external, logi- cal, and internal.Anexternal view is the model seen by a particular user. An external schema is an external model description written in the data defini- tion language© Jones, which is& partBartlett of the Learning,data sublanguage LLC for the DBMS being © Jones & Bartlett Learning, LLC used. The userNOT interface FOR SALEcreates OR the user’sDISTRIBUTION working environment and hides NOT FOR SALE OR DISTRIBUTION lower levels from the user. The logical schema is a complete DDL description of the logical model. It specifies the information content of the database, including all record types and fields. It is derived from the conceptual model. © JonesA good & conceptualBartlett Learning, model results LLC in a logical model that is easy© to Jones implement & Bartlett Learning, LLC NOT andFOR supports SALE the OR desired DISTRIBUTION external views. The logical recordNOT interface FORis SALE a OR DISTRIBUTION boundary below which the logical level cannot see. The internal schema is a DDL description of the internal model. It specifies how data is represented, how records are sequenced, what indexes and pointers exist, and what hashing scheme is used. The stored record interface is the boundary below which the © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC DBMS does not see. The operating system should be responsible for all physi- NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION cal details below this interface, including creating a physical record interface for itself to handle low-level physical details such as track placement. The external/logical mapping tells how the external views correspond to the logi- cal items. The logical/internal mapping tells how logical items correspond to internal ones.© JonesData independence & Bartlettmakes Learning, each level LLC immune to changes on © Jones & Bartlett Learning, LLC lower levels.NOTLogical FOR data SALE independence OR DISTRIBUTIONmeans that the logical level can be NOT FOR SALE OR DISTRIBUTION changed without changing external views. Physical data independence means internal and physical changes will not affect the logical model.

© JonesSome & data Bartlett models Learning, are the entity-relationship LLC , object-oriented© Jones, object- & Bartlett Learning, LLC NOT relationalFOR SALE, and OR semistructured DISTRIBUTIONmodels. There are also NOTrecord-based FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 58

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

58 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FORmodels, SALE including OR DISTRIBUTION the relational as well as the older networkNOT andFOR hierar- SALE OR DISTRIBUTION chical models. The entity-relationship model uses E-R diagrams to show entity sets, attributes of entities, relationship sets, and descriptive attrib- utes of relationships. The relational model uses tables to represent data © Jones & Bartlett Learning,and relationships. LLC The object-oriented model© Jones uses the& Bartlett concept of Learning, a class, LLC NOT FOR SALE ORhaving DISTRIBUTION attributes and methods. An objectNOTis createdFOR SALE as an instanceOR DISTRIBUTION of a class. Object-oriented databases contain persistent objects. Object- relational databases are extensions of relational model databases to allow complex objects and methods. Semistructured databases consist of nodes that are self-describing using XML. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONExercises NOT FOR SALE OR DISTRIBUTION

2.1 Name four resources of a typical business organization. 2.2 Distinguish between data and information. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR2.3 SALEIdentify OR the DISTRIBUTION four levels of abstraction in discussingNOT data. FOR For each,SALE OR DISTRIBUTION give an example of an item that appears on that level. 2.4 Distinguish between an entity set and an entity instance.

© Jones & Bartlett Learning,2.5 Distinguish LLC between a record type© andJones a record & Bartlett occurrence. Learning, LLC NOT FOR SALE OR2.6 DISTRIBUTIONWhat level of data abstraction is representedNOT FOR in SALE the data OR dictionary? DISTRIBUTION Give examples of the types of entries that would be stored there. 2.7 Explain why a staged design approach is appropriate for database design. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC 2.8 Name five desirable characteristics of a conceptual model of an NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION enterprise. 2.9 Name the eight major design stages in staged database design, along with the activities and possible outcomes of each. © Jones2.10 & BartlettExplain Learning,what is meant LLC by saying staged database© design Jones is a & “top- Bartlett Learning, LLC NOT FOR SALEdown” OR method. DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 2.11 Explain how a CASE package can be used in database design. 2.12 Name two advantages and two disadvantages of the following: © Jones & Bartlett Learning,a. integrated LLC data dictionaries © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION b. freestanding data dictionaries

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 59

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

Exercises 59

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC 2.13 ExplainNOT whyFOR users SALE should OR not DISTRIBUTION have access to the data dictionary. NOT FOR SALE OR DISTRIBUTION 2.14 Name eight uses for a data dictionary. 2.15 What types of skills must a database administrator possess? For © Jones & whatBartlett tasks Learning,are they needed? LLC © Jones & Bartlett Learning, LLC NOT2.16 FOR SALEList the OR major DISTRIBUTION functions of the DBA. NOT FOR SALE OR DISTRIBUTION 2.17 Define each of the following terms: a. operational data © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC b. corporate resource NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION c. metadata d. entity e. attribute © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC f.NOT data item FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION g. data aggregate h. data record © Jones & Bartletti. data file Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALEj. data ORsublanguage DISTRIBUTION NOT FOR SALE OR DISTRIBUTION k. l. system tuning © Jones & Bartlett Learning,m. CASE LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTIONn. integrated data dictionary NOT FOR SALE OR DISTRIBUTION o. data dictionary synonym p. data dictionary homonym q.© data Jones standards & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION r. DBA 2.18 Describe the three-level architecture for databases. 2.19 Describe the two parts of data sublanguages. © Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT 2.20FOR SALEGive five OR reasons DISTRIBUTION why it is desirable to separate the NOTphysical FOR repre- SALE OR DISTRIBUTION sentation from the external structure of a database.

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION 06008_CH02_R cardo.qxd 2/1/11 9:11 AM Page 60

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

60 CHAPTER 2 Database Planning and Database Architecture

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR2.21 SALEDistinguish OR DISTRIBUTION between the following: user interface,NOT logical FOR record SALE OR DISTRIBUTION interface, stored record interface, physical record interface. 2.22 Describe each of the following: external schema, logical schema, internal schema. © Jones & Bartlett Learning,2.23 Explain LLC the purpose of the external/logical© Jones & mapping Bartlett and Learning, of the LLC NOT FOR SALE OR DISTRIBUTIONlogical/internal mapping. NOT FOR SALE OR DISTRIBUTION 2.24 Distinguish between logical and physical data independence, and give examples of possible changes they allow. © Jones & Bartlett Learning, LLC2.25 Explain why the ©logical Jones model & isBartlett called the Learning, heart of the database.LLC NOT FOR SALE OR DISTRIBUTION2.26 Describe abstractionNOT and FOR explain SALE how OR it is DISTRIBUTIONused in database design. 2.27 Distinguish between the intension and extension of a database. © Jones2.28 & BartlettExplain Learning,how record-based LLC data models differ from ©semantic Jones models. & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION On the Companion Website:

Lab Exercises

© Jones & Bartlett Learning, Sample LLC Project © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION Student Projects

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION

© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC.© NOTJones FOR SALE & BartlettOR DISTRIBUTION. Learning, LLC NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION