21792 relational database managementsystem

Click here to load reader

Post on 15-Jul-2015

38 views

Category:

Data & Analytics

3 download

Embed Size (px)

TRANSCRIPT

  • Chapter 14Databases

  • After reading this chapter, the reader should be able to:OBJECTIVES

  • DATABASEMANAGEMENTSYSTEM14.1

  • DBMSDatabase a collection of data that is logically coherent.DBMS Database Management Systemdefines, creates, and maintains a database.Allows users controlled access to data in the database.A combination of 5 components:HardwareSoftwareDataUsersProcedures

  • Figure 14-1DBMS componentsHardware the physical computer system that allows physical access to data.Software the actual program that allows users to access, maintain, and update physical data.Data stored physically on the storage devicesUsers End users - Normal user and DBA (Database Administrator)Application programsProcedures a set of rules that should be clearly defined and followed by the users.

  • ARCHITECTURE14.2

  • Figure 14-2Database architecture

  • ArchitectureInternal level Determines where data are actually stored on the storage device.Low-level access methodConceptual level Defines the logical view of the dataThe main functions of DBMS are in this level.External level Interacts directly with the user.Change the data coming from the conceptual level to a format and view that are familiar to the users.

  • DATABASEMODELS14.3

  • Database modelsA database model defines the logical design of data.Describes the relationships between different parts of data.3 modelsHierarchical modelNetwork modelRelational model

  • Figure 14-3Hierarchical modelData are organized as an upside down tree.Each entity has only one parent but can have several children.

  • Figure 14-4Network modelThe entities are organized in a graph.Some entities can be accessed through several paths.

  • Figure 14-5Relational modelData are organized in two-dimensional tables called relations.The tables are related to each other.The most popular model.

  • RELATIONALMODEL14.4

  • Relational modelRDBMS (Relational Database Management System)external viewThe data are represented as a set of relations. A relation is a two-dimensional table.This doesnt mean that data are stored as tables; the physical storage of the data is independent of the way the data are logically organized.

  • Figure 14-6RelationName each relation in a relational database should have a name that is unique among other relations.Attribute each column in a relation. The degree of the relation the total number of attributes for a relation.Tuple each row in a relation.The cardinality of the relation the total number of rows in a relation.

  • OPERATIONSONRELATIONS14.5

  • Operations on relationsIn a relational database, we can define several operations to create new relations out of the existing ones.Basic operations:InsertDeleteUpdateSelectProjectJoinUnionIntersectionDifference

  • Figure 14-7Insert operationAn unary operation.Insert a new tuple into the relation.

  • Figure 14-8Delete operationAn unary operation.Delete a tuple defined by a criterion from the relation.

  • Figure 14-9Update operationAn unary operation.Changes the value of some attributes of a tuple.

  • Figure 14-10Select operationAn unary operation.It is applied to one single relation and creates another relation.The tuples in the resulting relation are a subset of the tuples in the original relation.Use some criteria to select

  • Figure 14-11Project operationAn unary operation.It is applied to one single relation and creates another relation.The attributes in the resulting relation are a subset of the attributes in the original relation.

  • Figure 14-12Join operationA binary operation.Combines two relations based on common attributes.

  • Figure 14-13Union operationA binary operation.Creates a new relation in which each tuple is either in the first relation, in the second, or in both.The two relations must have the same attributes.

  • Figure 14-14Intersection operationA binary operation.Creates a new relation in which each tuple is a member in both relations.The two relations must have the same attributes.

  • Figure 14-15Difference operationA binary operation.Creates a new relation in which each tuple is in the first relation but not the second.The two relations must have the same attributes.

  • STRUCTUREDQUERYLANGUAGE14.6

  • SQL (Structured Query Language)Standardized by ANSI and ISO for use on relational databases.It is a declarative (not procedural) language, which means that the users declare what they want without having to write a step-by-step procedure.First implemented by Oracle in 1979.SQL allows you to combine the following statements to extract more complex information from database.

  • Insertinsert into RELATION-NAME values ( , , )insert into COURSES values ( CIS52,TCP/IP, 6 )

  • Deletedelete from RELATION-NAME where criteriadelete from COURSES where No=CIS19

  • Updateupdate RELATION-NAME set attribute1=value1, attribute2=value2, where criteriaupdate COURSES set Unit=6 where No=CIS51

  • Selectselect * from RELATION-NAME where criteriaselect * from COURSES where Unit=5

  • Projectselect attribute-list from RELATION-NAMEselect No, Unit from COURSES

  • Joinselect attribute-list from RELATION1,RELATION2 where criteriaselect No,Course-Name,Unit,Professor from COURSES,TAUGHT-BY where COURSES.No=TAUGHT-BY.No

  • Unionselect * from RELATION1 union select * from RELATION2select * from CIS15-Roster union select * from CIS52-Roster

  • Intersectionselect * from RELATION1 intersection select * from RELATION2select * from CIS15-Roster intersection select * from CIS52-Roster

  • Differenceselect * from RELATION1 minus select * from RELATION2select * from CIS15-Roster minus select * from CIS52-Roster

  • OTHERDATABASEMODELS14.7

  • Distributed databasesIt is not a new model. It is based on relational model.The data are stored on several computers that communicate through the Internet or some private WAN.Data are either fragmented, with each fragment stored at one site, or data are replicated at each site.Fragmented distributed databasesReplicated distributed databases

  • Object-Oriented databasesSome application like to see data as a structure such as a record made of fields.Tries to keep the adv. of the relational model and allows applications to access structured data.In an OODB, objects and their relations are defined. In addition, each object can have attributes that can be expressed as fields.