CompSci 280 S Introduction to Software Development

Slides:



Advertisements
Similar presentations
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Advertisements

Accounting System Design
Systems Development Life Cycle
The Database Approach u Emphasizes the integration of data across the organization.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Database Architecture The Relational Database Model.
Database Lecture # 1 By Ubaid Ullah.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Database Technical Session By: Prof. Adarsh Patel.
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
FEN  Concepts and terminology  Operations (relational algebra)  Integrity constraints The relational model.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lection №4 Development of the Relational Databases.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
Chapter 3: Relational Databases
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
Lecture 4: Logical Database Design and the Relational Model 1.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Database Constraints ICT 011. Database Constraints Database constraints are restrictions on the contents of the database or on database operations Database.
Database Constraints Ashima Wadhwa. Database Constraints Database constraints are restrictions on the contents of the database or on database operations.
Getting started with Accurately Storing Data
Databases and DBMSs Todd S. Bacastow January
Fundamentals of DBMS Notes-1.
Logical Database Design and the Rational Model
Chapter 1 Introduction.
Chapter 4 Logical Database Design and the Relational Model
Chapter 4: Logical Database Design and the Relational Model
COP Introduction to Database Structures
Client/Server Databases and the Oracle 10g Relational Database
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Normalization Karolina muszyńska
Information Systems Today: Managing in the Digital World
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Database Management Systems (DBMS)
Information Systems Database Management
Chapter 4 Relational Databases
Translation of ER-diagram into Relational Schema
Databases and Information Management
Chapter 9 Designing Databases
Introduction lecture1.
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Accounting System Design
Data Modelling Introduction
Normalization Referential Integrity
Relational Database.
Database.
Insert, Update, Delete Manipulating Data.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
SQL DATA CONSTRAINTS.
Accounting System Design
Databases and Information Management
DATABASES WHAT IS A DATABASE?
Chapter 17 Designing Databases
DATABASE Purpose of database
Relational Database Model
INTRODUCTION A Database system is basically a computer based record keeping system. The collection of data, usually referred to as the database, contains.
Presentation transcript:

CompSci 280 S2 2107 Introduction to Software Development The Relational Model

Today’s Agenda Topics: Reading: Introduction The Relational Model Database Relationships One to One One to Many Many to Many Constraints Reading: https://www.tutorialspoint.com/dbms/relational_data_model.htm Lecture13

Modeling an App with a 3-Tier Architecture Written docs UI models (e.g. screen diagrams) Flow or sequence charts State machines Data models (e.g. class diagrams) Lecture13

1.Introduction What is a Database Management System DBMS? Definition Software that manages and stores the data. The applications interact with the system, which retrieves and manipulates the data. Advantages of Database systems over file systems Data Integrity; Controlled Redundancy; Standards can be proposed since the data definitions are also shared; The ability to implement decisions on access control; The ability to balance conflicting needs by tuning and optimising Security of data. Lecture13

2.The Relational Model Was introduced by Codd in 1970 (journal paper); It is based on a simple and uniform data structure - the relation - and it has a solid theoretical foundation; The Relational Model represents the Database as a collection of Relations, which are sets from a mathematical point of view; One Entity type is a Relation; One Relationship Type is either a Relation or one or more attributes; The retrieval of information involves manipulating the Relations using set operations and also operators defined in the relational algebra; Examples of relational database systems: Oracle, Microsoft SQL Server, Sybase SQL Server, Lecture13

2.The Relational Model Relational Database Data from several tables is tied together (related) using a field that the tables have in common A Simple Relational Database Example Lecture13

2.The Relational Model Some Rules … Every table has a unique name. Attributes in tables have unique names. Every row/tuple is unique. Lecture13

2.The Relational Model Concept Relational modeling uses primary keys and foreign keys to maintain relationships Primary Key (cannot have null value) - attribute(s) that uniquely identify a tuple in a table. Foreign Key - an attribute that is a primary key in another table. Composite keys are primary keys that are made of more than one attribute Weak entities Associative entities Lecture13

2.The Relational Model Customer Table Mapping UML class diagrams to Relational Data Base Tables CREATE TABLE Customer ( customerID INT NOT NULL primary key, name VARCHAR(50) NOT NULL, tempAmount decimal ); Lecture13

3.Database Relationships There are several types of database relationships. One to One Relationships One to Many and Many to One Relationships Many to Many Relationships Lecture13

3.Database Relationships One to One Relationships There are two tables: Customers table: Addresses table: We have a relationship between the Customers table and the Addresses table. If each address can belong to only one customer, this relationship is "One to One". Keep in mind that this kind of relationship is not very common. Normally one table is enough: Lecture13

3.Database Relationships One to Many Relationships This is the most commonly used type of relationship. Consider an e-commerce website, with the following: Customers can make many orders. Orders can contain many items. Items can have descriptions in many languages. Example: Each customer may have zero, one or multiple orders. But an order can belong to only one customer. Lecture13

3.Database Relationships Many to Many Relationships In some cases, you may need multiple instances on both sides of the relationship. For example, each order can contain multiple items. And each item can also be in multiple orders. We need to create an extra table: Lecture13

4.Constraints Primary & Foreign Keys Tables can be related through primary/foreign key relationships (e.g. A customer may order one or more orders) Primary key Guarantees the uniqueness of a row Can be composed of one or more columns Foreign key Establishes logical relationship between tables One or more columns of a table that match the primary key of another table CustomerID FirstName LastName ALFKI Maria Anders Alfreds Futterkiste ANATR Ana Trujillo Ana Trujillo ... Foreign Key 1 ∞ Relation OrderID CustomerID OrderDate 10248 WILMK 04-Jul-1996 10249 TRADH 05-Jul-1996 Primary Key Lecture13

4.Constraints A CONSTRAINT is a rule that limits (or restricts) what data can be placed in a column of a table. Constraints are used to ensure that the data is kept consistent and meaningful. UNIQUE Constraints Ensures that every row contains a different value NOT NULL Constraints Ensures that there are no nulls in that column PRIMARY KEY Constraints Combination of Unique and Not Null constraint Referential Integrity Constraints Lecture13

4.Constraints Referential Integrity Constraints Main type of data validation within relational database Ensures relationships are maintained between the data in one table with data in another table Performed when data is being changed Performed during Insert, Update and Delete Statements will fail if Referential Integrity is not maintained For examples: Case 1: add a new row to the child table Case 2: update/delete an existing row Lecture13

4.Constraints Case 1 Parent table: customer, child table: order In the Data Table(child), a value can always be Deleted or set to null, but any new value must pass validation For example: Insert a new order for a new customer: 20001, AXETH (Axen Thomas), 07-12-2017 Solution: Add “Axen Thomas” into the Customer table FIRST Then, add the new order to the Order table CustomerID FirstName LastName ALFKI Maria Anders Alfreds Futterkiste ANATR Ana Trujillo Ana Trujillo ... Foreign Key OrderID CustomerID OrderDate 10248 WILMK 04-Jul-1996 10249 TRADH 05-Jul-1996 Primary Key Lecture13

There is an order made by WILMK in the order table 4.Constraints Case 2 In the List of Valid Values in the parent table, a new valid value can always be added, but a value can only be deleted if it is not used at all in the Data Table. For example: Remove WILMK from the customer table Solution: Use the RI options to “Cascade” All the ROWS of the Data Table are DELETED if they were using the value that is being deleted There is an order made by WILMK in the order table CustomerID FirstName LastName ALFKI Maria Anders Alfreds Futterkiste ANATR Ana Trujillo Ana Trujillo ... Foreign Key OrderID CustomerID OrderDate 10248 WILMK 04-Jul-1996 10249 TRADH 05-Jul-1996 Primary Key Lecture13