“National Electoral Division Profiles” Case Study Vincent Tang High Distinction Assignment, Autumn 2007.

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

© Abdou Illia MIS Spring 2014
Chapter 4 Joining Multiple Tables
Database design by Sarah Huynh.
Australian Electoral Commission Database By: Jason Murphy.
Australia BY ALEX MARCHESE. The capital city of Australia is ACT.
Click on a State or Territory. Click on the house to exit.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Introduction to Structured Query Language (SQL)
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
Database – Part 2a Dr. V.T. Raja Oregon State University.
LOGICAL DATABASE DESIGN
Helen Spiropoulos Benjamin Mills Nicoleta Bikrogiannis Jessica El-chaar.
The ZhangLamHoyts Case Study De Wen Zhong Vincent Tang Distinction Assignment, Autumn 2007.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
The 2 nd Hand Student Book Database Jon Havier High Distinction Assignment, Autumn 2007.
By Sean Boange.  This Database is modelled on the Computer Hardware Store MSY At current they display the numerous products they sell.
The Carnie_MyCareer Case Study Peter Ebeid Dane Harris Stephanie Ho Chris Zaharia Distinction Assignment, Autumn 2007 Presented by.
Component 4/Unit 6f Topic VI: Create simple querying statements for the database The SELECT statement Clauses Functions Joins Subqueries Data manipulation.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
STA TRAVEL AUSTRALIA Rumana Islam HD Assignment 3, Autumn 2007.
ITBIS373 Database Development
SQL Server 7.0 Maintaining Referential Integrity.
CSC271 Database Systems Lecture # 12. Summary: Previous Lecture  Row selection using WHERE clause  WHERE clause and search conditions  Sorting results.
ПРЕЗЕНТАЦИЯ «Добро пожаловать в Австралию!» выполнена учителем МОУ лицея №10 г.Волгограда Апраксиной Л.А Волгоград, 2011г.
SQL: Data Manipulation Presented by Mary Choi For CS157B Dr. Sin Min Lee.
INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS Dr. Adam P. Anthony.
Using Special Operators (LIKE and IN)
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
11 Copyright © Oracle Corporation, All rights reserved. Creating Views.
SQL Data Manipulation II Chapter 5 CIS 458 Sungchul Hong.
SQL for Data Retrieval. Review Questions of Previous Class Q1. Show the sum of hours worked for project with ID 1200 (use ASSIGNMENT table) – Use “SUM”
M1G Introduction to Database Development 5. Doing more with queries.
Recap of SQL Lab no 8 Advance Database Management System.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Soompi Music By: Karen Sin. Introduction to Soompi Music This database models from the various artists and group data gathered from the Korean based English.
Moshtix Case Study High Distinction assignment By Annie Tran.
Netball case study Harryanto Surjani. domain Team names Team locations – where they’re based Game venues – Venue name and what the stadium is called Draw.
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
UTS DATABASE Chris Zaharia.
Australia By Elizabeth & Sammy-Jo
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
Food Waste. Cost of household food waste in Australia and New Zealand Cost of food waste per HH Cost of food waste per person Average HH size NSW $
By Jayden Leonard. (Sir) Edmund Barton to Nickname –Tosspot Toby Term – Electorate- NSW Sydney southern suburbs.
Database Principles Autumn 2007 High Distinction Assignment REBEL Sport Online Author: Joseph Diver.
1 MySQL and SQL. 2 Topics  Introducing Relational Databases  Terminology  Managing Databases MySQL and SQL.
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 6 This material was developed by Oregon Health & Science.
Jenny Jirathammakul High Distinction Assignment Database Principles Autumn, 2007 Melbourne City Toyota.
Capital Cities of Australia. Adelaide Capital of South Australia. A pretty and industrial city. Population of about 1,100,000.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Databases Introduction - concepts. Concepts of Relational Databases.
Lab week 10 Aggregates and sub-queries And assignment details.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
1 All Powder Board and Ski SQL Server Workbook Chapter 5: Advanced Queries Jerry Post Copyright © 2003.
Insurance is an investment and protection plan which takes care of you in your difficult times. The various policies offered by such companies cater to.
Squash Australia Sporting Schools Initiative (SSI) Identifying, informing, developing and implementing to achieve the ASC’s and Squash Australia’s participation.
THE DATABASE OF MSY TECHNOLOGY PTY. LTD PRODUCT Ronald Diningrat High Distinction Assignment Autumn 2007.
The Booktopia Database
The Dance Fever Case Study
CSC 453 Database Systems Lecture
Contents Preface I Introduction Lesson Objectives I-2
Presentation transcript:

“National Electoral Division Profiles” Case Study Vincent Tang High Distinction Assignment, Autumn 2007

Introduction to National Electoral Division Profiles The database refers to the website: pdf pdf ► Holds information about 14 National/Federal Electoral Divisions ► The current/previous members of those divisions ► First Name ► Surname ► Parties the members belong too ► The length of period they are members ’ of the division ► Year Started ► Year Ended ► Contact Details for the State Head Office

ERD

One to Many Relationship – 1:m divisionname| state| size | firstelection| demographic …………………….. | ….. | ….| ……….| …. Prospect| NSW | 159| 1968| Inner Metro Reid | NSW | 62| 1922| Inner Metro Calare | NSW | 21621| 1906| Rural stateabv|buildingno| street | suburb | postcode| areacode| phoneno | faxno NSW | 24| Campbell Street | Sydney | 2000| 2| | VIC | 2| Lonsdale Street | Melbourne| 3000| 3| | QLD | 488| Queen Street | Brisbane | 4000| 7| | WA | 111| St Georges Terrace | Perth | 6848| 8| | SA | 1| King William Street | Adelaide | 5000| 8| | TAS | 86| Collins Street | Hobart | 7000| 3| | NT | 80| Mitchell Street | Darwin | 800| 8| | ACT | | Queen Victoria Terrace| Parkes | 2600| 2| | (8 rows) Division Table StateOffice Table Primary Key Foreign Key State in Division Table is Foreign Key in StateOffice Table

Many to Many Relationship – m:m memid | memfirstname | memsurname | C | Bowen 2 | J | Crosio 3 | R E | Klugman 8 | C | Pearce 9 | PE | Nugent 10 | J | Saunderson 11 | P | Andren memid*| partyabv* | ALP 2 | ALP 3 | ALP 8 | LP 9 | LP 10 | ALP 11 | IND partyabv | partyname ALP |Australian Labor Party IND |Independent LP |Liberal Party of Australia (formed in 1946) Member Table Memberships Table PartName Table

Query: Simple Display Divisions that belong to NSW divisionname | state | size | firstelection | demographic Prospect | NSW | 159 | 1968 | Inner Metro Reid | NSW | 62 | 1922 | Inner Metro Calare | NSW | | 1906 | Rural (3 rows) select * from division where state='NSW';

Query: Natural Join memid | memfirstname | memsurname | partyabv | C | Bowen | ALP 2 | J | Crosio | ALP 3 | R E | Klugman | ALP 4 | L | Ferguson | ALP 5 | T | Uren | ALP 6 | C A | Morgan | ALP 7 | J T | Lang | LANG LAB 8 | C | Pearce | LP 9 | PE | Nugent | LP 10 | J | Saunderson | ALP 11 | P | Andren | IND 12 | D W | Simmons | ALP 13 | A J | MacKenzie | NCP 13 | A J | MacKenzie | NP select * from member natural join memberships; Display everything in both member table and membership table (natural join): - shows the members name and the party they belong in

Query: Cross Product memid | memfirstname | memsurname | memid | partyabv | C | Bowen | 1 | ALP 2 | J | Crosio | 2 | ALP 3 | R E | Klugman | 3 | ALP 4 | L | Ferguson | 4 | ALP 5 | T | Uren | 5 | ALP 6 | C A | Morgan | 6 | ALP 7 | J T | Lang | 7 | LANG LAB 8 | C | Pearce | 8 | LP 9 | PE | Nugent | 9 | LP 10 | J | Saunderson | 10 | ALP 11 | P | Andren | 11 | IND 12 | D W | Simmons | 12 | ALP 13 | A J | MacKenzie | 13 | NCP 13 | A J | MacKenzie | 13 | NP select * from member, memberships where member.memid = memberships.memid; Display everything in both member table and membership table (cross-product): - shows the members name and the party they belong in

Query: Group By state | total TAS | 1 NT | 1 ACT | 1 SA | 1 VIC | 3 WA | 1 QLD | 3 NSW | 3 (8 rows) select state, count(*) as total from division group by state; Determine the total amount of divisions in the each state

Query: Group By & Having state | total VIC | 3 QLD | 3 NSW | 3 (3 rows) select state, count(*) as total from division group by state having count(*) >2; Determine the states with more than 2 divisions

Query: Sub-Query memfirstname | memsurname | divisionname | length J | Crosio | Prospect | 14 T | Uren | Reid | 32 PE | Nugent | Aston | 11 D W | Simmons | Calare | 13 J A | England | Calare | 15 Dr A C | Theophanous | Calwell | 17 R F | Shipton | Higgins | 15 H E | Holt | Higgins | 18 B C | Humphreys | Griffith | 19 D M | Cameron | Griffith | 11 E E | Darling | Lilley | 13 W | Truss | Wide Bay | 16 B P | Hansen | Wide Bay | 13 N | Andrew | Wakefield | 21 D | Williams | Tangney | 11 (15 rows) select memfirstname, memsurname, divisionname, yrend-yrstart as length from member natural join period where yrend-yrstart> (select avg(yrend-yrstart) from period); Display previous members who we’re members for a division greater then the average length

Query: Self Join divisionname | demographic Prospect | Inner Metro Reid | Inner Metro Higgins | Inner Metro Griffith | Inner Metro Lilley | Inner Metro Tangney | Inner Metro Solomon | Inner Metro Denison | Inner Metro Canberra | Inner Metro (9 rows) SELECT d2.divisionname, d2.demographic FROM division d1, division d2 WHERE d1.divisionname = 'Lilley' AND d1.demographic = d2.demographic; Show divisions which are considered the same demographic as Lilley

Action Statement: “CHECK” CREATE TABLE Period ( MemIDINTEGER, YrStartINTEGER NOT NULL, YrEndINTEGER, DivisionNameTEXT, ………………, ………………………, CONSTRAINT di_Period_YrStart CHECK ((YrStart >= 1900) AND (YrStart <= 2500)), ………… ); Output – When constraint is violated INSERT INTO Period VALUES (37,1880,null,'Denison'); ERROR: new row for relation "period" violates check constraint "di_period_yrstart"

“CHECK” Constraints CREATE TABLE Division ( DivisionNameTEXT, StateVarchar(3), SizeINTEGERNOT NULL, FirstElectionINTEGER, DemographicTEXT NOT NULL, …………………, ……………………, CONSTRAINT di_Division_Demographic CHECK (Demographic IN ('Inner Metro', 'Outer Metro', 'Provincial', 'Rural')) ); Output – When constraint is violated INSERT INTO Division VALUES ('Canberra','ACT',1900,1974, ‘Inner'); ERROR: new row for relation "division" violates check constraint "di_division_demographic"

Action Statement: “ON DELETE RESTRICT” To prevent delete in Member Table without deleting data from Memberships Table first CREATE TABLE Memberships (MemIDINTEGER NOT NULL, PartyAbvTEXT, CONSTRAINT MSPK PRIMARY KEY (MemID, PartyAbv), CONSTRAINT MS_MemIdFK FOREIGN KEY (MemID) REFERENCES Member ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT MS_PartyFK FOREIGN KEY (PartyAbv) REFERENCES PartyName ON DELETE RESTRICT ON UPDATE CASCADE); DELETE FROM Member WHERE MemId = 1; ERROR: update or delete on "member" violates foreign key constraint "ms_memidfk" on "memberships" Output – When constraint is violated

Creating a “VIEW” To create a view containing the previous/current members of the division ‘Prospect’ CREATE VIEW Prospect (Id, Surname, FirstName, Start) AS SELECT memid, memsurname, memfirstname, yrstart FROM member natural join period WHERE divisionname = 'Prospect'; id | surname | firstname | start | Bowen | C | | Crosio | J | | Klugman | R E | 1969 (3 rows) select * from Prospect;

Query a “View” id | surname | firstname | start | Bowen | C | | Crosio | J | 1990 (2 rows) select * from prospect where start > 1980; To search the view table ‘Prospect’ for members who started after 1980