good ppt for rdbms starter

Download Good PPT for RDBMS starter

Post on 27-Jan-2015

103 views

Category:

Education

1 download

Embed Size (px)

DESCRIPTION

here the ppt will shows how to work with sql and with related quiries

TRANSCRIPT

  • 1. raghu@theoracletrainer.comwww.theoracletrainer.com

2. Introduction to Database Management Systems (DBMS) 3. Database Management System (DBMS) Definitions: Data: Known facts that can be recorded and that have implicit meaning Database: Collection of related data Ex. the names, telephone numbers and addresses of all the people you knowDatabase Management System: A computerized record-keeping systemraghu@theoracletrainer.comwww.theoracletrainer.com 4. DBMS (Contd.) Goals of a Database Management System: To provide an efficient as well as convenient environment for accessing data in a database Enforce information security: database security, concurrence control, crash recoveryIt is a general purpose facility for: Defining databaseConstructing databaseManipulating databaseraghu@theoracletrainer.comwww.theoracletrainer.com 5. Benefits of database approach Redundancy can be reduced Inconsistency can be avoided Data can be shared Standards can be enforced Security restrictions can be applied Integrity can be maintained Data independence can be providedraghu@theoracletrainer.comwww.theoracletrainer.com 6. DBMS Functions Data Definition Data Manipulation Data Security and Integrity Data Recovery and Concurrency Data Dictionary Performanceraghu@theoracletrainer.comwww.theoracletrainer.com 7. Database System UsersDATABASEApplication Programs/QueriesSYSTEM DBMS SoftwareSoftware to process queries/programs Software to access stored dataStored Data Defn. (META-DATA).raghu@theoracletrainer.comStored Databasewww.theoracletrainer.com 8. Data Model A set of concepts used to desscribe the structure of a database By structure, we mean the data types, relationships, and constraints that should holds for the data Categories of Data ModelsConceptual raghu@theoracletrainer.comPhysicalRepresentational www.theoracletrainer.com 9. Database Architecture External level (individual user views) Conceptual level (community user view)Internal level (storage view) Databaseraghu@theoracletrainer.comwww.theoracletrainer.com 10. An example of the three levels SNo FName LNameAgeSalaryConceptual View SNo FName LNameAgeExternal View1SNo LName BranchNo External View2 raghu@theoracletrainer.comSalaryBranchNo struct STAFF { Internal int staffNo; View int branchNo; char fName[15]; char lName[15]; struct date dateOfBirth; float salary; struct STAFF *next; /* pointer to next Staff record */ }; index staffNo; index branchNo; /* define indexes for staff */www.theoracletrainer.com 11. Schema Schema: Description of data in terms of a data model Three-level DB Architecture defines following schemas: External Schema (or sub-schema) Conceptual Schema (or schema) Written using external DDL Written using conceptual DDLInternal Schema Written using internal DDL or storage structure definitionraghu@theoracletrainer.comwww.theoracletrainer.com 12. Data Independence Change the schema at one level of a database system without a need to change the schema at the next higher level Logical data independence: Refers to the immunity of the external schemas to changes in the conceptual schema e.g., add new record or fieldPhysical data independence: Refers to the immunity of the conceptual schema to changes in the internal schema e.g., adding new index should not void existing ones www.theoracletrainer.com raghu@theoracletrainer.com 13. TYPES OF DATABASE MODELS HIERARCHICALNETWORKCOLUMNROWVALUETABLERELATIONAL raghu@theoracletrainer.comwww.theoracletrainer.com 14. DATABASE DESIGN PHASES DATA ANALYSIS Entities - Attributes - Relationships - Integrity RulesLOGICAL DESIGN Tables - Columns - Primary Keys - Foreign KeysPHYSICAL DESIGN DDL for Tablespaces, Tables, Indexesraghu@theoracletrainer.comwww.theoracletrainer.com 15. Introduction to Relational Databases: RDBMS 16. Some Important Terms Relation : a tableTuple : a row in a tableAttribute : a Column in a tableDegree : number of attributesCardinality : number of tuplesPrimary Key : a unique identifier for the tableDomain : a pool of values from which specific attributes of specific relations draw their valuesraghu@theoracletrainer.comwww.theoracletrainer.com 17. Keys KeySuper KeyCandidate Keys Primary Key Alternate KeySecondary Keysraghu@theoracletrainer.comwww.theoracletrainer.com 18. Keys and Referential Integrity Enrolled sid 53666 53688 53650 53666cid grade carnatic101 C reggae203 B topology112 A history105 BForeign key referring to sid of STUDENT relation raghu@theoracletrainer.comStudent sidnameloginagegpa53666 JonesJones@cs183.453688 SmithSmith@eecs183.253650 SmithSmith@math193.8Primary keywww.theoracletrainer.com 19. raghu@theoracletrainer.comwww.theoracletrainer.com 20. Conceptual Design Using the Entity- Relationship Model 21. Overview of Database Design Conceptual design : (ER Model is used at this stage.)Schema Refinement : (Normalization)Physical Database Design and Tuningraghu@theoracletrainer.comwww.theoracletrainer.com 22. Design Phases Requirements Collection & Analysis Data RequirementsFunctional Requirements User Defined Operations Data Flow Diagrams Sequence Diagrams, ScenariosConceptual Design Entity Types, Constraints , Relationships No Implementation Details.Logical DesignEnsures Requirements Meets the DesignData Model Mapping Type of Database is identified Physical Design Internal Storage Structures / Access Path / File Organizationsraghu@theoracletrainer.comwww.theoracletrainer.com 23. E-R Modeling Entity Entity Set a group of similar entitiesAttribute is anything that exists and is distinguishableproperties that describe an entityRelationship an association between entitiesraghu@theoracletrainer.comwww.theoracletrainer.com 24. Notations ENTITY TYPE ( REGULAR )WEAK ENTITY TYPE RELATIONSHIP TYPEWEAK RELATIONSHIP TYPEraghu@theoracletrainer.comwww.theoracletrainer.com 25. Entity Attributes ssnnameEmployeelotSSN NAME 123- 22- 3666 Attishoo 231- 31- 5368 Smiley 131- 24- 3650 SmethurstLOT 48 22 35Entity Set CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER, PRIMARY KEY (ssn)) raghu@theoracletrainer.comwww.theoracletrainer.com 26. Types of Relationships 11:1student1:MstudentsMM:MstudentsMraghu@theoracletrainer.comIs issuedenrols intake1ID card1courseMtestswww.theoracletrainer.com 27. ER Model ssnlotnameEmployee supervisorsinceWorks_indiddnamebudgetDepartmentSubordinateReports_Toraghu@theoracletrainer.comwww.theoracletrainer.com 28. ER Model (Contd.) Works_ In SSN 123-22-3666 123-22-3666 231-31-5368DID 51 56 51raghu@theoracletrainer.comSINCE 1/1/91 3/3/93 2/2/92CREATE TABLE Works_ In( ssn CHAR (11), did INTEGER, since DATE, PRIMARY KEY (ssn, did), FOREIGN KEY (ssn) REFERENCES Employees, FOREIGN KEY (did) REFERENCES Departments) www.theoracletrainer.com 29. Key ConstraintsssnnameEmployeeraghu@theoracletrainer.comlotsinceManagesdiddnamebudgetDepartmentwww.theoracletrainer.com 30. Key Constraints for Ternary RelationshipsssnlotnameEmployeesinceWorks_indiddname budget DepartmentLocation address raghu@theoracletrainer.comcapacity www.theoracletrainer.com 31. Participation Constraints ssnnameEmployeelotsinceManagesdiddnamebudgetDepartmentWorks_in since raghu@theoracletrainer.comwww.theoracletrainer.com 32. Weak Entities ssnnameEmployeeraghu@theoracletrainer.comlotcostpolicypnameageDependentwww.theoracletrainer.com 33. ISA (is a) Hierarchies ssnnamelotEmployee Hrly_wages Hrs_workedHourly_Emp raghu@theoracletrainer.comIsAcontractid Contract_Emp www.theoracletrainer.com 34. Aggregation ssnnamelotEmployee monitorspidpbudgetproject raghu@theoracletrainer.comStarted onsponsorsuntildiddname budgetdepartment www.theoracletrainer.com 35. Entity vs. Attribute Works_ In does not allow an employee to work in a department for two or more periods (why?)ssnnamelotEmployeeraghu@theoracletrainer.comfromtoWorks_indiddnamebudgetDepartmentwww.theoracletrainer.com 36. Entity vs. Attribute (Contd.)ssnlotnameEmployeefromraghu@theoracletrainer.comdidWorks_inDurationdnamebudgetDepartmenttowww.theoracletrainer.com 37. Entity vs. RelationshipssnnamelotEmployeesinceDBmanagesdiddnamebudgetDepartmentDB - Dbudgetraghu@theoracletrainer.comwww.theoracletrainer.com 38. Entity vs. Relationship ssnnamelotEmployeedidmanagesdnamebudgetDepartmentsince Appt numMgr_appt DBudgetraghu@theoracletrainer.comwww.theoracletrainer.com 39. Binary vs. Ternary RelationshipsssnlotnameEmployeepnameageDependentcovers Policypolicyid raghu@theoracletrainer.comcost www.theoracletrainer.com 40. Binary vs. Ternary Relationships Better Design ssnnamelotpnameDependentEmployeeBeneficiarypurchaserpolicyid raghu@theoracletrainer.comagePolicycost www.theoracletrainer.com 41. Constraints Beyond the ER Model Some constraints cannot be captured in ER diagrams: Functional dependencies Inclusion dependencies General constraintsraghu@theoracletrainer.comwww.theoracletrainer.com 42. E-R Diagram DEPARTMENT 1 SUPPLIER DEPT_ EMP MM MPROJ_ WORKM PROJECTEMPLOYEE 1MM1PROJ_ MGRMDEPENDENTraghu@theoracletrainer.comSUPP_ PARTMEMP_ DEP MSUPP_ PART_ PROJPART MM MPART_ STRUC TUREwww.theoracletrainer.com 43. Example to Start with . An Example Database Application called COMPANY which serves to illustrate the ER Model concepts and their schema design. The following are collection from the Client.raghu@theoracletrainer.comwww.theoracletrainer.com 44. Analysis Company : Organized into Departments, Each Department has a name, no and manager who manages the department. The Company keeps track of the date that employee managing the department. A Department may have a Several locations.raghu@theoracletrainer.comwww.theoracletrainer.com 45. Analysis Department : A Department controls a number of Projects each of which has a unique name , no and a single Location. Employee : Name, Age, Gender, BirthDate, SSN, Address, Salary. An Employee is assigned to one department, may work on several projects which are not controlled by the department. Track of the number of