Introduction to Relational Database David Gerbing School of Business
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Relational Database David Gerbing School of Business Administration Portland State University Table of Contents SECTION I BASIC RELATIONAL DATABASE CONCEPTS ..... 1 Introduction ............................................................................................................................................................ 2 Database Management Systems ......................................................................................................................... 2 History ................................................................................................................................................................ 3 Database Structure ................................................................................................................................................ 4 Tables ................................................................................................................................................................. 4 Limitations of Representing Disparate Data Types with a Single Table ........................................................... 5 One-to-Many Relationships across Multiple Tables .......................................................................................... 7 Forms .................................................................................................................................................................... 12 Database Analysis ................................................................................................................................................ 13 Queries ............................................................................................................................................................. 14 Reports ............................................................................................................................................................. 14 Example: The Invoicing Database ..................................................................................................................... 16 Invoicing Structure ........................................................................................................................................... 16 OrderLine subform ........................................................................................................................................... 18 Database Design and Use .................................................................................................................................... 19 References ............................................................................................................................................................. 21 Further Reading ............................................................................................................................................... 21 Endnotes ........................................................................................................................................................... 21 © David W. Gerbing, 2013 Section I Basic Relational Database Concepts This section introduces the basic vocabulary and central concepts of a relational database, including the tables that store the data and the one-to-many relationships that link the data across tables. This section also introduces the data analysis techniques of queries and reports. These concepts are applied to the description of an invoicing database. Relational Database Introduction Databases store and organize data. The names, addresses, and phone numbers in a phone book constitute a database, as does a collection of recipes stored on a set of index cards. A database is a stored, structured, integrated and retrievable set of data. Today most organizations and businesses store their databases on computer systems. Computerized databases include accounting applications such as invoicing, accounts receivable, and accounts payable. Other business examples include sales management applications organized around lists of customers and potential customers, inventory control, and the pictures and descriptions of a company’s products available for sale over the Internet. Database Management Systems The concept of a DBMS. An application program and related files for managing a computerized database form a Database Management System (DBMS). As Table 1 illustrates, a DBMS allows a user to (a) enter and modify the data, (b) organize the data, and then (c) retrieve and/or summarize the data. Table 1. Database activities. Activity Examples change a customer’s order Manipulate Data enter a new student into the class roster delete a student from the class roster locate all past due invoices Organize Data sort a list of students by their last name locate all students registered for a particular class calculate total sales over the last year by zip code Retrieve and/or Summarize Data list students in a class on the computer screen create a disk file of students in the class print a listing of students in the class DBMS programs span a wide range of power and usability. A desktop DBMS runs on a personal computer for only a single user. A server DBMS allows simultaneous access to one set of data by multiple users at different computers. The individual users or clients connect to the server computer that stores the data that all users access. A small office or departmental server DBMS may allow a dozen users to simultaneously access the database. The most powerful server DBMS programs run on the largest mainframe computers and allow 2 Gerbing © 2013 I. Database Concepts hundreds, thousands, or even tens of thousands of users, all simultaneously modifying, processing, and retrieving data. Some specific DBMS programs. The most widely installed DBMS at the personal computer level is Microsoft Accessi, restricted to the Windows family of operating systems. The most widely used DBMS that runs on both Windows and Macintosh personal computers is Filemaker Pro. PC Magazineii (2012) named FileMaker Pro 12 as Editor’s Choice for Best Personal Database. One reason for this high rating is that Filemaker Pro is simpler to use than MS Access but still delivers much of the power of the more sophisticated and correspondingly more difficult to use DBMS. Filemaker also more easily generalizes from one to hundreds of users, whereas Access is limited to only several users at a time. Large companies and organizations run their database systems on mainframe computers. Examples include airline reservation systems, bank records, and student records for large universities. The most widely installed large-scale DBMS is Oracleiii. The large-scale DBMS with the second highest number of installations is IBM’s DB2iv. Microsoft’s entry into the large-scale database field is SQL Serverv, which is often integrated with a graphical user-interface provided by MS Access (or similar product such as 4D). Versions of these large- scale systems also run on smaller computers. The Unix world offers several powerful commercial and open-source (free) DBMS’s. Perhaps the most powerful and full-featured open-source database that runs on Windows and Unix (and therefore Macintosh) is PostgreSQLvi. MySQL is another popular open-source product, particularly for working with data on web sites such as customer lists and products offered for salevii. MySQL is more of a file manager than a true relational database, a kind of database- light. SQLite is a very small free, open source database that is widely used in many applications. For example, SQLite is at the core of many iPhone applications, providing the structure for storing and organizing data. History An IBM researcher, Ted Codd, proposed the concept of a relational database in 1970. Based on Codd’s work, IBM developed the first versions of the standard relational database programming language called SQL. IBM, however, already sold a type of commercially successful database that preceded the relational database, so the company did not innovate for fear of undermining their existing product. Larry Ellison seized the opportunity in the early 1980s and founded Oracle Corporation, which offered the first commercial relational database Gerbing © 2013 3 Relational Database based on the SQL language. Oracle’s database market preeminence continues todayviii,ix. Appearing in 1985 on the Macintosh, 4D was one of the first database programs for a personal computer. 4D was also the very first database application to offer a graphical user interface – when all other mainframe and PC databases were limited to text interfaces. Database Structure Different DBMS’s organize data differently. The most common type of database structure is the relational database. A relational database stores all data in a series of related tables. Some forms of databases (hierarchical and network) predate the relational database, and a newer form of database structure, the object-oriented database, is emerging. However, the vast majority of contemporary databases, including those previously discussed such as Microsoft Access and 4D, follow the relational model. Tables Entity Type Fields A table organizes data by columns and Customer Last First Addr1 Records rows. The table in Smith John 22 NE 22nd St Table Figure 1 contains Jackson Sally 33 NE 33rd St data for two customers. An actual Figure 1. Database table with two records (Customers). Customer database table may contain data for millions of customers. All of the data in a table describes a particular type