Database Fundamentals Lecture 4 Useful website for MySQL download language.com/workshops/Default.asp ?workshop=21.

Slides:



Advertisements
Similar presentations
Data Modeling. What are you keeping track of? You begin to develop a database by deciding what you are going to keep track of. Each thing that you are.
Advertisements

BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Chapter 3 Data Modeling Copyright © 2014 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent.
Data Design The futureERD - CardinalityCODINGRelationshipsDefinition.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Accounting System Design
Relational Databases Chapter 4.
Database Fundamentals Lecture 5. The Design Process continued.
CSE 1561 Designing Relational Databases Stephen Scott.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Database Design Concepts Info1408
Relational Databases What is a relational database? What would we use one for? What do they look like? How can we describe them? How can you create one?
Case study Lisa’s Bookstore IST210.
APPENDIX C DESIGNING DATABASES
Data Modeling 1 Yong Choi School of Business CSUB.
Database Systems Marcus Kaiser School of Computing Science Newcastle University.
Relational Database Concepts. Let’s start with a simple example of a database application Assume that you want to keep track of your clients’ names, addresses,
Introduction to Accounting Information Systems
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Entity Relationship Diagram (ERD) 22 February 2011.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Concepts and Terminology Introduction to Database.
G057 - Lecture 02 Introduction To Database System Concepts Mr C Johnston ICT Teacher
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
HNDComputing – DeMontfort University  DeMontfort University 2011 Database Fundamentals wk2 Database Design ConceptsDatabase Design Concepts Database Design.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Rob and Coronel Adapted for INFS-3200.
Lecturer: Gareth Jones. How does a relational database organise data? What are the principles of a database management system? What are the principal.
Data Models and Relational Databases Chapter 2. Learning Objectives Identify primary and foreign keys for each entity and relevant relationships in the.
1 n 1 n 1 1 n n Schema for part of a business application relational database.
Introduction to Databases Trisha Cummings. What is a database? A database is a tool for collecting and organizing information. Databases can store information.
Implementing an REA Model in a Relational Database
ATADESAB. BATLE CORDER DLEIF Lesson objectives In this lesson you will learn some basic database terms and learn how a database is created.
1 A Guide to MySQL 2 Database Design Fundamentals.
1.  An introduction to data modelling  The purpose of data modelling  Modelling data relationships 2.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
Relational Database. Database Management System (DBMS)
Entity-Relationship (ER) Modelling ER modelling - Identify entities - Identify relationships - Construct ER diagram - Collect attributes for entities &
Microsoft Access Intro Class 6 Relationships.
DATABASE What exactly is a database How do databases work? What's the difference between a spreadsheet database and a "real" database?
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
1 Database & DBMS The data that goes into transaction processing systems (TPS), also goes to a database to be stored and processed later by decision support.
Chapter 7 Data Modeling with Entity Relationship Diagrams
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
Description and exemplification of entity-relationship modelling.
Jozef Kuper.  Describe a Database  Entities  Atributes  Relationships.
Database Design. The process of developing database structures from user requirements for data a structured methodology Structured Methodology - a number.
Cloudacus = LAMP + Appaserver ©Tim Riley Appahost Model.
Relational Database. I. Relational Database 1. Introduction 2. Database Models 3. Relational Database 4. Entity-Relationship Models 5. RDB Design Principles.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
44220: Database Design & Implementation Conceptual Data Modelling Ian Perry Room: C49 Tel Ext.: 7287
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
INTRODUCTION TO DATA MODELING CS 260 Database Systems.
* Database is a group of related objects * Objects can be Tables, Forms, Queries or Reports * All data reside in Tables * A Row in a Table is a record.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
Information Systems Database Systems (H).
Data Modeling AND ER MODELS.
Microsoft Access CS 110 Fall Entity Relationship Model Entities Entities Principal data object about which information is to be collectedPrincipal.
Database Relationships
Database Fundamentals
logical design for relational database
Presentation transcript:

Database Fundamentals Lecture 4 Useful website for MySQL download language.com/workshops/Default.asp ?workshop=21

The Design Process Good decisions require good information derived from raw facts known as data.

Importance of good database design Well designed database facilitates data management and becomes a good information generator. It will grow well. It is easy to use.

NoteNoPackerCompComp Add ItemNoQtyPartNoDescrip 300JWBloggsYork Nuts 300JWBloggsYork Bolts 300JWBloggsYork Nails What is wrong with this organisation’s database? Info about Packer, Comp and CompAdd has been repeated in more than one row If Bloggs was the only company to have purchased Nuts and then decided they did not want them so were deleted from packing note, contents of ParNo and Descrip fields would be lost PartNo and Descrip fields cannot be established until a packing note has been raised. Update anomaly Delete anomaly Insert anomaly

Architect Plan Builder House Database Designer Database Design Database Builder Database System

The Database Design Process 1 Define the current process. 2 Define the components of the organisation. 3 Define rules (how organisation is run). 4 Model the database. 5 Define the relationships. 6 Review. 7 Create the database. 4, 5, 6 & 7 are pertinent to this module.

Entities Things it may be required to keep information about. Can be: People (e.g. Customers) Objects (e.g. Products) happening (e.g.ad hits)

address 14 Grand Ave 59 Cucumber Dr 928 Shingles Rd 2572 Family Ave phone Company_num Company_name Big Deal Ltd Pickles Inc Real Roofing Co Gigafred & Son company Company_num ad_num Hit_fee product date July 13 July 14 July 15 ad_num ad hits

Is it an entity? Rules: 1.An entity must be important to the organisation. 2.An entity must have at least one attribute. 3.An entity must occur more than once (there must be more than one customer) 4.Each entity occurrence (record) must be uniquely identifiable (customer id)

Entities are represented like this and they are always singular. customer Bits of data associated with the entity are attributes: Customer number Customer name Customer address Contact name Telephone Way of identifying occurrence (record) - the primary key.

Relationships customer invoice product

Three types of Relationhip one-to-one (1:1) one-to-many (1:M) many-to-many (M:N)

cardriver cardriver cardriver cardriver 1:1 A car can only have one driver; a driver can have only one car. 1:M A car can have more than one driver; a driver can only one car. 1:M A car can have only one driver; a driver can have more than one car. M:N A car can have more than one driver; a driver can have more than one car.

A typical company Managing Director Company Sales Staff Customer employs manages take orders Relationship name

Sales Staff Customer take orders Sales StaffCustomer Order acceptsplaces This many-to-many relationship does not enable mapping between a particular order and a particular member of the sales staff The entity Order uniquely defines an instance involving both Sales Staff and Customer. From a single many-to-many relationship two one-to-many relationships have been created.

Sales Staff Staffid Name DOB Employ start date Order Orderid Staffid* Customerid* Order details Customer Customerid Name Address Contact name Telephone Foreign keys

A model is: Simplified abstractions of real world events or conditions. A database model is a collection of logical constructs used to represent the data structure and the data relationships within the database 2 categories of database models: –Conceptual models (what is presented) –Implementation models (how it is represented)

Entity (E-R) Relationship Model (top down approach) A conceptual model and like other conceptual models it uses three types of relationship: one-to-many (1:N) one-to-one (1:1) many-to-many (M:N) Multiplicity is a term which can be used to describe this.

ENTITY - is a person place or thing for which data are to be collected or stored e.g.student, book, author, stock ATTRIBUTE - characteristics of an entity e.g. student entity may include the attributes student number, date of entry, pathway, dob, home address, phone number etc. RELATIONSHIP - an association between entities e.g.

Week 4 practical In week 4 you will be working with the 3 tables: book author stock And you will make queries such as:

USE ; DROP TABLE IF EXISTS book; CREATE TABLE book ( bookid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR(50) NOT NULL, author VARCHAR(20) NULL, topic VARCHAR(20) NOT NULL, pages INT UNSIGNED NULL, firstPubDate YEAR NULL, publisher VARCHAR(40) NOT NULL, price FLOAT(4,2) );

DROP TABLE IF EXISTS stock; CREATE TABLE stock ( bookid INT UNSIGNED NOT NULL, authorid INT UNSIGNED NOT NULL, reorder INT NOT NULL, instock INT NOT NULL ); DROP TABLE IF EXISTS author; CREATE TABLE author ( authorid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, lastname VARCHAR(20) NOT NULL, firstname VARCHAR(20) NOT NULL );

SELECT book.title, author.lastname, author.firstname, stock.instock FROM book, author, stock WHERE stock.instock <5 AND stock.bookid=book.bookid AND stock.authorid=author.authorid ;

1) SELECT title FROM book \c ; 2) SELECT book.title, author.authorid FROM book, author \c ; 3) SELECT book.title, author.authorid, stock.instock FROM book, author, stock WHERE author.lastname='GLANCEY' AND author.authorid=stock.authorid \c ; 4) SELECT book.title, author.authorid, stock.instock FROM book, author, stock WHERE author.lastname='GLANCEY' AND author.authorid=stock.authorid AND stock.bookid=book.bookid \c ; 5) SELECT book.title, author.lastname, author.firstname, stock.instock FROM book, author, stock WHERE stock.instock <5 AND stock.bookid=book.bookid AND stock.authorid=author.authorid \c ;