mgis 301 databases and database technologies

59
MGIS 301 Management Information Systems Week 04 Databases and Database Technologies M. Murat Albayrakoglu

Upload: m-murat-albayrakoglu

Post on 12-Apr-2017

89 views

Category:

Education


0 download

TRANSCRIPT

Page 1: MGIS 301 Databases and Database Technologies

MGIS 301 Management Information Systems

Week 04Databases and Database Technologies

M. Murat Albayrakoglu

Page 2: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 2

Agenda • Transferable skill • Database concepts • Database design • Database management system (DBMS)

Page 3: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 3

Transferable Skills• Any skill that applies to various roles and tasks throughout an individual’s

career• Can be acquired via various activities• Informal• Formal

• Categories • Communication skills • Analytical skills • Technical skills • Personal skills • Organizational skills

Database skills = Knowledge + Practice

Page 4: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 4

Database Concepts

Page 5: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 5

Basics• Bit (b): 0 or 1 • Byte (B): 8 bits; size of each ASCII character• Data storage needs measured in

kB = 103 BMB = 106 BGB = 109 BTB = 1012 BPB = 1015 BEB = 1018 BZB = 1021 B

Page 6: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 6

Database Definition• A database is an organized collection of related data • A database

has a purpose has users has structure describes a relevant part of the real world

Page 7: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 7

Database Advantages• Program-data independence

• Data changes without changing programs • New programs can use existing data

• Planned data redundancy• Limited replication of data • Storage space efficiency

• Improved data consistency• Reduced chance for data inconsistency

• Improved data sharing • Authorized users • User view specific to a task

• Increased productivity of application development• Focus on accessing data rather than creating and updating data• Focus on functionality

Page 8: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 8

Database Advantages (cont.)• Enforcement of standards

• Single authority to enforce data standards: DBA • Improved data quality

• Entry and modification constraints • Integrity constraints

• Improved data accessibility and responsiveness• Easy to get data from within the authorized user views

• Reduced program maintenance• No impact of data changes on the programs to a certain limit

• Improved decision support• Fast access to high quality data • Faster and more accurate decisions

Page 9: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 9

Database Disadvantages• New IT specialists

• Database developers and administrators

• Installation and maintenance costs • Getting, operating and maintaining multi-user systems

• Apparent complexity• User, developer and administrator training

• Conversion costs • Changing from legacy systems to a database environment

• Security and continuity risks• Backup and recovery issues

• Organizational conflicts• Data definition, ownership, and maintenance rights

Page 10: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 10

Database ModelsPre-Relational and Relational Models• Flat file model • Hierarchical database model • Network database model • Relational database model (in

this course) • Object-relational database

model

Post-Relational Models (after Web 2.0)• Object database model • Column-based database model • Key-value database model • Document-based database

model • Graph database model • Hybrid database models

Page 11: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 11

Relational Database Model History • Edgar F. Codd proposed the

model in 1970• Based on the concepts of

relational algebra • First commercial

implementation in 1979 • Oracle’s SQL RDBMS

Major players today • Proprietary

• IBM DB2• Microsoft Access • Microsoft SQL Server • Oracle

• Open source • MySQL• PostGRE SQL • SQLite

Page 12: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 12

Relations • Relation (Table)

• Named and two-dimensional table, e.g. INSTRUCTOR • Contains columns e.g. instructorID, instructorName, lastName, academicTitle,

dateEmployed• Contains data, e.g. 555551, Mehmet Murat, Albayrakoglu, Instructor, 15/09/2016

in its rows

• Attribute (Field)• Each named column of a relation, e.g. instructorName, lastName, academicTitle • Of a particular data type, e.g. text, integer, decimal, date, hyperlink, Boolean, date etc.

• Tuple (Record) • Each unnamed row of a relation • Made up of data cells

Page 13: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 13

Example: A Table

Page 14: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 14

Keys• Primary key

• An attribute (or combination of attributes) whose value is unique across all occurrences of a relation• e.g. studentID, citizenshipNo, productID.

• Composite key • An attribute that has meaningful components • e.g. studentID = 20150112007 is made up of admissionYear = 2015 collegeID = 01 departmentID = 12 registrationNo = 007

• Foreign key • An a nonprimary attribute in one relation that appears as a primary key in another• e.g. departmentID in INSTRUCTOR relation.

Page 15: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 15

Keys: Examples • Primary key

INSTRUCTOR(instructorID, instructorName, lastName, academicTitle, dateEmployed)

COURSE(courseID, courseName, creditHRS) DEPARTMENT(departmentID, departmentName)

• Composite key INSTRUCTORCOURSE(instructorID, courseID, courseCoordinator)

• Foreign key INSTRUCTOR(instructorID, instructorName, lastName, academicTitle,

dateEmployed, departmentID)INSTRUCTORCOURSE(instructorID, courseID, courseCoordinator)

Page 16: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 16

Primary Keys

Page 17: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 17

Composite Key

Page 18: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 18

Foreign Key

Page 19: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 19

Foreign Keys

Page 20: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 20

Relational Algebra• An algebra is a mathematical system of operands and operators • Operands

• Relations (tables)

• Operators• Union• Intersection• Difference• Selection• Projection • Join• Renaming

Used for creating a programminglanguage, known as SQL, capable of creating and modifying relations and relationships, as well as,manipulating data contained in one or more relations

Page 21: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 21

Tuple (Record) Operations: CRUD • In a given relation• Create • Creates a new tuple

• Read • Reads an existing tuple

• Update • Updates an existing tuple

• Delete• Deletes an existing tuple

Page 22: MGIS 301 Databases and Database Technologies

Data Entry• Electronic forms (e-forms)• Mostly browser based• Form elements

• Label• Text box • Radio button • Check box • Menu • Slider• Action buttons (Save, Submit, OK, Cancel, Help etc.)• etc.

05/03/2023 MGIS 301 Management Information Systems 22

Page 23: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 23

Example: A Raw Form

Page 24: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 24

Queries• Filtered data for a specific purpose • To make a query • Decide what data are required• Define a criterion to select data to fulfill the requirement • Identify the relations and the fields that holds the data • Perform the query

• To perform a query • Write an SQL statement • Use a query-by-example (QBE) tool

Page 25: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 25

Example: A Query

Page 26: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 26

Example (cont.)The SQL Statement to perform the query: SELECT INSTRUCTOR.academicTitle, INSTRUCTOR.instructorName, INSTRUCTOR.lastName, DEPARTMENT.departmentName

FROM DEPARTMENT INNER JOIN INSTRUCTOR ON DEPARTMENT.[departmentID] = INSTRUCTOR.[departmentID]

WHERE DEPARTMENT.departmentName = ‘Economics’;

Thank God, I don’t have to know this in MGIS 301!

Page 27: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 27

Reports• A report is an organized and summarized data for a particular purpose • Report elements • Tables• Charts

• Report types • Regular reports

• Time-triggered reports • Event-triggered reports

• Ad-hoc reports • On a per-requirement basis

Page 28: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 28

Example: A Raw Report

Page 29: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 29

Database Design

Page 30: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 30

Database Design• Modeling organizational data

• Output: Conceptual data model • A representation of the organizational data (ERD)

• Conceptual database design • Output: Conceptual database model• A representation of normalized data in detail

• Physical database design • Output: Physical database model• Specific DBMS representation the conceptual database model

• Next: Database implementation (in the labs) • Programming the database visually or with SQL programming language

Page 31: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 31

Steps of Conceptual Database Design 1. Determine the relevant entities2. Indicate the relevant attributes of each entity type 3. For each entity, decide which one(s) of these characteristics can be a

candidate for uniquely identifying the entity4. Set the most useful candidate key as the identifier 5. Determine the relationships among the entities 6. Connect entities through relationships 7. Determine the business rules 8. Indicate the cardinality of the relationships

Page 32: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 32

Entities • Similar persons, places, things, events, or concepts • Categories of data • The symbol and an example

ENTITYattribute1attribute2…attributeM

STUDENT

studentIDnationalIDstudentNamelastName birthDatebirthPlacegendercellPhoneeMailhomeAddress yearAdmittedyearIncumGPAyearGraduated

Candidate keys

Entity name (singular)

Attribute list

Identifier

Page 33: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 33

Entities (cont.)• Entity type • Similar entities

• Three generic entity types • Strong entity • Weak entity • Associative entity

• Entity instance (or occurrence) • Single example of an entity

Page 34: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 34

Entities and Entity Instances STUDENT

studentIDnationalIDstudentNamelastName birthDatebirthPlacegendercellPhoneeMailhomeAddress yearAdmittedyearIncumGPAyearGraduated

STUDENT

0000001555 55 555 551EminKendinden Jul. 20, [email protected]……………

Entity Entity instance

Page 35: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 35

Attributes• Attributes • Relevant characteristics of each entity for the organization • Each attribute belongs to a domain, e.g. text, integer, date, hyperlink, file etc.

• Candidate key • One or more of the attributes of a particular entity that is used to identify

each specific occurrence of the entity • e.g. the citizenship number, tax ID, or school ID.

• Identifier • The candidate key chosen to be the unique identifying characteristic of each

entity

Page 36: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 36

Attribute Types• Multivalued attribute, e.g. phone numbers • Repeating group, e.g. children or various addresses • Required attribute, e.g. student ID• Optional attribute, e.g. second name• Composite attribute, e.g. course ID and student ID • Derived attribute, e.g. age = today – birthDate

Page 37: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 37

Relationships • Any association of two or more instances of entities relevant to a

business • Degrees of a relationship • Unary (advanced) • Binary (in this course)• Ternary (advanced)

• Normalized relationships • Necessary to preserve data integrity

Page 38: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 38

Relationships: Depiction • Entity 1 does something to Entity 2 • Something is done to Entity 2 by Entity 1

ENTITY 2

attribute1attribute2…attributeN

ENTITY 1

attribute1attribute2…attributeM

Something_done_by

Does_something_to

Page 39: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 39

Relationships: Example

COURSE

courseIDcourseNamecreditHrs…

STUDENT

studentIDstudentNamelastName…

Taken by

Takes

Page 40: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 40

Relationships: Optionality and Cardinality

CardinalityOne Many

Optionality

Optional Optionalone

Optionalmany

Mandatory Mandatoryone

Mandatorymany

• Optional one

• Mandatory one

• Optional many

• Mandatory many • Minimum and maximum cardinalities

may be defined • e.g. a class section may have between a

minimum of 5 and a maximum of 50 students

Page 41: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 41

Optionality and Cardinality Example• From left-to-right:

A student always takes one or more courses• From right-to-left:

A course is sometimes taken by one or more students

COURSE

CourseIDcourseNamecreditHrs…

STUDENT

studentIDstudentNamelastName…

Taken by

Takes

Page 42: MGIS 301 Databases and Database Technologies

05/03/2023 42

Cardinality Types

MGIS 301 Management Information Systems

One-to-one

One-to-many

Many-to-many

Page 43: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 43

More Examples and Exercises Consider the following relationships. Describe the two-way relationships in plain English. Draw the ERD segments connecting each pair. • INSTRUCTOR advises STUDENT• STUDENT gets PC• STUDENT earns SCHOLARSHIP • STUDENT lives in ROOM • ROOM contains FURNITURE • ROOM belongs to DORM

• PUBLISHER publishes BOOK • AUTHOR writes BOOK • BOOKSTORE sells BOOK • BOOKSTORE ships BOOK • CUSTOMER orders BOOK • CUSTOMER pays for BOOK

Page 44: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 44

Degree of Relationships • Number of entities participating in a relationship

Unary Binary Ternary

Page 45: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 45

Entity Relationship Diagram (ERD)• Create entity-relationship segments • Combine them to a complete diagram

E1 E2

E2 E3

E1 E4

E1 E2

E3

E4

Page 46: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 46

Conceptual Database Design 1. Normalize the relationships in the data model (ERD) 2. Transform entities into relations 3. Create relationships 4. Merge relations

Page 47: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 47

Normalization • Normalization is a process for converting a single many-to-many

relationship into two one-to-many relationships • Normalization helps • Avoid data anomalies • Protect data integrity

COURSE

CourseIDcourseNamecreditHrs

STUDENT

studentIDstudentNamelastName…

Takes

STUDENTCOURSE

studentIDCourseIDGrade Taken by

Refers to

Referred by

Page 48: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 48

Transforming Entities into Relations • A relation has the following form: • ENTITY(primaryKey, attribute1, attribute2, … , attributeN)

• Examples • STUDENT(studentID, studentName, lastName, birthDate,

birthplace,...)• COURSE(courseID, courseName, creditHrs)• STUDENTCOURSE(studentID, courseID, grade)• DEPARTMENT(departmentID, departmentName)

Page 49: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 49

Creating Relationships• DEPARTMENT(departmentID, departmentName)

STUDENT(studentID, studentName, lastName, birthDate, birthplace,…, departmentID)

• DEPARTMENT(departmentID, departmentName)

COURSE(courseID, courseName, creditHrs, departmentID)

How toInsert the primary key of the relation on the one-side ofthe relationshipinto the relationon the many-side.

Page 50: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 50

Merging Relations• DEPARTMENT(departmentID, departmentName)

STUDENT(studentID, studentName, lastName, birthDate, birthplace,…, departmentID)

COURSE(courseID, courseName, creditHrs, departmentID)

How toReduce the number of repeating entities to one.

Page 51: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 51

Physical Database Design 1. Create relations by using the RDBMS’s visual programming tools or SQL

language 2. Establish relationships among relations by using the RDBMS’s visual

programming tools or SQL language 3. Design data entry forms by using the RDBMS’s visual programming tools 4. Design queries by using the RDBMS’s visual programming tools or SQL

language 5. Design regular reports by using the RDBMS’s visual programming tools 6. Design menus by using the RDBMS’s visual programming tools

Page 52: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 52

Database Implementation

Page 53: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 53

Database Management Systems (DBMS)

Page 54: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 54

Components of a DBMSCreate and change thelogical structure of data

Create-Read-Update-DeleteMake queries

Create and modify menus, forms and reports

Data authorization Recovery and backup Structural changes

DBM

S En

gine

Datadictionary

Database

Data definition language

Data manipulationlanguage

Data administration tools

Application generation tools

DatabaseDatabase

Page 55: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 55

Client-Server Architecture

Databaseserver

Applicationserver

Webserver

Internet

Clients

Page 56: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 56

Centralized Database

Internet

Page 57: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 57

Distributed Database

Internet

Page 58: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 58

Q&A

?

Page 59: MGIS 301 Databases and Database Technologies

05/03/2023 MGIS 301 Management Information Systems 59

Next Week • We will have two online quizzes• The first due Tuesday, 10/25/2016• The second due Thursday, 10/27/2016

• We will have a 2-page written assignment from Chapter 1 of our textbook. • We will discuss the issues related to Chapter 6 and Appendix C of our

textbook.