good ppt for rdbms starter

Download Good PPT for RDBMS starter

Post on 27-Jan-2015




1 download

Embed Size (px)


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


  • 1.

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 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 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 6. DBMS Functions Data Definition Data Manipulation Data Security and Integrity Data Recovery and Concurrency Data Dictionary 7. Database System UsersDATABASEApplication Programs/QueriesSYSTEM DBMS SoftwareSoftware to process queries/programs Software to access stored dataStored Data Defn. (META-DATA).raghu@theoracletrainer.comStored 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 9. Database Architecture External level (individual user views) Conceptual level (community user view)Internal level (storage view) 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 */ 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 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 13. TYPES OF DATABASE MODELS HIERARCHICALNETWORKCOLUMNROWVALUETABLERELATIONAL 14. DATABASE DESIGN PHASES DATA ANALYSIS Entities - Attributes - Relationships - Integrity RulesLOGICAL DESIGN Tables - Columns - Primary Keys - Foreign KeysPHYSICAL DESIGN DDL for Tablespaces, Tables, 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 17. Keys KeySuper KeyCandidate Keys Primary Key Alternate KeySecondary 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 19. 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 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 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 24. Notations ENTITY TYPE ( REGULAR )WEAK ENTITY TYPE RELATIONSHIP TYPEWEAK RELATIONSHIP 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)) 26. Types of Relationships 11:1student1:MstudentsMM:MstudentsMraghu@theoracletrainer.comIs issuedenrols intake1ID 27. ER Model ssnlotnameEmployee 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) 29. Key 30. Key Constraints for Ternary RelationshipsssnlotnameEmployeesinceWorks_indiddname budget DepartmentLocation address raghu@theoracletrainer.comcapacity 31. Participation Constraints ssnnameEmployeelotsinceManagesdiddnamebudgetDepartmentWorks_in since 32. Weak Entities 33. ISA (is a) Hierarchies ssnnamelotEmployee Hrly_wages Hrs_workedHourly_Emp raghu@theoracletrainer.comIsAcontractid Contract_Emp 34. Aggregation ssnnamelotEmployee monitorspidpbudgetproject raghu@theoracletrainer.comStarted onsponsorsuntildiddname budgetdepartment 35. Entity vs. Attribute Works_ In does not allow an employee to work in a department for two or more periods (why?) 36. Entity vs. Attribute (Contd.) 37. Entity vs. RelationshipssnnamelotEmployeesinceDBmanagesdiddnamebudgetDepartmentDB - 38. Entity vs. Relationship ssnnamelotEmployeedidmanagesdnamebudgetDepartmentsince Appt numMgr_appt 39. Binary vs. Ternary RelationshipsssnlotnameEmployeepnameageDependentcovers Policypolicyid raghu@theoracletrainer.comcost 40. Binary vs. Ternary Relationships Better Design ssnnamelotpnameDependentEmployeeBeneficiarypurchaserpolicyid raghu@theoracletrainer.comagePolicycost 41. Constraints Beyond the ER Model Some constraints cannot be captured in ER diagrams: Functional dependencies Inclusion dependencies General 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 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 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 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