Jenny Jirathammakul High Distinction Assignment 31061 - Database Principles Autumn, 2007 Melbourne City Toyota.

Slides:



Advertisements
Similar presentations
Access 2007 ® Use Databases How can Microsoft Access 2007 help you structure your database?
Advertisements

What is a Database By: Cristian Dubon.
Candidate Keys Objectives of the Lecture : To consider Integrity Constraints; To consider the principles of Candidate Keys; To consider Candidate Keys.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
A U Database Review Professor J. Alberto Espinosa ITEC 334 Fall 2010 Online (Business) Application Development.
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,
Methodology Logical Database Design for the Relational Model
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
A Guide to MySQL 7. 2 Objectives Understand, define, and drop views Recognize the benefits of using views Use a view to update data Grant and revoke users’
Introduction to Structured Query Language (SQL)
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
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?
Transforming Data Models into Database Designs
Microsoft Access II Information Technology Services User Services User Training & Support.
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
©Silberschatz, Korth and Sudarshan6.1Database System Concepts Chapter 6: Integrity and Security Domain Constraints Referential Integrity Assertions Triggers.
Database Systems Marcus Kaiser School of Computing Science Newcastle University.
Where dream cars are found Peter Ebeid.  When you go to buy a car, you can jump in your family’s car and go to the nearest car dealership. However, like.
The 2 nd Hand Student Book Database Jon Havier High Distinction Assignment, Autumn 2007.
Chapter 9 Designing Databases Modern Systems Analysis and Design Sixth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
The Carnie_MyCareer Case Study Peter Ebeid Dane Harris Stephanie Ho Chris Zaharia Distinction Assignment, Autumn 2007 Presented by.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
SQL Server 7.0 Maintaining Referential Integrity.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
“National Electoral Division Profiles” Case Study Vincent Tang High Distinction Assignment, Autumn 2007.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
Natural vs. Generated Keys. Definitions Natural key—a key that occurs in the data, that uniquely identifies rows. AKA candidate key. Generated key—a key.
Database Management COP4540, SCS, FIU Constraints and security in SQL (Ch. 8.6, Ch22.2)
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.
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.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
CSC 240 (Blum)1 Introduction to Data Entry, Queries and Reports.
© 2002 by Prentice Hall 1 Database Processing with Microsoft Access David M. Kroenke Database Concepts 1e Appendix A.
Microsoft Access 2013 ®® Tutorial 9 Using Action Queries and Advanced Table Relationships.
Data Driven Designs 99% of enterprise applications operate on database data or at least interface databases. Most common DBMS are Microsoft SQL Server,
Database Processing with Microsoft Access Appendix DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
IBS 520 Introduction to Internet Technology Database Fundamentals Week 4.
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.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
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.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
Database Principles Autumn 2007 High Distinction Assignment REBEL Sport Online Author: Joseph Diver.
Session 1 Module 1: Introduction to Data Integrity
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
Further Consolidation Objectives of the Lecture : To use simple queries to check out a DB. To use insertions, deletions and amendments to maintain a DB.
Drill Consider the following tables with the following fields: Student: FName, LName, StudentID, Age, Yr, Course Grades: ID, P1, P2, P3 1.Display the.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
THE DATABASE OF MSY TECHNOLOGY PTY. LTD PRODUCT Ronald Diningrat High Distinction Assignment Autumn 2007.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Module 5: Implementing Data Integrity by Using Constraints
CPSC-310 Database Systems
Structured Query Language
Teaching slides Chapter 8.
אבטחת נתונים בסביבת SQL Data Security
Relational Database Design
Guide to Modeling Keys to E-R diagrams.
SQL – Constraints & Triggers
Question 1: Basic Concepts (45 %)
Guide to Modeling Keys to E-R diagrams.
Presentation transcript:

Jenny Jirathammakul High Distinction Assignment Database Principles Autumn, 2007 Melbourne City Toyota

: Melbourne City Toyota This database is based on the Melbourne City Toyota website: Allows users to search the website for New Toyotas, Used Cars or Demonstration Cars. The Cars are sorted into Car Brands that is further arranged into the Car Style to make it easier to browse through the different categories. Extras are also included, such as Accessories and Parts, with New Cars if the User wished to look through additional things for a particular car. Enquiries by Users concerning the Cars are sorted by the CarID. This is to ensure that the Users’ enquiries would be specific to the particular car.

: Melbourne City Toyota

: Entity Relationship Diagram

: One to Many Relationship – 1:M CarBrandIDCarBrandCarModelCarMakeCarBody 1ToyotaRAV4CV4WD 2ToyotaCamrySportivoSedan 6HondaAccordEXI 4WSSedan 8LexusIS200SportsSedan 11SuzukiSwiftCinoHatchback CarID CarBrandID* CarYearCarOwnTypeColourKilometresListPriceInternetPriceRegistration N NewSilver31990 U UsedLight Gold ULS948 U UsedLight Teal UPZ685 N UsedBlack33000 U UsedWhite ULJ121 Primary Key Foreign Key* This 1:M relationship shows that one Car Style has one or many cars with that style  CarBrandID 1 & 2 show this association CarStyle Car

: Many to Many Relationship – M:M CarIDCarBrandID*CarYearCarOwnTypeColourKilometresListPriceInternetPriceRegistration N NewSilver31990 U UsedLight Gold ULS948 U UsedLight Teal UPZ685 N NewBlack33000 U UsedWhite ULJ121 CarID*AccessoryID*PartsID* N N N N AccessoryIDAccessoryNameAccessoryPrice 1Safety Pack750 2Metallic Paint300 9New Camry Bootlip Spoilers550 13Leather Trim Moonroof1650 Car Extras Accessory This M:M relationship shows that many cars can have many accessories because: A Car can have many Accessories and; An Accessory can be apart of many Cars

: Simple Query of a Single Table CarBrandIDCarBrandCarModelCarMakeCarBody 6HondaAccordEXI 4WSSedan 7HondaHRVSport4WD select * from carstyle where carbrand = ‘Honda’ order by carbrandid; List all cars manufactured by Honda select accessoryname, accessoryprice from accessory where accessoryname like ‘G%’; Show all Accessory Names starting with ‘G’ AccessoryNameAccessoryPrice Genuine Toyota Park Assist595 Genuine Toyota Protection Packs180 Genuine Toyota Satellite Navagation System3500

: Query – Natural Join select enquiriesid, carid, username, carowntype, question from users natural join enquiries natural join car where carid = ‘U37975’; Show EnquiriesID, CarID, UserName, CarOwnType and Question for the car ‘U37975’ EnquiriesIDCarIDUserNameCarOwnTypeQuestion 3U37975NicoleUsed Would the car get the same kind of since as a newly bought Toyota since it has only been used for a while 1U37975TonyUsedWhat is the average Fuel consumption rate for this car

: Cross-Product Join select carid, carbrand, carmodel, carmake, caryear from car, carstyle where car.carbrandid = carstyle.carbrandid and carbody = ‘Hatchback’; Show the carid, carbrand, carmodel and carmake, caryear of all cars that are hatchbacks CarIDCarBrandCarModelCarMakeCarYear N12345SuzukiSwiftCino1998 U36892ToyotaYarisYR2007

: Group By Find out how many CarBrandIDs have registrations (that is, their registration is not null) select carbrandid, count(*) from car where registration is not null group by carbrandid; CarBrandIDCount

: Group By with Having Display car colours that have more than one car having that colour select colour, count(*) as total from car group by colour having count(*) > 1; ColourTotal Silver3 Black3 White4

: Sub-Query List the carid, carbrand, carmodel, carmake, kilometres of the car with the minimum amount of kilometres driven that was manufactured before the year 2000 select carid, carbrand, carmodel, carmake, kilometres from car natural join carstyle where caryear < 2000 and kilometres <= (select min(kilometres) from car where caryear < 2000); CarIDCarBrandCarModelCarMakeKilometres U38412SuzukiSwiftCino95876

: Self-Join List the CarID of cars that have the same colour ‘Black’ select c1.colour, c2.carid from car c1, car c2 where c1.carid = ‘U38523’ and c1.colour = c2.colour; ColourCarID BlackN24689 BlackU38523 BlackU37947

: Data Integrity – CHECK Statements These CHECK statements make sure that the values entered into the INSERT statements do not breach the restrictions placed upon them CONSTRAINTCHECK CONSTRAINT Car_Year CHECK ((CarYear > 1900) AND (CarYear <= 2007)), CONSTRAINTCHECK CONSTRAINT Car_ListPrice CHECK (ListPrice > 0), CONSTRAINTCHECK CONSTRAINT Car_InternetPrice CHECK ((InternetPrice > 0) OR (InternetPrice IS NULL)) This CHECK statements make sure that the values entered into the INSERT statements include only these types of values, that is, the only values that can be entered into Car Brand are only those types of car brands to ensure that misspellings do not occur CONSTRAINTCHECK CONSTRAINT CarStyle_Brand CHECK (CarBrand IN ( 'Alfa Romeo','Audi','BMW','Chrysler','Citroen', 'Daewoo','Daihatsu','Ford','Holden','Honda', 'Hyundai','Isuzu','Jeep','Land Rover','Lexus', 'Mazda','Mercedes-Benz','Mitsubishi','Nissan', 'Peugeot','Proton','Renault','Saab','Smart', 'Subaru','Suzuki','Toyota','Volkswagen','Volvo')) Check Statements prevents the SQL from creating data that does not conform to the guidelines that have been put into place and an error would thus occur because of a breach of the contraints

: Action Statements – ON DELETE RESTRICT “ON DELETE RESTRICT” prevents the deletion of data that is being used by other categories in another table These Restrictions prevent the deletion of AccessoryIDs and PartsIDs if they are currently being used by other categories in another table CONSTRAINT ExtrasFK_aid FOREIGN KEY (AccessoryID) REFERENCES Accessory (AccessoryID) ON DELETE RESTRICT ON UPDATE CASCADE, CONSTRAINT ExtrasFK_pid FOREIGN KEY (PartsID) REFERENCES Parts (PartsID) ON DELETE RESTRICT ON UPDATE CASCADE

: Action Statements – ON DELETE CASCADE “ON DELETE CASCADE” allows data to be deleted from a table that will delete itself in another table as well This deletion of CarID in a table will also be deleted in the extras table also CONSTRAINT ExtrasFK_cid FOREIGN KEY (CarID) REFERENCES Car (CarID) ON DELETE CASCADE ON UPDATE CASCADE,

: Creating a View create view specs (carid, year, brand, model, make, kms, owntype, rego) as select carid, caryear, carbrand, carmodel, carmake, kilometres, carowntype, registration from car, carstyle where car.carbrandid = carstyle.carbrandid and carbody = ‘4WD’; Create a view that shows the car style, year, kilometres, ownership type and registration of 4WDs select * from specs; CarIDYearBrandModelMakeKmsOwnTypeRego N ToyotaRAV4CVNew U FordTerritoryTS47088UsedSZS937 U HondaHRVSport123000UsedPUR303 U ToyotaRAV4CV75324UsedULS948 U ToyotaRAV4CV7499UsedUPZ685

: Querying a View select * from specs where brand <>‘Toyota’; Show all 4WDs that are not Toyota from the created view ‘specs’ CarIDYearBrandModelMakeKmsOwnTypeRego U FordTerritoryTS47088UsedSZS937 U HondaHRVSport123000UsedPUR303