Preparing for BIT – IT2301 Database Management Systems 2001d

1,047 views

Published on

Preparing for BIT – IT2301 Database Management Systems, on Rupavahini by Gihan Wikramanayake, 07th June 2001, 2200-2230 hrs.

Published in: Education, Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,047
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Preparing for BIT – IT2301 Database Management Systems 2001d

  1. 1. IT2301 Database Management Systems [email_address] PREPARING FOR THE BIT Preparing for BIT 07/06/2001
  2. 2. Introduction to DBMS - OBJECTIVES cont. <ul><li>Explain the difference between conceptual , external and physical schemas and the reasons for a three - schema architecture for databases </li></ul>
  3. 3. 3 Level ANSI/SPARC Architecture <ul><li>Made databases more independent of application </li></ul><ul><li>Became a standard for the organisation of DBMS </li></ul>
  4. 4. 3 Levels <ul><li>External </li></ul><ul><ul><li>User’s and Application’s view of data </li></ul></ul><ul><li>Conceptual </li></ul><ul><ul><li>Logical Data Model </li></ul></ul><ul><li>Physical </li></ul><ul><ul><li>Physical data Model </li></ul></ul>
  5. 5. <ul><li>External (Sub) Schema </li></ul><ul><ul><li>defines the external view of data </li></ul></ul><ul><ul><ul><li>as seen by a user or program </li></ul></ul></ul><ul><li>Conceptual Schema </li></ul><ul><ul><li>defines the logical view of data </li></ul></ul><ul><ul><ul><li>as seen by all users and programs </li></ul></ul></ul><ul><li>Physical (Internal) Schema </li></ul><ul><ul><li>defines the physical view of data </li></ul></ul><ul><ul><ul><li>as seen by a DBMS </li></ul></ul></ul>
  6. 6. user a user i /program j program x sub-schema a sub-schema i sub-schema z conceptual schema physical schema 3 Level Architecture Databases
  7. 7. Name (20 characters) Address (40 characters) NID (10 char) Designation (15 char) Physical View A.B.C. De Silva |222, Galle Road, Colombo | 650370690V|Senior Lecturer <ul><li>The DBMS must know </li></ul><ul><ul><li>exact physical location </li></ul></ul><ul><ul><li>precise physical structure </li></ul></ul>Employee record database
  8. 8. Logical View Address 222, Galle Road, Colombo <ul><li>The user/application must know </li></ul><ul><ul><li>existence </li></ul></ul><ul><ul><li>logical reference </li></ul></ul>Employee Name A.B.C. De Silva Designation Senior Lecturer NID 650370690V database
  9. 9. External View Department Dept. of Computer Science <ul><li>The user/application see </li></ul><ul><ul><li>authorised data </li></ul></ul><ul><ul><li>own format </li></ul></ul>Lecturer Name A.B.C. De Silva Designation Senior Lecturer Age 35 database
  10. 10. <ul><li>External Views Allows to </li></ul><ul><ul><li>hide unauthorised data </li></ul></ul><ul><ul><ul><li>e.g. salary, dob </li></ul></ul></ul><ul><ul><li>provide user view </li></ul></ul><ul><ul><ul><li>e.g. view employee name, designation, department data taken from employee and department files </li></ul></ul></ul><ul><ul><li>derive new attributes </li></ul></ul><ul><ul><ul><li>e.g. age derived from dob or nid </li></ul></ul></ul>External View cont.
  11. 11. <ul><li>External Views Allows to </li></ul><ul><ul><li>change unit of measurement </li></ul></ul><ul><ul><ul><li>e.g. show age in years or months </li></ul></ul></ul><ul><ul><li>define security levels </li></ul></ul><ul><ul><ul><li>e.g. update access to employee file </li></ul></ul></ul><ul><ul><ul><li>read-only to department file </li></ul></ul></ul>External View cont.
  12. 12. user a user i /program j program x sub-schema a sub-schema i sub-schema z conceptual schema physical schema DDL SDDL DML/SQL Practitioners: DBA Users Databases
  13. 13. <ul><li>Data Definition Language (DDL) </li></ul><ul><ul><li>- is the language component of a DBMS that defines each data element as it appears in the database. </li></ul></ul><ul><li>Sub-Schema Data Definition Language (SDDL) </li></ul><ul><ul><li>- is the language component of a DBMS that defines data elements as it should appear to the end users and programmers. </li></ul></ul>
  14. 14. <ul><li>Data Manipulation Language (DML) </li></ul><ul><ul><li>- is a language associated with a DBMS that is employed by end users and programmers to manipulate data in the database. </li></ul></ul><ul><li>Structured Query Language (SQL) </li></ul><ul><ul><li>- pronounced as sequel, is the standard data manipulation for relational DBMSs. </li></ul></ul>
  15. 15. The Relational Model
  16. 16. <ul><li>Understand concepts of database systems in general and relational systems in particular </li></ul>Data Model Objective
  17. 17. The Relational Model <ul><li>Relational database management is the standard implementation for database server technology. </li></ul><ul><li>The relational model of data defines the way data is presented and manipulated by database users. </li></ul>
  18. 18. <ul><li>[Properties] </li></ul><ul><ul><li>Each relation (or table) in a database has a unique name </li></ul></ul><ul><ul><li>An entry at the intersection of each row and column is atomic (or single-valued); </li></ul></ul><ul><ul><li>there can be no multi-valued attributes in a relation </li></ul></ul><ul><ul><li>Each row is unique; </li></ul></ul><ul><ul><li>no two rows in a relation are identical </li></ul></ul><ul><ul><li>Each attribute (or column) within a table has a unique name </li></ul></ul>The Relational Model
  19. 19. <ul><li>Properties Cont. </li></ul><ul><ul><li>The sequence of columns (left to right) is insignificant; </li></ul></ul><ul><ul><li>the columns of a relation can be interchanged without changing the meaning or use of the relation </li></ul></ul><ul><ul><li>The sequence of rows (top to bottom) is insignificant; </li></ul></ul><ul><ul><li>rows of a relation may be interchanged or stored in any sequence </li></ul></ul>The Relational Model
  20. 20. The Relational Model... <ul><li>The relational model of data has three major components: </li></ul><ul><ul><li>Relational database objects </li></ul></ul><ul><ul><ul><li>allows to define data structures </li></ul></ul></ul><ul><ul><li>Relational operators </li></ul></ul><ul><ul><ul><li>allows manipulation of stored data </li></ul></ul></ul><ul><ul><li>Relational integrity constraints </li></ul></ul><ul><ul><ul><li>allows to defines business rules and ensure data integrity </li></ul></ul></ul>
  21. 21. The Relational Objects... <ul><li>Relation </li></ul><ul><ul><li>A named, two dimensional table of data </li></ul></ul><ul><li>Database </li></ul><ul><ul><li>A collection of databases, tables and related objects organised in a structured fashion. </li></ul></ul><ul><ul><li>Several database vendors use schema interchangeably with database </li></ul></ul>
  22. 22. Relational Objects... <ul><li>Tables are comprised of rows and a fixed number of named columns . </li></ul>Data is presented to the user as tables: Column 1 Column 2 Column 3 Column 4 Row Row Row Table
  23. 23. <ul><li>Columns are attributes describing an entity. Each column must have an unique name and a data type. </li></ul>Name Designation Department Row Row Row Employee Structure of a relation (e.g. Employee) Employee(Name, Designation, Department)
  24. 24. Relational Objects... <ul><li>Rows are records that present information about a particular entity occurrence </li></ul>Name Designation Department Row Row Row Employee De Silva Manager Personnel Perera Secretary Personnel Dias Manager Sales
  25. 25. Entity occurrences Mr. De Silva, Manager of Personnel Department Mrs Perera, Secretary of Personnel Department Employees
  26. 26. Keys <ul><li>Primary Key: An attribute (or combination of attributes) that uniquely identifies each row in a relation. </li></ul><ul><ul><li>Employee( Emp_No , Emp_Name, Department) </li></ul></ul><ul><li>Composite Key: A primary key that consists of more than one attribute </li></ul><ul><ul><li>Salary( Emp_No , Eff_Date , Amount) </li></ul></ul>
  27. 27. Primary Key <ul><li>Each table has a primary key . The primary key is a column or combination of columns that uniquely identify each row of the table. </li></ul>Primary Key Employee E-No E-Name D-No 179 Silva 7 857 Perera 4 342 Dias 7 Primary Key Salary E-No Eff-Date Amt 179 1/1/98 8000 857 3/7/94 9000 179 1/6/97 7000 342 28/1/97 7500
  28. 28. Cardinality and Degree <ul><li>The cardinalit y of a table refers to the number of rows in the table. The degree of a table refers to the number of columns. </li></ul>Salary Salary Table Degree = 3 Cardinality = 4 179 1/1/98 8000 857 3/7/94 9000 179 1/6/97 7000 342 28/1/97 7500 E-No Eff-Date Amt
  29. 29. Relationship Employee Name, Designation, Department Department Name, Manager === works for ==>
  30. 30. Relationship <ul><li>Foreign Key: An attribute in a relation of a database that serves as the primary key of another relation in the same database </li></ul><ul><ul><li>Employee( Emp_No , Emp_Name, Department) </li></ul></ul><ul><ul><li>Department( Dept_No , Dept_Name, M_No) </li></ul></ul>
  31. 31. Foreign Key <ul><li>A foreign key is a set of columns in one table that serve as the primary key in another table </li></ul>Foreign Key Primary Key Primary Key D-No D-Name M-No 4 Finance 857 7 Sales 179 Primary Key Department Employee E-No E-Name D-No 179 Silva 7 857 Perera 4 342 Dias 7
  32. 32. Relationship Rows in one or more tables are associated with each other solely through data values in columns (no pointers). Foreign Key Primary Key Primary Key D-No D-Name M-No 4 Finance 857 7 Sales 179 Primary Key Department Employee E-No E-Name D-No 179 Silva 7 857 Perera 4 342 Dias 7
  33. 33. Relational DB Server Architecture Conceptual Layer Physical Layer System Catalogue Base Tables External Layer Stored Tables ... View View View
  34. 34. External Model Name Designation Department De Silva Manager Personnel Dias Programmer Computer Perera Chief Accountant Accounts Silva Clerk Accounts View Table Employee Details View View View
  35. 35. <ul><li>The external model represents how data is presented to users. </li></ul><ul><li>It is made up of view tables . </li></ul><ul><li>View tables are virtual -- they do not exist in physical storage, but appear to a user as if they did </li></ul>External Model Personnel Employee … Department View View View
  36. 36. External Model User Views Personnel Employee … Department Production Product … Supplier Sales Customer … Product View View View View View View View View View
  37. 37. Conceptual Model <ul><li>The conceptual model is a logical representation of the entire contents of the database. </li></ul><ul><li>The conceptual model is made up of base tables . </li></ul><ul><li>Base tables are “real” in that they contain physical records. </li></ul>
  38. 38. Conceptual Model Table Table Table E-No Name Designation DOB D-No 01 Dias Programmer 12-05-1956 COM 02 Perera Chief Accountant 15-12-1958 ACC 03 De Silva Manager 01-01-1960 PER 05 Silva Clerk 25-09-1965 ACC Base Table Employee
  39. 39. Personnel Employee … Department Production Product … Supplier Sales Customer … Product Employee Department Product Customer Table View View View View View View View View View Table Table Table
  40. 40. Physical Model <ul><li>Changes to physical structures (for performance purposes) do not impact the base table definitions -- data independence . </li></ul><ul><li>Access to data is simplified. </li></ul>Importance of the physical model:
  41. 41. Physical Model Index Files Stored Tables
  42. 42. Contact <ul><li>External Degree Unit (EDU) of the Institute of Computer Technology </li></ul><ul><li>No. 221/2A, Dharmapala Mawatha, </li></ul><ul><li>Colombo 7. </li></ul><ul><li>Phone : 074-720511 </li></ul><ul><li>Fax : 074-720512 </li></ul><ul><li>Email : bit@ict.cmb.ac.lk </li></ul><ul><li>http://www.ict.cmb.ac.lk/bit.htm </li></ul>

×