dbms l3

66
DATA INFORMATION DATABASE ORGANIZATION AS AN INFORMATION SYSTEM SOURCES/QUALITIES OF INFO SYSTEM WHAT IS DATABASE HIERARCHY OF DATABASE DATABASE Vs. FILE SYSTEM DATA MODELS DATABASE MANAGEMENT SYSTEM DATABASE DESIGN DATABASE MANAGEMENT SYSTEM

Upload: kashika-kohli

Post on 30-Sep-2015

215 views

Category:

Documents


1 download

DESCRIPTION

ppt on dbms

TRANSCRIPT

DATABASE MANAGEMENT SYSTEMS

DATAINFORMATIONDATABASEORGANIZATION AS AN INFORMATION SYSTEMSOURCES/QUALITIES OF INFO SYSTEMWHAT IS DATABASEHIERARCHY OF DATABASEDATABASE Vs. FILE SYSTEMDATA MODELSDATABASE MANAGEMENT SYSTEMDATABASE DESIGNDATABASE MANAGEMENT SYSTEMDATADATA = GREEK WORD DATUM MEANS Raw facts and figures LIKENumber, event, letter, transactionBy which we cannot make any conclusion OR Meaningless INFORMATIONPROCESSED DATA WHICH IS MEANINGFULLUser can take the decision based on information Data Information Internal OR ExtertnalProcessingOrganization as an information system Corporate DatabasemanagementPlanningControlfinishedrawMaterialSchedulingA/C ReceivableProductionSalesManufacturingAccountingMarketingA/C PayableProductionSources/Qualities of Information Internal & ExternalThe value of informationInformation for Managers-Controlling, Operation, Strategic, Tactical.CompletenessAccurate TimelinessSpeed

What is DATABASE A database is a logically coherent collection of data with some inherent meaning. A random assortment of data cannot correctly be referred to as a database

A database is collection of related information, which is designed, built, and populated with specific purpose

Hierarchy of DATABASEBit 0,1Byte 10001101 (8Bits)Field Collection of BytesRecord Collection of FieldsTable Collection of RecordsDatabase Collection of tables Example of a simple databaseE_noE_nameE_ageE_deptE_addE101Amit25SalesGurgaonE102Sunil32MarketingDelhiE103Radha27AccountsChennaiE104Vibha34SalesDelhiE105Sunita

30MarketingMumbaiFieldRecordsTableHeader RowE_noBasicTADAPFE10150005002501000E10270007003501400E10355005502251100E10480008004001600E10575007503751500TableDATABASEEmp_paymentEmp_personnelExamples of Database OrganizationBankHospitalUniversityGovernment OrganizationManufacturing CompanyWhy DatabaseCompactnessSpeedControlled RedundancyInconsistency can be avoided Database can be sharedSecurityIntegrityDatabase Vs File SystemIn the database approach, a single repository of data is maintained that is defined once then accessed by various users

Self-describing of a DB

Insulation between programs and data

Support of multiple views of the data

5. Sharing of data and multiuser transaction processingRedundancy not controlled

2. Data Accessing problems

Not Secured

Integrity

Doesnt support multiple users

unable to handle New situation like over draftingData Models Collection of Conceptual tools for describing

1. Data 2. Data relationships 3. Constraints 4. Data semantics Types of Data Models Data Model

Record based model Object Oriented Model Physical Model 1. Relation model 1. E-R Model2. Network Model 2. Object oriented 3. Hierarchical Model 3. SemanticRelational Model

A relational database allows the definition of data structures, storage and retrieval operations, integrity constraints. 2. In such a database the data and relations between them are organized in tables. 3. A table is a collection of records and each record in a table contains the same fields.Network Model 1. Data are represented as collection of records.2. Relationships are represented as Links.3. Each record is a collection of fields which can be viewed as pointers.

Hierarchical Model1. A hierarchical database consists of a collection of records which are connected to one another through links.2. A record is a collection of fields, each of which contains only one data value.3. A link is an association between precisely two records.4. The hierarchical model differs from the network model in that the records are organized as collections of trees rather than as arbitrary graphs.5. A parent may have an arrow pointing to a child, but a child must have an arrow pointing to its parent.

Entity / AttributeEntity=A person, Place, Thing or Event Ex: Teacher, Organization, EmployeeAttribute=Information to describe the entity EmployeeEageEnoEnameEdeptEageE-R Model Based on perception of the real world.Collection of basic object called as entityAnd relationships among the entity.Rectangles=entityEllipses=attributesDiamond=relation

Object Oriented Model

Collection of classes and ObjectsClass=collection of same type of objectsObjects=have many attributeEx: Fruit, Furniture, StationaryFruits=yellow, pulpy, sweetSemantic ModelInclude extended relation between tablesRicher facilities for capturing the data objectsMaintains integrity of the objects

Physical ModelUsed to describe data at lowest levelWhere and how to store the dataEx: Unifying Model & Frame memory Model What is a Database Management System?A DBMS is a collection of programs which1. Create database (Creation)2. provide management of databases (Access)3. control access to data (Security)4. contain a query language to retrieve information easily (Access)5. Computerised record keeping system (Data where house)DATABASE MANAGEMENT SYSTEMSSchema Definition

The description of Database is called as schema. Specified during database design and expected to change easily.Ex: Employee

Emp_IDEmp_NameAddCitypincodeInternal schema

Internal schema = describe the storage structure of the DB.Uses physical data model that describe storage and access path of the data.Ex: stored item : length 40 bytes type: number, offset=0, index=1 name: character, offset=6 price: number, offset=20

Conceptual schema

Describe the structure of the DBConcentrates on describing entities, data type, relationships, user operation, constraints. Represented in the form of data model ex. E-R modelExternal Schema or view levelAlso called as view levelDescribe the part of DB that particular user or group if user is interested.Hides the details from other user Ex. Show emp_name, add, city, pincode; hide Salary or Age

Database Architecture ANSI-SPARC Three-Level Architecture

Data independence Capacity to change the schema at one level of DB system without having to change the schema at next higher levelLogical & Physical data independence capacity to change the conceptual schema without having to change the external schema or application program.

capacity to change the physical schema without having to change the conceptual schema. Phases of database designMini worldRequirement & collection analysisData requirement Conceptual designConceptual schemalogical designlogical schemaphysical designinternal schemaFunctional requirement Functional analysisHigh level transaction analysisApplication program designTransaction implementationApplication programDatabase independentDatabase specific31 Database DesignIt is important to design the database in such a way that:

A specific item can be reached easily (maximum guarantee that the desired record will be reached) The database can respond to the users different questions easily (necessary relationships are provided)DATABASE MANAGEMENT SYSTEMSThe database occupies minimum storage space (choosing data types and how to express a certain concept is important)The database contains no unnecessary data (storing the gross salary is enough, the net salary can be calculated from the gross salary) Data can be added and updated easily without causing mistakes (no data redundancy)DATABASE MANAGEMENT SYSTEMSDatabase languages

DDL=data definition language Ex: create, alter, drop, grant, revokeDML=data manipulation language Ex: Select, update, deletion, insertion Insertion, modification, deletion and accessTCL=transection control language Ex: commit, rollback, locktable VDL=view definition language Ex: create viewView=window through user can view the database E-R Modeling1976 proposed by Peter ChenER diagram is widely used in database designRepresent conceptual level of a database systemDescribe things and their relationships in high level

EntityNotations

36Notations

37Entity

Entity An entity is an object that exists and is distinguishable from other objects.

Example: Employee, customer, Student, event, plant

Notation: rectangle

employeeEntity set1. An entity set is a set of entities of the same type that share the same properties.2. An abstraction of similar things, 3. An entity set contains many entitiese.g. Employee, Customer, students

customer_id customer_nameCustomer_addCustomer_cityCustomer_pincode Student_id student_namestudent_addstudent_citystudent_pincode Employee_id employee_nameemployee_addemployee_cityemployee_pincode 40Weak Entity Set Notations

1. Double rectangles for weak entity set2. Double diamond for weak entity relationship3. Cannot indentify without owner4. So week entity always has total participation means full dependency Ex: father-> children all have different name Notation DOB Dependent 40AttributesAttributes: common properties of the entities in a entity sets which describe the entity

Single value attribute: exactly one value for particular attribute Ex: age, telephone no.

Multi valued attribute: having sets of valuesEx: one teacher teaches =multiple subject one car having = multiple color

Stored or Derived attribute :Stored attribute: whose value can be used to derive the value of some other attributeEx: DOB, DOJDerived attribute: whose value can be derived from stored attributeEx: Age, Experience Simple Vs. composite attribute Simple attribute: attribute that is not divisible Ex: Sex, Composite attribute: attribute that is divisible Ex: Address street add, city state pin code Key attribute key attribute: has unique value for each and every entityValue used to identify the entity Ex: Emp_No, St_No, Item_no, customer_noCandidate key: if one table Has more then one key attributes Ex:Vehicle_ID and registration_noE-R Diagram With Composite, Multivalued, Derived Attributes

Relationships

Relationship specify the relations among entities from two or more entity setsCardinality RatioThe degree of a relationship = the number of entity sets that participate in the relationshipOne to one relationship(1:1)One to many relationships (1:M)Many to one relationship (M:1)Many to many relationship (M:M)

47One to One relationshipBinary relation type We express cardinality constraints by drawing either a directed line Ex; one department can be manage by one one manager Each dept = one managerDept Manager One to Many One dept = many employees Dept1 emp3 emp2 emp1 emp4

In the one-to-many relationship a loan is associated with at most one customer via borrower,Many to One One Teacher = many students teacher student1 student2 student3 student3

In the many to One relationship a customer is associated with loan via borrower,Many to Many Many students = Many projects student1 student4 student3 student2 project1 project2 project3 project4 A customer is associated with several (possibly 0) loans via borrowerA loan is associated with several (possibly 0) customers via borrower

51Relationship typebinary & Turnery Relation type Relationship type Ex; teacher-student relation=taught Emp-Dept relation=works for Doctor-patient relation=treatementRelationship setsEx; teacher, employee, students, dept, doctor patientRelationship B/W 2 entities called as binary type relationship

Binary relationship Examplee1 .e2 .e3 .e4 .e5 .e6 .

r1 .r2 .r3 .r4 .r5 .r6 .

d1 .d2 .d3 .d4 .d5 .d6 .

Emp-Dept Relationship type=works for

E1,E3,E6 works for d1 Relationship degree: No. of E2, E4 works for d2 participating entityE5 works for d3 2 entities emp & dept relationship degree=2 Turnery relationship If entities are more then 2 it is called as turnery relationship.Supplier s1, part p1, project j1 (3 entities)Supply is the relationship types1 s2 .

r1 .r2 .r3 .r4 .r5 .r6 . r7 .

j1 .j2 .j3 .j4 .j5 .j6 .

p1 P2p3

Recursive/Constraints Relationship typeRecursive = An entity participates more then one relationships Teacher mother, sister, wife

Constraints = organization has rule that each emp works only for one project2 types of relationship constraints Cardinality RatioParticipation a) Total participation b) Partial participation Participation ConstraintsSpecifies whether the existence of an entity depend on its being related to another entity via the relationship type. 2 types1. Total participation2. Partial participation

Total Participation

When we require all entities to participate in the relationship (total participation), we use double lines to specify OREvery emp has to works_for dept, the total set Every loan has to have at least one customer57Partial participation We do not expect every employee to manage the department so participation of employee in manages relationship type is partialMeans that some or part of but not necessarily all. Specialization/Generalization Specialization the process of defining the subclass from the entity type.

Each subclass can be created on the basis of special characteristics of the super class entity engineere1 .e2 .e3 .e4 .e5 .e6 .

e1 e2e3

e1 e2e3

e1 e2e3

secretarytechnicianExtended E-R Features: SpecializationTop-down design process; we designate sub groupings within an entity set that are distinctive from other entities in the set.These sub groupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set.Depicted by a triangle component labeled ISA (E.g. customer is a person).Attribute inheritance a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked.

Specialization Example

Generalization

Generalization reverse process many entity having similar type of features.Identify the feature and generalize them in one into single super class Ex; Employee, Car, Truck, person, employee

ER DIAGRAM Entity Types are:EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT

University ER DiagramStudentClassStudentIDSSNSexZipDegreeCityBirth dateStateNameAddressDepartmentDNameDCodeOfficeNumberOfficePhoneCollegeCourseCNameCourseDescCNumberCreditsSectionInstructorYearSemesterSectionNumber GPANumeric GradeLetter GradeGrade_ReportBelong_ToOfferMinor InMajor InER DIAGRAM FOR A BANK DATABASE

An ER diagram for an AIRLINE database schema.