UTS DATABASE Chris Zaharia.

Slides:



Advertisements
Similar presentations
Relational data integrity
Advertisements

COMP 3715 Spring 05. Working with data in a DBMS Any database system must allow user to  Define data Relations Attributes Constraints  Manipulate data.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Accounting System Design
Chapter 2 The Relational Database Model
1 Review #1 l Intro stuff –What is a database, 4 parts, 3 users, etc. l Architecture –Data independence –Three levels, two mappings –Jobs of the DBA.
Entity-Relationship Model and Diagrams (continued)
3-1 Chapter 3 Data and Knowledge Management
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Accounting Databases Chapter 2 The Crossroads of Accounting & IT
Mapping of N:M Relationships PERSON-ID TITLE PERSON-NAME DATE-OF-BIRTH PERSON-ID PROJECT-ID HOURS-SPENT PROJECT-ID END-DATE START-DATE E-R Diagram PERSON.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
CSEN 5314 Quiz 3.
Entity PrimaryKey Attribute relationship Cardinality: zero to many Cardinality: one and only one Cardinality: one to many Explanation Entity Relationship.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
Computer Science & Engineering 2111 Introduction to Database Management Systems Relationships and Database Creation 1 CSE 2111 Introduction to Database.
 An entity-relationship (ER) diagram is a specialized graphic that illustrates the interrelationships between entities in a database.  An Entity Relationship.
Tomslist Boston University Craigslist Ben Duong, Frank Wong, Marc Adam, Henry Huang.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
Relational databases.  Retrieving data from a database requires pulling data from multiple tables  Tables relate to each other in distinct ways, modelled.
PHASE 3: SYSTEMS DESIGN Chapter 7 Data Design.
Microsoft Access Lesson 3
Database Design Concepts
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
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,
The 2 nd Hand Student Book Database Jon Havier High Distinction Assignment, Autumn 2007.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
DATABASES Pindaro Demertzoglou – Lally School of Management and Technology.
The Carnie_MyCareer Case Study Peter Ebeid Dane Harris Stephanie Ho Chris Zaharia Distinction Assignment, Autumn 2007 Presented by.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
1 CSE 480: Database Systems Lecture 5: Relational Data Model.
PLUG IT IN 3 Fundamentals of Relational Database Operations.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 9 – Building Links,
Fundamentals of Relational Database Operations
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
IST 220 Introduction to Databases Course Wrap-up.
Exploring Microsoft Access Chapter 6 Many-to-Many Relationships: A More Complex System.
Microsoft Access 2013 ®® Tutorial 9 Using Action Queries and Advanced Table Relationships.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Database revision.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Rebecca McCready Faculty of Medical Sciences Newcastle University Lecture 2 – Relationships and Lookup fields.
Jozef Kuper.  Describe a Database  Entities  Atributes  Relationships.
ENTITY RELATIONSHIP DIAGRAM ENTITY RELATIONSHIP DIAGRAM IS A SPECIALIZED GRAPHIC THAT ILLUSTRATES THE INTERRELATIONSHIPS BETWEEN ENTITIES IN A DATABASE.
Exam 1 Review: ERDs, Schemas, SQL Out Describe Elements of an ERD Create Schema from ERD Notes: Associative Entities.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Database Principles Autumn 2007 High Distinction Assignment REBEL Sport Online Author: Joseph Diver.
Entity-Relationship Diagram Presentation Gianna-lee Williams 6AQ Ms. Anderson.
Relational Database in Access Student System As always please use speaker notes!
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
Class11 Introduction to relational databases and MySQL MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University.
Jenny Jirathammakul High Distinction Assignment Database Principles Autumn, 2007 Melbourne City Toyota.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Hoi Le. Why database? Spreadsheet is not good to: Store very large information Efficiently update data Use in multi-user mode Hoi Le2.
Information System Design “Student Registration System Example”
Lecture 5 Data Model Design Jeffery S. Horsburgh Hydroinformatics Fall 2012 This work was funded by National Science Foundation Grant EPS
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
THE DATABASE OF MSY TECHNOLOGY PTY. LTD PRODUCT Ronald Diningrat High Distinction Assignment Autumn 2007.
DBM 380 AID Focus Dreams/dbm380aid.com
DBM 380 aid Perfect Education/dbm380aid.com
DBM 380 aid Education Begins/dbm380aid.com
אבטחת נתונים בסביבת SQL Data Security
Review #1 Intro stuff What is a database, 4 parts, 3 users, etc.
Database 2.
Presentation transcript:

UTS DATABASE Chris Zaharia

The Domain – UTS

The Domain – UTS Based on the UTS Database that contains information on courses and subjects Focuses especially on categorising courses under structures which contain subjects i.e. A course can have core, major etc structures that have a number of subjects in each structure category http://www.uts.edu.au

Entity Relationship Diagram Course Course CourseID CourseName CourseDesc CourseGrad CourseAward CourseAward2 CRICOSCode CommSupport LoadCP CourseEFTSL FacResp FacColl Location Subject Subject SubjectID SubjectName SubjectDesc SubjectGrad CP Faculty SubjectEFTSL * CourseUACCode CourseUACCode UACNumber CourseID * UACType SubjectRequisite SubjectID * ReqSubject * SubjectRequisite SubjectStructureChoice SubjectID * StructureChoiceID * SubjectStructureChoice CourseStructureChoice CourseStructureChoice StructureID * StructureChoiceID * SubjectChoice StructureChoice StructureChoiceID StructureChoiceName CourseStructure CourseStructure CourseID * StructureID * StructureCP Structure Structure StructuretID StructureType SubjectFee SubjectFee SubjectEFTSL FeeComPrice FeeDomPrice SubjectStructure SubjectStructure SubjectID * StructureID *

One-to-many Relationship SubjectID SubjectName Subject EFTSL 22107 Accounting for Business 0.125 31257 Information System Development Methodologies 31271 Database Fundamentals 70113 Legal Process and History 0.208 SubjectEFTSL FeeComPrice FeeDomPrice 0.083 694.42 1648 0.125 889.75 2280 0.208 1736.04 4120 0.25 1779.5 4920 Table 1 - SubjectFee Table 1 - Subject Primary Key Primary Key Foreign Key Both tables have a one-to-many relationship Linked by a foreign key

One-to-many Relationship ERD Subject SubjectID SubjectName SubjectDesc SubjectGrad CP Faculty SubjectEFTSL * SubjectFee SubjectEFTSL FeeComPrice FeeDomPrice Has

Many-to-many Relationship Primary Key SubjectID SubjectName 31270 Networking Essentials 31271 Database Fundamentals 31280 Strategic IT Project StructureID StructureType CBK90781 Major CBK90782 Major/Two Submajors/Electives STM90651 Core Foreign Key Table 1 - Subject Table 2 - Structure Table 3 - SubjectStructure Primary Key SubjectID StructureID 31270 STM90651 31271 31280 CBK90781 CBK90782 Foreign Key Both one-to-many paired Relationships (T1,T3; T2,T3) Creates a many-to-many relationship Table 1 and Table 2 Primary keys are foreign Keys in table 3 Primary Key

Many-to-many Relationship ERD Subject SubjectID SubjectName SubjectDesc SubjectGrad CP Faculty SubjectEFTSL * Structure StructuretID StructureType SubjectStructure SubjectID * StructureID * Part of Contains

Queries 1. Show all undergraduate courses. SELECT courseID, courseName, courseGrad FROM Zaharia_UTS_Course WHERE courseGrad = 'Undergraduate'; CourseID CourseName CourseGrad C10026 Bachelor of Business Undergraduate C10148 Bachelor of Science in Information Technology C10219 Bachelor of Business Bachelor of Science in Information Technology

Queries 2. Show all subjects with requisites and display their requisites. SELECT subjectID, subjectName, reqSubject FROM Zaharia_UTS_Subject NATURAL JOIN Zaharia_UTS_SubjectRequisite; SubjectID SubjectName ReqSubject 22320 Accounting for Business Combinations 22107 31257 Information System Development Methodologies 31270 31269 Business Requirements Modelling 31266 31272 Project Management and the Professional 31280 Strategic IT Project 31276

Queries 3. Show subjects along with their structure types. SELECT SubjectID, Zaharia_UTS_Structure.StructureID, StructureType FROM Zaharia_UTS_Structure, Zaharia_UTS_SubjectStructure WHERE Zaharia_UTS_Structure.StructureID = Zaharia_UTS_SubjectStructure.StructureID;

Queries SubjectID StructureID StructureType 22107 STM90273 Core 22320 CBK90169 Major CBK90170 Major/Two Submajors/Submajor + Four Electives 31257 CBK90781 CBK90782 Major/Two Submajors/Electives 31266 STM90651 31269 31270 31271 31272 31276 31280 70113

Queries 4. Show the average of the Commonwealth and Domestic fee price for each subject whose fee average is over $5000 SELECT subjectID, avg(FeeComPrice + FeeDomPrice) AS Average_SubjectPrice FROM Zaharia_UTS_SubjectFee NATURAL JOIN Zaharia_UTS_Subject GROUP BY subjectID HAVING avg(FeeComPrice + FeeDomPrice) > 5000; SubjectID Average_SubjectPrice 70113 5856.04

Queries 5. Show all core subjects that are newer then the very first core subject. SELECT subjectID FROM Zaharia_UTS_SubjectStructure NATURAL JOIN Zaharia_UTS_Structure WHERE structureType = 'Core' AND subjectID > ( SELECT min(subjectID) FROM Zaharia_UTS_SubjectStructure ); SubjectID 31266 31269 31270 31271 31272 SELECT subjectID FROM Zaharia_UTS_SubjectStructure NATURAL JOIN Zaharia_UTS_Structure WHERE structureType = 'Core' and subjectID > ( SELECT min(subjectID) FROM Zaharia_UTS_SubjectStructure );

Queries 6. Show all courses that share the same graduation status as course C10219 (BBus BScIT). SELECT c1.courseID FROM Zaharia_UTS_Course c1, Zaharia_UTS_Course C2 WHERE c1.courseGrad = c2.courseGrad AND c2.courseID = 'C10219' AND c1.courseID <> 'C10219'; CourseID C10026 C10148

CHECK Constraint Examples Check for graduation status CONSTRAINT Zaharia_UTS_Course_CourseGrad CHECK (CourseGrad IN ( 'Undergraduate', 'Postgraduate')), Check value of Course EFTSL CONSTRAINT Zaharia_UTS_Course_CourseEFTSL CHECK (CourseEFTSL BETWEEN 0.5 AND 7)

CHECK Constraint Examples Check for Faculty Responsible CONSTRAINT Zaharia_UTS_Course_FacResp CHECK (FacResp IN ( 'Business', 'Design, Architecture and Building', 'Education', 'Engineering', 'Humanities', 'Information Technology', 'Law', 'Nursing, Midwifery & Health', 'Science')),

SQL Actions Examples On Delete Cascade CONSTRAINT Zaharia_UTS_CourseUACCode_CourseIDFK FOREIGN KEY (CourseID) REFERENCES Zaharia_UTS_Course ON DELETE CASCADE ON UPDATE CASCADE

SQL Actions Examples For example if we would delete a Course from the Course table: DELETE FROM Zaharia_UTS_Course WHERE CourseID = 'C10026'; This would also delete the Course’s UAC code details from the CourseUACCode table, and we can see this after: SELECT * FROM Zaharia_UTS_CourseUACCode; No C10026 ! UACNumber CourseID UACType 605002 C10219 CSP 615002 DFEE 942600 C01457 Autumn semester 945600 Spring semester

SQL Actions Examples (2) On Delete Restrict CONSTRAINT Zaharia_UTS_Subject_SubjectEFTSLFK FOREIGN KEY (SubjectEFTSL) REFERENCES Zaharia_UTS_SubjectFee ON DELETE RESTRICT ON UPDATE CASCADE

SQL Actions Examples (2) For example if we try to delete a subject’s EFTSL from the SubjectFee table: DELETE FROM Zaharia_UTS_SubjectFee WHERE SubjectEFTSL = 0.125; We get the error: update or delete on "zaharia_uts_subjectfee" violates foreign key constraint "zaharia_uts_subject_subjecteftslfk" on "zaharia_uts_subject“ Since the foreign key SubjectEFTSL in the Subject table is restricted from deleting data in the Subject table that shares the value SubjectEFTSL = 0.125

Creating a View Example CREATE VIEW Zaharia_UTS_CoursePrice (CourseID, CourseName, CourseCP, CoursePriceCom, CoursePriceDom) AS SELECT CourseID, CourseName, LoadCP, CourseEFTSL * 7118, CourseEFTSL * 18240 FROM Zaharia_UTS_Course;

Creating a View Example Query view as if a table: Show the subject prices for the subject Database Fundamentals in the BBus BScIT course SELECT SubjectID, ((CoursePriceCom / CourseCP) * CP) AS SubjectComPrice, ((CoursePriceDom / CourseCP) * CP) AS SubjectDomPrice FROM Zaharia_UTS_Subject, Zaharia_UTS_CoursePrice WHERE SubjectName = 'Database Fundamentals' AND CourseName = 'Bachelor of Business Bachelor of Science in Information Technology'; SubjectID SubjectComPrice SubjectDomPrice 31271 889.75 2280

END