Presentation is loading. Please wait.

Presentation is loading. Please wait.

Database Introduction. Objectives To understand the nature and characteristics of databases To survey some important and interesting database applications.

Similar presentations


Presentation on theme: "Database Introduction. Objectives To understand the nature and characteristics of databases To survey some important and interesting database applications."— Presentation transcript:

1 Database Introduction

2 Objectives To understand the nature and characteristics of databases To survey some important and interesting database applications To gain a general understanding of tables and relationships To define the term database management system (DBMS) and describe the functions of a DBMS To define the term database and describe what is contained within the database To define the term metadata and provide examples of metadata To define and understand database design from existing data

3 TRADITIONAL FILE PROCESSING SYSTEMS CASE STUDY: Sleepy Valley High School

4 Information Split Among Different Departments We will look at the offices at Sleepy Valley H.S. who keep files on the teachers at Sleepy Valley  Principal's Office  Assistant Principal's Office  Personnel Department  Payroll department

5 Where is data stored?  The Principal, Mr. Halprin, uses a regular notebook.  The Assistant Principal, Ms. Lewis, uses index cards.  The Personnel Office Director, Ms. Lauren, uses a Windows word processing program.  The Payroll Office Director, Mr. Smith, uses a Lotus 1-2-3 Spreadsheet.

6 Principal  Mr. Halprin is the Principal  He keeps two very important files on teachers: A Teacher File with current data on all teachers. A Job History File for every teacher who has taught at the school.

7 Teachers Mr. Halprin's Teacher File Teacher ID#Teacher NameAddressDegree Dept. Code 001Sill, Bill1 Apple Rd.M.A.3 012 Lan, Jackie 18 Lord Rd.M.A.2 014James, Hal 15 Pine Terrace M.S.5 027Lan, Hennie20 Lord Rd.M.A. 1 035Gold, Amy 21 Deer Lane M.S.3 041Doe, Jon 4 High Street M.S.2

8 Pay Scale Mr. Halprin's Job History File ID# SCALEDATE ATTAINED 00129/15/1995 00139/15/1996 00149/15/2001 012412/15/2008 01411/15/1999 01429/15/2002 02719/15/1994 03531/15/1987 04229/15/1995 04419/1/1996

9 Why maintain data?  One reason is REPORTS.  The world demands REPORTS.  For Mr. Halprin, the Teachers Union demands an annual salary report, giving for each teacher their salary scale history.

10 Teacher Salary Scale Information Teacher's Job History Report Teach. IDNameAddressDegreeeCurrent Scale ScaleDate 001Sill, Bill1 Apple Road M.A.4234234 9/15/95 9/15/96 9/15/01 012Lan, Jackie18 Lord Rd. M.A.4412/15/08 014James, Hal15 Pine Terrace M.S.21212 1/15/99 9/15/02

11 Assistant Principal n Ms. Lewis is the Asst. Principal n One of her assignments is to maintain a "Speakers List" n She maintains 2 files – Teacher-Speaker File – Seminar Topic File

12 Speaker File Ms. Lewis' Teacher File Teacher ID Teacher Name Teacher Address Highest Degree Home Phone 001Sill, Bill1 Apple Rd.M.A.648-2174 012Lan, Jackie18 Lord Rd.Ph.D.334-9392 014James, Hal15 Pine TerraceM.S.647-1267 027Lan, Hennie20 Lord Rd.M.A.325-1111 035Silver, Amy65 Bliss Ave.M.S.246-1342 042Doe, John4 High StreetM.S.371-1994

13 Do You See Any Problems With these different files? Look closely at Teacher ID 35 in both Mr. Halprin’s Teacher File, and Ms. Lewis’s Teacher File? –Can you explain the differences? –Why did they occur? –Is this a desirable feature for this file processing system? Also look at the “Doe’s” in both Teacher Files.

14 Seminar Information Ms. Lewis' Seminar Topic File Teacher IDSeminar TitleAudience LevelDate Last Given 001Crisis in BosniaH-So1/8/2003 012 Shakespeare's Poetry H-Jr5/2/2009 014Finding PrimesH-Fr10/4/2001 014 Non-Euclidean Geometry C-So4/15/2002 014Digital PhotographyH-Sr.11/1/2002 027 Modern Portugese Poetry H-Fr4/4/2002 035 Hypergeometric Invariant transformations C-Sr5/3/2003

15 Personnel Office  Ms. Lauren directs the Personnel Office  Among several files, she maintains the following 2 files Personnel Teachers File Insurance Plan File

16 Teacher / Medical Plan Personnel's Teacher File Teacher IDTeacher nameMedical Plan # Dependent Coverage ? 001Sill, Bill3N 012Lan, Jackie3Y 014James, Hal1Y 027Lan, Hennie2N 035Silver, Amy2Y 042Doe, John4Y

17 Medical Plan Information Insurance File Medical Plan #Plan Name 1Best Medical 2Good Health 3USMEDCO 4National Medical 5Republic Care

18 Payroll Office n Mr. Smith is the Director of the Payroll Office n Mr. Smith maintains two files of interest to us – a Teacher Master File – a Department File

19 Salary Payroll Dept's Teacher File Teach. ID NameAddressZip CodeSalaryYear to date Dept. # 001Sill, Bill1 Apple Rd. 07102$54,613$27,5023 012Lan, Jackie 18 Lord Rd. 07122$46,215$28,1022 014James, Hal 17 Main Street 07145$48,112$24,0165 027Lan, Hennie 20 Lord Rd. 07104$44,000$22,0324 035Gold, Amy 21 Dear Lane 07103$42,465$26,2175 042Doe, John 4 High Street 07102$40,810$25,4195

20 Dept #Dept. NameDept. Loc.Phone Ext. 1Science2073111 2English3153164 3Social Studies1173152 4 Foreign Languages 2153123 5Mathematics4613154 Payroll's Department File

21 File Processing Problems  Redundancy (duplication of data) wasteful of space (storage) update inefficiencies  (when a teacher moves to a new address, or changes her name, the teacher's "record" must be changed each place it is stored) data inconsistency (different addresses for the same teacher in different files)

22 Legacy Programs  Programs to work on these files at Sleepy Valley H.S.  The Payroll Department has written some lengthy Pascal programs to access their files and perform queries and reports.  The Personnel Department has written some C programs to access their files and perform queries and reports.

23 Sleepy Valley H.S. - continued  The Board of Education asks the Principal to provide a report giving: For EACH department,  list separately the scale 1,2,3 and 4 teachers  the date of promotion to current rank for each teacher  the seminar topics for each teacher.

24 How To Create the Board of Education requested report  We must access files from 3 different offices, since no single office has all the files needed to create this report From the Payroll Office files, we can obtain, for each Department, the teachers' names and id's and departments From the Principal's Office Files, we can obtain, for each teacher, the current salary scale and date this salary scale became effective From the Asst. Principal's Office files, we can obtain the seminar topics for each teacher.

25 A Potential Solution…  Build a SINGLE pool of interrelated files, rather than SEPARATE collection of files. (This is an INFORMAL description of a database).

26 The Teacher File in a Database ID# NAMADDSALARYYTDDEPT #DEGSCLINSDEP 001Sill, Bill1 Apple54613275003M.A.43N 012Lan, Jacki 18 Lord Rd. 46215 242562PhD43Y 014etc.--------- --

27 How would other files appear?  The other files would have the identical structure (scheme) as they had in their original departments. The Department File from Payroll The Insurance File from Personnel The Seminar Topic File from the Asst. Principal The Job History file from the Principal's Office etc.

28 The DEPARTMENT "schema" Dept #Dept. NameDept. Loc.Dept. Phone 1Science2073111 2 3 or (Dept#, Deptname, DeptLoc, Phone)

29 Important Notes:  We eliminate redundancy in the database by listing each teacher only once.  The report requested by the Board of Education is much easier to produce, as all of the needed data is present in the single database.  The teacher "table" has "relationships" with other "tables."

30 Why Use A Database? (Summary) The purpose of a database is to help people and organizations keep track of things Problems of using list to store data –Data inconsistencies –Data privacy: The departments want to share some, but not all, of their data Databases store data in single-theme tables Tables are related through primary and foreign keys

31 Database Theory: Entities, Attributes and Relationships  An ENTITY is an object that exists and is distinguishable from other objects. "a person, place or thing"  Examples of entities include individual teachers, departments, seminar topics, etc.  An ENTITY SET is the set of all entities of the same type. ALL of the teachers at Sleepy Valley HS constitute an ENTITY SET. Each individual teacher is an ENTITY ..

32 Database Theory: Attributes  An ATTRIBUTE is a defining property or quality of an entity (we will see that relationships will be permitted to have attributes also) Attributes of Teachers might include their id#, address, degree, department #, etc. Attributes of Departments might include their name, room#, telephone, chairman, etc.  The DOMAIN OF AN ATTRIBUTE will be the set of allowable values for an attribute.

33 Database Theory: Relationships  A RELATIONSHIP is an association between entities in different entity sets. – There is a RELATIONSHIP between entities (teachers) in the TEACHER entity set and entities (departments) in the DEPARTMENT entity set, namely each teacher (e.g., Jackie Lan), is associated with a given department (English)  A MAPPING CARDINALITY is the number of entities to which another entity can be associated with in a relationship.

34 Lakeview Equipment List

35 Lakeview List Issues Four “themes” in the list (Jobs, Contactors, Equipment, & Rentals) Suppose KH Services changes its phone# ? Suppose we delete RB Partnership’s row? Can a new contractor be added if there is no rental? What about the missing data for the scaffolding rental? Are the different daily rental rates for the backhoe rental valid?

36 Four themes – four tables? JOB (Name,…) CONTRACTOR (Contractor, Phone,…) EQUIPMENT(EquipmentType, EquipmentNumber, Dailyrate,…) RENTAL (StartDate, EndDate, Days,…)

37 Unique Identifiers, Relationships JOB (JobID, Name) CONTRACTOR (ContractorID, Contractor, Phone, Street, City, State, Zip) EQUIPMENT (EquipmentID, EquipmentType, EquipmentNumber, DailyRate) RENTAL (ID, JobID, ContractorID, EquipmentID, StartDate, EndDate, Days)

38 Populated Lakeview Database Tables in Microsoft Access, With Relationships

39 Sample SQL Query

40 Database Definition A Database is a structure that can house information about multiple types of entities, as well as relationships among the entities.

41 Database System Components

42 DBMS DBMS: Database Management System –Create database, tables, and supporting structures –Read and update database data –Maintain database structures –Enforce rules –Control concurrency –Provide security –Perform backup and recovery Examples: Oracle, DB2, Microsoft Access, SQL Server

43 Database Database is a self-describing collection of related records or tables –User Data –Metadata: data about the structure of a database –Indexes and related structures –Stored procedures: program modules stored within the database –Triggers: a procedure that is executed when a particular data activity occurs –Application metadata: data describing application elements such as forms and reports

44 Kroenke-Auer Definition of a Database (Important!) "A database is a self-describing collection of integrated records."

45 An Analogy  Is a Library a collection of books and periodicals? A Library also contains a card-catalog, which describes the books in the Library. So, a Library might be considered a self- describing collection of books and periodicals.

46 Self Describing  In addition to source data, a database contains a description of its own structure. – This description is referred to as either:  a data dictionary  a data directory  metadata

47 Different Types of Databases Type Example Typical Number of Concurrent Users Typical Size of Database Personal Mary Richards House Painting 1< 10 megabytes Work GroupTreble Clef Music<25<100 megabytes Organizational Licensing & Registration Hundreds to Thousands 1 Trillion Bytes

48 Mary Richards House Painting CUSTOMER( CUST-ID, CustomerName, Street, City, State, Zip, PhoneNumber, SOURCE-ID) JOB( JOB-ID, JobDate, Description, AmtBilled, AmtPaid, CUST-ID) SOURCE( SOURCE-ID, Name, PhoneNumber)

49 Sea View Yacht Sales - Work Group BOAT-TYPE(BOAT-TYPE-ID, Description, NewPurchasePrice, NumberPurchased) SAILBOAT(SAILBOAT-ID, BoatName, DateListed, Year, AskingPrice, CurrentLocation, Description, BOAT-TYPE-ID) EQUIPMENT( EQUIPMENT-ID, ItemName, Item-Desc, SAILBOAT-ID) SALESPERSON(SALESPERSON-ID, Name, AreaCode, LocalNumber) CUSTOMER(CUSTOMER-ID, Custname, AreaCode, LocalNum, Street, City, State, Zip, Notes, SALESPERSON-ID) CUSTOMER-BOAT-INT(CUSTOMER-ID, BOAT-TYPE-ID) CUSTOMER-SAILBOAT-INT( CUSTOMER-ID, SAILBOAT-ID)

50 Database Management System  A Database Management System (DBMS) is a software product through which users interact with a database. By "interact with a database" we mean the user can create, edit, query, produce reports, and perform other functions with a database.

51 Desktop Database History Ashton Tate (1979) introduces dBase II In 1980's, dBase, Paradox and Foxpro are the "major players" Microsoft buys out Foxpro Borland (Paradox) buys out Ashton-Tate Windows versions of DBMS products appear Microsoft brings out Access 1.0 at price of $99 Currently MS Access is most widely used microcomputer database product.

52 Relational Database Model  Developed by E. F. Codd in 1970  Based upon concepts in a branch of mathematics called Relational Algebra  A (simple) methodology for structuring and processing a database  Data is stored (conceptually) as tables. Relationships between tables are "visible" in the data

53 Sample Student & Course Tables StudentNamePhone 100 Jones, Mary323-0098 200 Parks, Franklin232-9987 300 Thomas, Martha887-4484 Course#CourseNameSemesterGradeStudentId BD100Intro MISFA100 BA402Accting Seminar SC200 BF315Mgmt Principles SB200 BD100Intro MISFC300 BD200DatabaseSB300 BA150Intro to AcctingFB100 MA102Intro CalculusFB100 CS100Intro Comp Sci F A300

54 Example of a Data Model

55 Departments Write to Single DB Personnel Programs Principal's Programs Database Without a DBMS, we would still have individual departments writing their own programs to directly interact with the database Payroll Programs

56 Interacting with the database through the DBMS Personnel Principal Database Management System Database Payroll

57 Database Views  A VIEW is some subset of the database which a DBMS permits a particular user, or set of users, to see. {It is actually the Database Administrator who decides upon the views.}  Another name for a view is a subschema (a subset of a schema).

58 Teacher Database ID#NAMADDSALARYYTDDEPT #DEGSCLINSDEP 001Sill, Bill1 Apple44613175003M.A.43N 012Lan, Jacki 18 Lord Rd. 36215 142562PhD43Y 014etc.--------- --

59 Student Database A View of the Teacher Database with NO Salary Information ID#NAMADDDEPT #DEGSCLINSDEP 001Sill, Bill1 Apple3M.A.43N 012Lan, Jacki 18 Lord Rd. 2PhD43Y 014etc.------- --

60 DB View Benefits  provides the user with a "simpler" structure containing only relevant information  protects sensitive data from users who should not be allowed to see such data  note that a dbms will permit other security features, such as password protection, so a user may be able to view salary data, but not edit any changes in salary data

61 A Second DBMS Feature  Most DBMS allow you to specify INTEGRITY CONSTRAINTS on attribute values (i.e., you can specify the domain of an attribute) Example: you can specify that SALARY for a teacher be numeric, non-negative and below $123,456.  Specifying integrity constraints provides some protection against data-entry errors.  Database Designers have a primary concern to maintain the integrity of the database.

62 Relational Databases The purpose of a database is to help people and organizations track things of interest to them A relational database stores data in tables, which have rows and columns (like a spreadsheet). A database typically has many different tables, where each table stores data about a different thing Each row in a table stores data about an occurrence or instance of the thing of interest (an entity) – rows are also known as records. A column of a table stores an attribute common to all of the rows in a table. –For example, in a STUDENT table, we might have columns/attributes for firstname, lastname, major, GPA, emailaddress, etc. A database stores data and other things.

63 A Student Table and a Class Table

64 A Database Has Data and Relationships A database contains both data (stored in tables) and relationships between the data in the tables. There could be several types of relationships between data.

65 Tables have Relationships Notice That The Tables Below Do Not Have Explicit Relationships, And Thus The Grades in the Grade Table Are Meaningless

66 Naming Conventions Table Names are written with all capital letters: –STUDENT, CLASS, GRADE Column names are written with an initial capital letter, and compound names are written with a capital letter on each word: –Term, Section, ClassNumber, StudentName

67 Adding Relationships We link data in one table with data in another table and form relationships. The links are accomplished by having an attribute in one table point to an attribute in another table. Each row in a table has an attribute (or set of attributes) which serves as the unique identifier, known as the primary key. –So, in the STUDENT table, the attribute StudentNumber serves as the primary key, while the attribute ClassNumber serves as the primary key of the CLASS table. –Could ClassName serve as the primary key of the CLASS table? (Answer is “No” – do you see why?) –Could LastName serve as the primary key of the STUDENT table? Will LastName ALWAYS uniquely identify a record???? –Could EmailAddress serve as a primary key? (What if a student did not have an email address?)

68 Foreign Keys A foreign key is an attribute in one table which point to an attribute in another table. Foreign keys enable us to form relationships between tables.

69 Database (With Relationships) For Students & Grades

70 Databases Create Information From Data Data = Recorded facts and figures Information = Knowledge derived from data, i.e., data presented in a meaningful context, where we may have applied some form of processing to the data, such as computing averages, sorting, grouping, etc. Databases record data, but they do so in such a way that we can produce information from the data –The data on STUDENTs, CLASSes and GRADEs could produce information about each student’s GPA

71 Database Examples

72 Types of Databases Single User Database Applications –Supports only one user at a time Multi-User Database Applications –Supports multiple users concurrently E-Commerce Database Applications Similar database design concepts are apropos to the above types.

73 Components of a Database Systems A database system generally contains 4 components: –Users (from end-users to database administrators –The database application –The Database Management System (such as Microsoft Access, Oracle, etc.) –The data (the collection of facts stored in the database) Aside : databases systems will also have metadata (data about data) and procedures/rules which govern the overall design and usage of the database

74 What is a DBMS (Database Management System)? A DBMS (Database Management System) is a collection of programs that manages the database structure and controls access to the data stored in the database The DBMS is the intermediary between the user and the database – it receives requests from users, and translates them into the operations required to fulfill those requests –The DBMS makes it possible to share data among multiple applications or users –The DBMS hides much of the database’s internal complexity from end-users –The DBMS makes data management more efficient and effective

75 The Components

76 Components of a DBMS Using SQL SQL (Structured Query Language) is an internationally recognized language used by commercial DBMS products – database applications typically send SQL statements to the DBMS for processing.

77 Summary: Database Applications, DBMS, and SQL Applications are the computer programs that users work with The Database Management System (DBMS) creates, processes and administers databases Structured Query Language (SQL) is an internationally recognized standard database language that is used by all commercial DBMSs

78 Some Prominent DBMS Products Microsoft Access Microsoft SQL Server IBM DB2 Oracle Corporation’s ORACLE MySQL

79 DBMS Power vs. Ease of Use

80 Database Applications and SQL Some typical functions of database application programs –Create and process forms for entering data The form presents the data entry details in an easy-to-use format Behind the form, the Application generates the requisite SQL statements to insert and update the data for any of the tables underlying the form –Process user queries (a query is a question the user asks of a database) The Application processes the query and sends it to the DBMS –Create and process reports for the end-user The Application queries (using SQL) the DBMS for data needed in the report, and formats the query results according to the end-user specifications.

81 An Example Data Entry Form for Our Student-Class Database

82 Producing Reports A Class Grade Report might be generated as follows:

83 Processing an SQL Query  We present an SQL query to list the first name, last name and email address of all students having a student number >2.  (We will cover SQL later, this is only a small preview) SELECT Lastname, Firstname, EmailAddress FROMSTUDENT WHEREStudentNumber > 2; The result might look like:

84 The Database Summary DEFINITION: A database is a self-describing collection of integrated tables The tables are called integrated because they store both end-user data and the relationships among the data. A database is called self-describing because it stores a description of itself The self-describing data are called metadata, which means “data about data” –(The form and format of metadata varies between different DBMS products.)

85 Why a “self-describing” collection? –To understand this definition, if you were asked to define a Library, would it be reasonable to say a Library is a collection of books and periodicals? If yes, if we were to pile up 5,000 books and periodicals in a stack in a room, would that be a Library? (No !) –What makes a Library a true Library is the organizational structure of the books and periodicals, and the fact that a true Library will have a card catalog which will enable us to locate a book (or periodical). –So, in fact, a Library should be defined as a self- describing collection of books and periodicals.

86 Typical Metadata Tables in User / Class Example

87 Query Metadata, Just As Query “Regular” Tables of Data Example: The following SQL queries the metadata table SYSOBJECTS to determine if a user table (Type = ‘U’) named CLASS exists in the database, and, if yes, that table will be removed from the database.( Note : reminder that the syntax will be more meaningful after we study SQL – this is merely a preview) IF EXISTS (SELECT * FROMSYSOBJECTS WHERE[Name] = ‘CLASS’ ANDType= ‘U’) DROP TABLE CLASS;

88 Database Design  Database design is the most crucial activity in database development, and involves designing the proper structure of tables, the proper relationships among tables, the appropriate data constraints, and other structural components.  Poorly designed databases are very problematic, and thus much of this course is devoted to reviewing the principles behind optimal database design.

89 The Three Types of Database Design From Existing Data –Analyze Spreadsheets and other data tables –Extract data from other databases –Design using normalization principles New Systems Development –Create data model from application requirements –Transform data model into a database design Database Redesign –Migrate databases to newer databases –Integrate two of more databases –Reverse engineer and design a new database using normalization principles and data model transformation

90 Database Design From Existing Data Often involves importing data from already existing spreadsheets or other files with tables of data. The data might also arise from an existing operational database, such as a CRM or ERP application, and will be brought into a new database specifically used for analysis and research. The existing database might arise from a data warehouse. Database designers must design the appropriate structure for the new database.

91 Databases Originating From Existing Data

92 A Common Issue in Creating a Database from Existing Data How should multiple tables and files from the existing data be handled in the new database? Should a single table be maintained as a single table?

93 Resolving the Design Issue from Existing Data Database designers follow a rigorous set of design principles, called Normalization or Normal Forms, which guide us to optimal database designs. Normalization is discussed later

94 Database Design for New Systems Development In the development of new information systems for business enterprises, government and organizations, databases are often designed “from scratch.” The databases are predicated on the database designer’s specification of user forms and the reports to be produced for the organization. Part of database design is eliciting and specifying User Requirements A data model is designed to graphically portray the User Requirements. The data model is then transformed into a database design. –Data models, such as Entity Relationship (ER) data modeling, are also studied along with how to transform our data models into database designs which can then be implemented.

95 Databases Designed for New Information Systems

96 Database Redesign Databases often need to be adapted to new or changing requirements (often referred to as database migration). We often need to integrate two (or more) databases, such as when adapting or removing legacy systems, or in enterprise application integration, where previously separate information systems are adapted to work with each other.

97 Database Redesign

98 The Relational Database Model The dominant database model is the relational database model, which is based upon tables of data (called relations) – all current major DBMS products are based on it Created by E. F. Codd in 1970 It was based on a mathematical theory called Relational Algebra Focus is on the relational database model.


Download ppt "Database Introduction. Objectives To understand the nature and characteristics of databases To survey some important and interesting database applications."

Similar presentations


Ads by Google