3 / 12 Databases MIS105 Lec14 11 Irfan Ahmed Ilyas Lecture Objectives • Integrated File Approach for saving data – Benefits/ Drawback • Database Accessing Approach – File based Programs – DBMS based access • Introducing DBMS – Working of a basic DBMS – Main DBMS Features 11 • Users in a DBMS Environment 02/3/2002 Prepared By: Irfan Ilyas 2 …Database Implementation Approaches • Integrated File Approach 11 – Data is scattered among many different data files – Each file is saving data relevant to its subject only – Files are linked together through data pointers (common field values) – The integrated collection of these data files is normally contained in one single disk file (database file) – Disadvantage: Cross-referencing across the files is needed for detailed reporting – Benefit: Data duplication is minimized which removes the updation anomalies 02/3/2002 Prepared By: Irfan Ilyas 3 Integrated File Database Example • A Student Grade Database • STUDENT – saving only student personal information • GRADE_REPORT – saving only grade information about student courses – The process which decompose data optimally among data files is called Normalization. STUDENT Name Smith Brown GRADE_REPORT StudentID 17 17 8 8 8 8 11 02/3/2002 StudentNumber Class 17 8 Major 1 CS 2 CS CourseCode MATH2410 CS1310 MATH2410 CS1310 CS3320 CS3380 1 1 2 1 1 1 Prepared By: Irfan Ilyas SectionCode Grade B C A A B A 4 …Integrated File Database Example • For detailed information, a cross-referencing activity is needed – While reading GRADE_REPORT, other student details can be found by using the data pointer (StudentNumber) in the STUDENT file • Data updation anomalies are removed – Addition Anomaly: While adding a new student’s grade in GRADE_REPORT file, no need to check for any data consistency . – Deletion Anomaly: Deleting all grades for any student, doesn’t delete the student information from STUDENT file. – Modification Anomaly: A student’s attribute change in STUDENT file (like Name) doesn’t need to be reflected in his grade records in GRADE_REPORT file (key attribute is an exception). 11 02/3/2002 STUDENT Name Smith Brown GRADE_REPORT StudentID 17 17 8 8 8 8 Prepared By: Irfan Ilyas StudentNumber Class 17 8 Major 1 CS 2 CS CourseCode MATH2410 CS1310 MATH2410 CS1310 CS3320 CS3380 1 1 2 1 1 1 SectionCode Grade B C A A B A 5 Accessing a Database 1. Directly Accessing the database files • Programs which directly work upon database files in order to – handle data maintenance, like creating, defining, updating data, in files – carry out the end-user job. • Any high level language like C++, Java etc. can be used to write such programs • Disadvantages – Structural Dependence • These programs are very sensitive to the data file record structures • A small change in the structure of any file’s record needs to change all the programs working over it. 11 – End users are always dependant on programmers for even a simple access to the database. 02/3/2002 Prepared By: Irfan Ilyas 6 1. File Based Application Programs Accounting End User Registration End User Accounting Application Registration Application Disk Storage STUDENT Name Smith Brown Smith Brown Smith Brown StudentNumber Class 17 8 8 2 2 2 1 2 3 4 5 6 Major CS CS CS CS CS CS Other End Users… Any other application…. Disk Storage Disk Storage STUDENT STUDENT Name Smith Brown Smith Brown Smith Brown StudentNumber Class 17 8 8 2 2 2 1 2 3 4 5 6 Major CS CS CS CS CS CS Name Smith Brown Smith Brown Smith Brown StudentNumber Class 17 8 8 2 2 2 1 2 3 4 5 6 Major CS CS CS CS CS CS 11 02/3/2002 Prepared By: Irfan Ilyas 7 …Accessing a Database 2. Using DBMS Software • DBMS Software is a collection of general purpose programs that • • enables users to create and maintain an integrated file database Separates the job of data maintenance from end-user use of stored data Available as a packaged software, called General Purpose Database Management System (DBMS) • DBMS Main Features – Data Structural Independence • Different end-user applications can access database on disk through DBMS • DBMS makes the applications unaffected with any structural change happened in database • DBMS uses control information data (Data Dictionary) to inform the application programs about the structural details of the database files • Data Dictionary is updated automatically by DBMS in case of any structural change done on the database 11 02/3/2002 Prepared By: Irfan Ilyas Chapter 11 (p268) 8 Example: Data Dictionary DBMS User End User End User Application S/W DBMS Software A Database File on disk STUDENT Name Smith Brown GRADE_REPORT StudentID 17 17 8 8 8 8 StudentNumber Class 17 8 Major 1 CS 2 CS CourseCode MATH2410 CS1310 MATH2410 CS1310 CS3320 CS3380 1 1 2 1 1 1 A Database Example SectionCode Grade B C A A B A Dictionary Data 11 Address B14 B15 B16 B17 B18 B19 Table STUDENT STUDENT STUDENT STUDENT ……… Fields Name StudentID Class Major ………. Types Character Character Number Character ……… Size 30 8 2 5 ……… Database’s Data Dictionary 02/3/2002 Prepared By: Irfan Ilyas 9 .. 2. Using DBMS Software • .. DBMS Main Features – Data Query Language • DBMS lets its users/ application programs to access database by making use of some query language • A query language is a set of standardized commands to perform different database maintenance activities • SQL (Structured Query Language) is the most widely used. • Examples of SQL commands are – – – – 11 02/3/2002 CREATE TABLE – to create new data tables (files) SELECT – to display selected data records UPDATE – to modify selected data records Chapter 11 (p295) … and many others. Prepared By: Irfan Ilyas 10 Details of DBMS Components • Database Engine – Controls all the data management activities (like database creation, retrieval, validation, manipulation etc.) • DBMS Interface Objects 11 – Easy to use graphical interfaces (menus, buttons, wizards etc.) to access the underlying database – Each of these objects are interacting with database engine in the background through SQL commands 02/3/2002 Prepared By: Irfan Ilyas 11 A Look to Database Management Systems • Create, modify, gain access to databases • Subsystems Chapter 11, – DBMS engine pg294 – Data definition subsystem • Data dictionary – Data manipulation subsystem • SQL 11 – Application generation subsystem – Data administration subsystem • Database administrators 02/3/2002 Prepared By: Irfan Ilyas 12 A Working DBMS DBMS Package End User Database Application Interface Objects Database User/ Operator S Q LC OM MAN D S Programming Interface Programmers Database Engine Data Definition Subsystem Database Creation Subsystem Database Security Subsystem Disk Storage Integrated File Database 11 02/3/2002 Prepared By: Irfan Ilyas STUDENT Name Smith Brown GRADE_REPORT StudentID StudentNumber Class 17 8 17 17 8 8 8 8 CourseCode MATH2410 CS1310 MATH2410 CS1310 CS3320 CS3380 Major 1 CS 2 CS SectionCode Grade 1B 1C 2A 1A 1B 1A 13 Database Personnel Chapter 11 (p276) • End Users – Requires access to the database for their jobs – Perform querying, updating and reporting on the stored database – Usually provided with a user friendly application program interface • Database Designers – Identifying the logical/ structural database picture for an environment • Database Administrators – Controlling security, structural updates and performance issues for a corporate database 11 • System Analysts and Application Programmers – Responsible for generating easy to use application programs for the end user requirements 02/3/2002 Prepared By: Irfan Ilyas 14 Users in a DBMS Environment End User Database Designer Database Administrator Information System Application Program(s) Data Definition Module Database Creation Module Data Manipulation Module DBMS Modules Database 11 02/3/2002 Prepared By: Irfan Ilyas 15 11 02/3/2002 Prepared By: Irfan Ilyas 16