Database Management Systems,



Similar documents
Data Modeling. Database Systems: The Complete Book Ch ,

Databases and BigData

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

There are five fields or columns, with names and types as shown above.

Lecture 6. SQL, Logical DB Design

Database Design. Goal: specification of database schema Methodology: E-R Model is viewed as a set of

Module Contact: Dr. Beatriz de la Iglesia, CMP Copyright of the University of East Anglia Version 1

Designing a Database Schema

How to set up a database in Microsoft Access

Ken Goldberg Database Lab Notes. There are three types of relationships: One-to-One (1:1) One-to-Many (1:N) Many-to-Many (M:N).

2.5.3 Use basic database skills to enter information in a database

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

A basic create statement for a simple student table would look like the following.

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

Database Management Systems [COP5725] Project Deliverable 2. SaferDC. Submitted By: Group 1

Information Systems SQL. Nikolaj Popov

Topic: Relationships in ER Diagram and Relationships in MS Access

Access Creating Databases - Fundamentals

Exercise 1: Relational Model

>

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

model license person owns car report-number participated damage-amount E-R diagram for a Car-insurance company.

CS 338 Join, Aggregate and Group SQL Queries

Entity - Relationship Modelling

SQL Tables, Keys, Views, Indexes

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3

EECS 647: Introduction to Database Systems

Conceptual Design Using the Entity-Relationship (ER) Model

SAIL Person-level Export File Structure & Data Transfer

RelayClinical Service Feature Guide RelayClinical Notify

Instructions to register for an NFP and MSP fellowship

SQL Programming. CS145 Lecture Notes #10. Motivation. Oracle PL/SQL. Basics. Example schema:

Databases What the Specification Says

SAIL Person-level Export File Structure & Data Transfer

Intro to Databases. ACM Webmonkeys 2011

IT2304: Database Systems 1 (DBS 1)

Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization

Introduction to SQL for Data Scientists

IT2305 Database Systems I (Compulsory)

SQL NULL s, Constraints, Triggers

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

A Brief Introduction to MySQL

Object-Based Databases

Websense SQL Queries. David Buyer June 2009

Online shopping cart. Tarik Guelzim Graduate school of computer science at Monmouth University. CS517 Database management systems Project 2

Chapter 9 Java and SQL. Wang Yang wyang@njnet.edu.cn

Enterprise Data Management Data Standard Person Core Matching Attributes Data Dictionary 10/13/2011

DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

Part III: On your marks... get set... go!

Software Requirements Specification for DLS SYSTEM

DENTIST PROJECT. Final Report of Development By Team 12

SQL. Short introduction

A Rational Software Whitepaper

E-R Method Applied to Design the Teacher Information Management System s Database Model

Boats bid bname color 101 Interlake blue 102 Interlake red 103 Clipper green 104 Marine red. Figure 1: Instances of Sailors, Boats and Reserves

Microsoft Access XP Beginners: Exercises

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

SQL Server Table Design - Best Practices

Introduction to Databases

SQL Server 2008 Core Skills. Gary Young 2011

Data Modelling and E-R Diagrams

Blueberry In-Patient Management System BIMS. Developing Innovative Software Solutions For The Healthcare Sector

CSI 2132 Lab 3. Outline 09/02/2012. More on SQL. Destroying and Altering Relations. Exercise: DROP TABLE ALTER TABLE SELECT

Database Administration with MySQL

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

IT3 Database Questions

Clinic Management System

Doing database design with MySQL

Information Technology

TECHNICAL UNIVERSITY OF CRETE DATA STRUCTURES FILE STRUCTURES

In-Memory Database: Query Optimisation. S S Kausik ( ) Aamod Kore ( ) Mehul Goyal ( ) Nisheeth Lahoti ( )

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Proposed solutions Project Assignment #1 (SQL)

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

Review: Participation Constraints

Fundamentals of Database Design

Part II: Let's get real

ACROD Parking Program - Application Form

CSCI315 Database Design and Implementation

Using SQL Server Management Studio

Using Temporary Tables to Improve Performance for SQL Data Services

In This Lecture. Security and Integrity. Database Security. DBMS Security Support. Privileges in SQL. Permissions and Privilege.

Office of Court Administration Automated Registry (AR) Interface Design Document for DSHS - Clinical Management for Behavioral Health Services (CMBHS)

Normalisation 1. Chapter 4.1 V4.0. Napier University

Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model

Welcome to the Data Analytics Toolkit PowerPoint presentation on EHR architecture and meaningful use.

Requirements for Admission (DBA)

Transcription:

Database Management Systems Database Design Example 1

Topics Hospital Database E-R Design Entities Relationships Converting E-R Model to Relational Model Tables Queries Company Database Summary 2

Hospital Database (1) The database for a hospital or a clinic. It contains information about people who have been admitted at least once in the hospital. A person can be admitted several times to the same or different wards. People are identified by a Code. The database should describes all the hospital s wards, showing for each ward the name and the respective consultant. 3

Hospital Database (2) The database should contains information about all doctors in the hospital, giving their surnames, first names, wards, and so on. For each patient the given treatment at any date is stored in the database. 4

Entities: Patient Doctor Ward E-R Model Relationships: A doctor works in a ward A patient is admitted to a ward at a given date. A doctor gives a treatment to a patient at a given date. A ward has a consultant who is a doctor 5

Patient Entity and its Attributes A patient is identified by a Patient Code. The attributes are: PatientCode Name Surname Date of Birth Place of Birth Gender Address Phone 6

Doctor Entity and its Attributes For each doctor a code is used. The attributes are: DoctorID Name Surname Expertise Address Phone 7

Ward Entity Ward has the following attributes: WardID Name Building Phone 8

E-R Diagram of the Hospital 9

Relationships(1) Each doctor works in a ward A ward has many doctors The relationship between ward and doctor is a one to many relationship. This relationship is defined as a foreign key. 10

Relationships(2) Admission: A patient is admitted to a ward. A patient may be admitted to different wards at different dates A ward admits many patients Admission is a many to many relationship 11

Relationships(3) Treatment A doctor gives a treatment to a patient A doctor can give treatment to many patients A patient gets treatment from many doctors (at different dates) The treatment is a many to many relationship between doctor and patient. 12

Relationships(4) Each ward has a consultant who is a doctor. A doctor can be a consultant in only one ward Each ward has only one consultant The relationship is a one to one relationship 13

Relational Model for the Hospital Database The following tables are created: 1. Patient table (patientcode primary key) 2. Doctor table (doctorid primary key, wardid foreign key) 3. Ward table (wardid primary key, Consultant is foreign key to doctor table ) 14

Converting Relationships Admission is converted to a table as Admission < PatientCode, WardCode, DateAdmitted, DateDischarged > PatientCode and WardCode are foreign keys Primary Key: PatientCode+WardCode+DateAdmitted Treatment <PatientCode, DoctorID, Date, Treatment> PatientCode and DoctorID are foreign keys. Treatment is a string. Primary Key : PatientCode+DoctorID+Date 15

Some Queries The following queries are given as example: Create table for ward entity Insert data into Patient table Select all patients admitted on May 10, 2010 Select all patients treated by doctor Hasan 16

Create Ward Table Create Table Ward ( WardID char(10) Primary Key, WardName varchar, Building char(5), Phone char(13) ) 17

Insert Data into Patient Table Insert Into Patient (PatientCode,Name,Surname, DateOfBirth, PlaceOfBirth, Gender, Address,Phone ) values ( 100, Ali, Velioglu, 1980, Ankara, Male, 100 Yil, 123456 ) 18

List Patients Admitted on May 10, 2010 Select Name, Surname FROM Patient JOIN Admission ON Patient.PatientCode = Admission.PatientCode WHERE DateAdmitted = 2010-5-10 19

List Patients Treated by Doctor Hasan SELECT Patient.Name, Patient.Surname FROM Patient, Treatment, Doctor WHERE Patient.PatientCode = Treatment.PateintCode AND Treatment.DoctorID = Doctor.DoctorID AND Doctor.Name = Hasan 20

Company Example A company has several projects. Each project is carried out in a different city, has a start date, period and budget. For each project some products are needed. These products are supplied by different suppliers. 21

Entities Project: Attributes: Project Code, Project Name, Project Start Date, Project Duration, Project Budget Product: Attributes: Product Code, Product Name, Price Supplier: Attributes: Supplier ID, Supplier Name, Location, Telephone 22

Relationships A supplier SUPPLIES some products for a project A project may get products from different suppliers A supplier may supply a product for different projects There is a ternary relationship between supplier, product, and project 23

E-R Model 24

Create Table for Relationship Create table supplies ( supplycode Integer Primary key, sid Integer References supplier(id), pcode Integer References product(code), pid Integer References project(code), quantity Integer, supplydate Date ) 25

Summary Read the problem requirements very carefully Find entities and relationships Create E-R model for the database Convert E-R model to Relational model Create tables Insert data into the tables Write some queries to use the database (depends on the requirements) 26

Questions? 27