Instructor: Zhe He Department of Computer Science

Slides:



Advertisements
Similar presentations
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Advertisements

Database Management Systems and Enterprise Software
Database Management3-1 L3 Database Management Santa R. Susarapu Ph.D. Student Virginia Commonwealth University.
Chapter 4: Database Management. Databases Before the Use of Computers Data kept in books, ledgers, card files, folders, and file cabinets Long response.
Chapter 14 The Second Component: The Database.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
Web-Enabled Decision Support Systems
1 INTRODUCTION TO DATABASE MANAGEMENT SYSTEM L E C T U R E
Organizing Data and Information AD660 – Databases, Security, and Web Technologies Marcus Goncalves Spring 2013.
1 CSC 101 Introduction to Computing Lecture 27 Dr. Iftikhar Azim Niaz 1.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
1 CSC 101 Introduction to Computing Lecture 26 Dr. Iftikhar Azim Niaz 1.
Chapter 17 Creating a Database.
11 3 / 12 CHAPTER Databases MIS105 Lec15 Irfan Ahmed Ilyas.
Database Management Systems.  Database management system (DBMS)  Store large collections of data  Organize the data  Becomes a data storage system.
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
ITGS Databases.
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
0 / Database Management. 1 / Identify file maintenance techniques Discuss the terms character, field, record, and table Describe characteristics.
© 2017 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
1 Finding Your Way Through a Database Exploring Microsoft Office Access.
Databases and DBMSs Todd S. Bacastow January
Pengantar Sistem Informasi
DBM 380 AID Focus Dreams/dbm380aid.com
Chapter 1 Introduction.
Fundamentals of Information Systems, Sixth Edition
IST 220 – Intro to Databases
Databases Chapter 9 Asfia Rahman.
Introduction to Computing Lecture # 13
GO! with Microsoft Office 2016
DBM 380 aid Perfect Education/dbm380aid.com
Practical Office 2007 Chapter 10
Database Management Systems
 2012 Pearson Education, Inc. All rights reserved.
DBM 380 aid Education Begins/dbm380aid.com
Fundamentals of Information Systems, Sixth Edition
Fundamentals & Ethics of Information Systems IS 201
GO! with Microsoft Access 2016
Chapter Ten Managing a Database.
Chapter 12 Information Systems.
Exploring Microsoft Office Access
Database Management  .
Databases.
Database Vocabulary Terms.
RELATIONAL DATABASE MODEL
Tools for Memory: Database Management Systems
DBM 380 Competitive Success/snaptutorial.com
DBM 380 AID Lessons in Excellence-- dbm380aid.com.
DBM 380 Education for Service/snaptutorial.com
DBM 380 Teaching Effectively-- snaptutorial.com
Big Data The huge amount of data being collected and stored about individuals, items, and activities and to the process of drawing useful information from.
System And Application Software
Chapter 9 Database and Information Management.
MANAGING DATA RESOURCES
Chapter 1 Database Concepts.
Spreadsheets, Modelling & Databases
Introduction to Access
DATABASES WHAT IS A DATABASE?
Microsoft Office Access is the best –selling personal computer database management system. What is Access?
DATABASE TECHNOLOGIES
Chapter 3 Database Management
McGraw-Hill Technology Education
Databases This topic looks at the basic concept of a database, the key features and benefits of a Database Management System (DBMS) and the basic theory.
Exploring Microsoft Office Access
Database Management Systems and Enterprise Software
Information system analysis and design
Presentation transcript:

Spring 2013 CS 103 Computer Science – Business Problems Lecture 11: Database Management System Instructor: Zhe He Department of Computer Science New Jersey Institute of Technology 1/11/2019

Database Management Systems Database management system (DBMS) Store large collections of data Organize the data Becomes a data storage system Discussion point Ask your student if anyone knows why sorting by zip code is important. Hopefully, someone knows that the post office provides a discount on presorted mail.

The Database Stores a collection of related items Collection is arranged in a structure Organizes and describes the data Often includes helper documents Two different types Teaching tip Figure 11A.2 on page 423 describes the database structure

Database Structure Field Name Record Field

The Database Fields Hold an individual piece of data Are named descriptively Often called a column Phone book examples Name, address, e-mail, phone number Fields may contain no data Last Name Smith Lin Luis

The Database Records One full set of fields Often called a row Databases may have unlimited rows Last Name First Name Email Address Phone # Smith Joe Smith,joe@gmail.com 10 Harrison Ave, Harrison, NJ 371-897-9658 Lin Ying Lin.ying@ymail.com 30 fork Str, Newark, NJ 201-898-8977 Luis Hu lh113@njit.edu 12 Rose Str, Kearny, NJ 748-877-6547

The Database Tables One complete collection of records Databases may have thousands of tables Last Name First Name Email Address Phone # Smith Joe Smith,joe@gmail.com 10 Harrison Ave, Harrison, NJ 371-897-9658 Lin Ying Lin.ying@ymail.com 30 fork Str, Newark, NJ 201-898-8977 Luis Hu lh113@njit.edu 12 Rose Str, Kearny, NJ 748-877-6547

Flat-file Databases Typically has only one table If multiple, each has a separate file Useful for simple data storage needs Hard to manage large data needs Can waste disk space Teaching tip Start your students thinking about real databases, with millions of records. Using PA instead of Pennsylvania saves 10 bytes per record. In a database with 1 million records, this saves 10,000,000 bytes. This is roughly equal to a stack of 10 floppy disks

Relational Databases Made of two or more tables Tables are related by a common field Called a relationship or join Can help organize data Most common form of database Maintaining data is easier than flat-file No wasted disk space Teaching tip To demonstrate the power of relationships, setup a flat file database with music, artists, CD and year released. Demonstrate how difficult and wasteful it is to store several songs by the same artist and CD. Be sure to make several typing mistakes. Then build the same structure relationally. Create music, artist and CD tables. Join the artist and CD to the music table. Now show how easy it is to add songs from the same CD. While creating this database, it helps to use music the students know.

Symbols on ER Diagram ssn Person name Wedding Is-insured Entity Type Attribute Is-insured Relationship Type Wedding Weak Entity Type ssn Key Attribute

ER Diagram degree department gender room name Student CID name time Course UCID department credits Teach Take gender name UCID degree Instructor

Cardinality in E-R diagram One-to-one (1:1) 1 1 Marry Man Woman One-to-many (1:n) 1 M Fulfill Order Customer Many-to-many (n:m) M N Take Student Course NOTE: Every many to many relationship consists of two one to many relationships working in opposite directions

ER Diagram cont. degree department gender room name Student CID name time Course M UCID department N N credits Teach Take 1 gender name UCID degree Instructor

Full participation degree department gender room name Student CID name time Course M UCID department N N credits Teach Take 1 gender name UCID degree Instructor

ER Diagram

The DBMS Programs that control the database Allows Entering data Querying data Printing reports Supports thousands of users Includes tools to protect the data Teaching tip Protecting databases is similar to network administration, covered in chapter 9. Access to read and change data is limited to a list of allowed users.

Working with a Database Creating tables List the necessary fields Steps to define a field Descriptively name the field Specify the field type Determine the field size

Working with a Database Field types Describes the type of data stored Most DBMS use the same types Text fields store letters and numbers Numeric field store numbers Date and time field Logical field stores yes or no Binary field stores images or sounds Counter field generates sequential numbers Memo fields store large amounts of data Teaching tip Dates are stored sequentially in a database. 0 is January 1, 1970 at midnight. 1 is one millisecond after midnight on January 1, 1970. Each date represents the number of milliseconds from January 1, 1970.

Working with a Database Entering data into a table Users type data into a field Data must be entered accurately Constraints help to verify data Forms are typically used for data entry

Working with a Database Viewing records Datasheet view shows all records Filters can limit the records shown Display only records matching a criteria Forms allow viewing one record

Working with a Database Sorting records Order records based on a field Multiple sub sorts resolve ‘ties’ Several types of sorts Alphabetic Numeric Chronological Ascending Descending Teaching tip Using a DBMS, demonstrate the power of sorting for the class.

Working with a Database Querying a database Statement that describes desired data List of fields can be modified Uses of querying Find data Calculate values per record Delete records Most important DBMS skill Teaching tip Page 432 and 433 show examples of the different querying languages.

Working with a Database Query languages All DBMS use a query language Most DBMS modify the language Structured Query Language (SQL) Most common query language xBase Query language for dBase systems Query by example (QBE) Interface to SQL or xBase Interactive query design

Query Examples SQL xBase Select FirstName, LastName, Phone From tblPhoneNumbers Where LastName=“Norton”; xBase Use tblPhoneNumbers List FirstName, LastName, Phone For LastName=“Norton”

Query Examples degree department gender room name Student CID name time Course M UCID department N N credits Teach Take 1 gender name IID Instructor

Mapping 1. Entities Student (UCID, name, gender, degree, department) Course (CID, name, room, time, department, credits) Instructor (IID, name, gender)

Mapping 2. M-N Relationships 3. N-1 Relationships (full participation) Take (UCID, CID) 3. N-1 Relationships (full participation) Course (CID, name, room, time, department, credits, IID)

Schema from E-R Diagram Student (UCID, name, gender, degree, department) Take (UCID, CID) Course (CID, name, room, time, department, credits, IID) Instructor (IID, name, gender)

Database Creation SQL (1) Create table Student ( UCID varchar(20), name varchar(100), gender varchar(1), degree varchar(20), department varchar(20), PRIMARY KEY (UCID))

Database Creation SQL (2) Create table Instructor ( IID varchar(20), name varchar(100), gender varchar(1), PRIMARY KEY (IID))

Database Creation SQL (3) Create table course ( CID varchar(20), name varchar(100), room varchar(1), time varchar(20), department varchar(20), credit int, IID varchar(20), PRIMARY KEY (CID), FOREIGN KEY (IID) REFERENCES Instructor(IID) )

Database Creation SQL (4) Create table take ( UCID varchar(20), CID varchar(100), PRIMARY KEY (UCID, CID), FOREIGN KEY (UCID) REFERENCES Student(UCID), FOREIGN KEY (CID) REFERENCES Course(CID) )

Inserting data SQL queries INSERT INTO Student VALUES (‘ac123’, ‘Mike Liu’, ‘M’, ‘BS’,’Management’) INSERT INTO Instructor VALUES (‘zh5’, ‘Zhe He’, ‘M’) INSERT INTO Course VALUES (‘CS103’, ‘Computer Science – Business Problem’, ‘MALL PC 40’, ‘TR10001125’,’CS’,3,’zh5’) INSERT INTO take VALUES (‘ac123’, ‘CS103’)

Query examples SELECT UCID FROM students SELECT name List all the students’ UCID SELECT UCID FROM students List all the students in Architecture department SELECT name WHERE department = ‘Architecture’

Query examples SELECT S.UCID, S.name FROM Students S, Take T List all the students who are taking CS103 SELECT S.UCID, S.name FROM Students S, Take T WHERE S.UCID = T.UCID AND T.CID = ‘CS103’ List all the instructors who are teaching CS courses SELECT I.name FROM Course C, Instructor I WHERE C.IID = I.IID and C.department = ‘Computer Science’

Working with a Database Generating reports Printed information extracted from a database Can calculate data Calculate data per row Calculate for entire table Pictures and formatting can be included

Databases at Work Knowledge discovery Technique of databases Generates questions for the database Those you did not think to ask

Databases at Work Data mining Type of knowledge discovery Searches for trends and patterns Makes predictions on events Supplies ideas for improving business Teaching tip Demonstrate this using www.amazon.com. Search for an author (Lee Cottrell works well!) and open one of the book entries. Below the description you will see several links describing suggested products. Data mining provides these links.

Databases at Work Internet uses Commercial websites use databases Supply image and price information Specialty databases exist online Search engines track links Teaching tip Access a few specialty databases in class to demonstrate their power. An excellent example is terraserver.Microsoft.com.

Databases at Work Databases for individuals Manage aspects of your life Organizes hobbies for school Microsoft Access is the most popular Discussion point An employer for my school suggested a way to improve student marketability. He states that he looks for the student that has gone beyond their studies at school and applied their learning to a hobby. As an example, he hires people with databases for their music or personal web sites.

Common Corporate DBMS Oracle Most popular enterprise-level DBMS Very flexible storage system Can be very complex Platform independent Offers a wide range of solutions

Common Corporate DBMS DB2 Venerable IBM database Platform independent Only database using pure SQL Teaching tip Remind students that SQL stands for Structured Query Language.

Common Corporate DBMS Microsoft SQL Server Fastest growing DBMS Only runs on Microsoft platforms Eight different versions exist Extremely scalable architecture Software can grow with the data

Common Corporate DBMS MySQL Leading DBMS for Linux Very inexpensive Features are those needed in business Often faster than other DBMS Platform independent Teaching tip An interesting article contrasting the strengths and weaknesses of these products can be found at www.eweek.com/article2/0,3959,293,00.asp.