Andmebaasid. Praktikum 7 (kordamine)

Size: px
Start display at page:

Download "Andmebaasid. Praktikum 7 (kordamine)"

Transcription

1 Andmebaasid Praktikum 7 (kordamine)

2 Ülesande püstitus Luua andmebaas õppeainete ning õppimisega seotud andmete hoidmiseks ja kasutamiseks.

3 ANDMETE FÜÜSILINE MUDEL

4

5 Ülesanded Loo andmebaas nimega edu ja järgnevad tabelid oma andmebaasi CREATE TABLE Faculty( Id INTEGER NOT NULL DEFAULT AUTOINCREMENT PRIMARY KEY, Name VARCHAR(50) NOT NULL, Address VARCHAR(30), DeanId INTEGER, ViceDeanId INTEGER, UNIQUE(Name) );

6 Ülesanded CREATE TABLE Person( Id INTEGER NOT NULL DEFAULT AUTOINCREMENT PRIMARY KEY, FirstName VARCHAR(30) NOT NULL, LastName VARCHAR(30) NOT NULL, FacultyId INTEGER NOT NULL, SSN VARCHAR(11), UNIQUE(FirstName,LastName)); CREATE TABLE Registration( Id INTEGER NOT NULL DEFAULT AUTOINCREMENT PRIMARY KEY, CourseId INTEGER NOT NULL, PersonId INTEGER NOT NULL, FinalGrade VARCHAR(1));

7 Ülesanded CREATE TABLE Lecturer( Id INTEGER NOT NULL DEFAULT AUTOINCREMENT PRIMARY KEY, CoursesId INTEGER, PersonsId INTEGER NOT NULL, Responsible SMALLINT); CREATE TABLE Course( Id INTEGER NOT NULL DEFAULT AUTOINCREMENT PRIMARY KEY, FacultyId INTEGER NOT NULL, Name VARCHAR(50) NOT NULL, Code VARCHAR(20), EAP INTEGER, GradeType VARCHAR(8));

8 INPUT näited INPUT INTO Person FROM 'person.txt' FORMAT ASCII DELIMITED BY '\x09' INPUT INTO Faculty FROM 'faculty.txt' FORMAT ASCII DELIMITED BY '\x09'

9 Ülesanded Analoogselt näidetega impordi sama nimega failidest ka järgnevad tabelid: Registration Lecturer Course Failid saab alla laadida Moodle i keskkonnast.

10 FK näidis ALTER TABLE Registration ADD CONSTRAINT fk_registration_person FOREIGN KEY (PersonId) REFERENCES Person (Id) ON DELETE CASCADE ON UPDATE CASCADE; Person tabeli kirje kustutamisel kustutatakse tema registreeringud ainetele ALTER TABLE Faculty ADD CONSTRAINT fk_faculty_person_dean FOREIGN KEY (DeanId) REFERENCES Person (Id) ON DELETE SET NULL ON UPDATE CASCADE; Dekaani kirje kustutamisel ei kustutata tema teaduskonda

11 Ülesanne Luua lisaks näidetele kuus välisvõtit nii, et ülemtabeli kirje kustutamisel kustutatakse ka alamtabeli vastavad kirjed, va kahel erandjuhul, kui seos tühistatakse: Registration Course Lecturer Person Lecturer Course (tühista seos) Course Faculty Faculty (ViceDeanId) Person (tühista seos) Person Faculty

12 PÄRINGUD

13 Alampäringud Dekaanid teaduskondadest, kus oli olemas ka prodekaan: SELECT * FROM person WHERE EXISTS ( SELECT * FROM faculty WHERE faculty.deanid = person.id AND faculty.vicedeanid IS NOT NULL )

14 Mitme tabeli sidumine päringusse SELECT firstname, lastname, name, faculty.id, DeanId FROM person, faculty WHERE firstname = 'Mati' AND deanid = person.id

15 Grupeerimine Kui palju on iga EAP väärtusega aineid? SELECT eap, count(*) FROM course GROUP BY eap Kui palju on igale kursusele registreerunud inimesi? SELECT name, count(*) FROM course, registration WHERE course.id = registration.courseid GROUP BY course.name

16 Grupeerimine Kui palju on sama tähega algavaid perekonnanimesid? SELECT LEFT(lastName,1) AS pn, COUNT(*) AS arv FROM person GROUP BY pn ORDER BY arv DESC, pn ASC;

17 Mitu päringut üks tulemus Millist tähte kasutatakse enam nime alguses? Vaadelda nii pere- kui ka eesnimesid. Järjestada tulemus nime algustäht, esinemiste arv ja p või e (perenimi / eesnimi) mitte kasvavalt korduste arvu järgi. SELECT LEFT(lastName,1), COUNT(*),'p' FROM person GROUP BY LEFT(lastName,1) UNION ALL SELECT LEFT(firstName,1), COUNT(*),'e' FROM person GROUP BY LEFT(firstName,1) ORDER BY 2 DESC, 1;

18 Näited CREATE VIEW v_oigusteaduskonna_opilased AS SELECT * FROM person WHERE facultyid = 2 CREATE VIEW v_oigusteaduskonna_opilased_mini (eesnimi,perenimi) AS SELECT FirstName, LastName FROM person WHERE facultyid = 2 CREATE VIEW v_persons_faculty AS SELECT p.firstname, p.lastname, f.name as FacultyName, f.address as FacultyAddress FROM person as p JOIN faculty as f ON (p.facultyid = f.id)

19 Näited CREATE VIEW v_faculty_deans (FacultyName, DeanName, ViceDeanName) AS SELECT f.name, d.firstname+' '+d.lastname as deanname, v.firstname+' '+v.lastname as vicedeanname FROM Faculty as f JOIN Person as d ON (f.deanid = d.id) JOIN Person as v ON (f.vicedeanid = v.id) ORDER BY f.name

20 Näited Lisame uue kursuse "Sissesjuhatus informaatikasse" INSERT INTO Course VALUES (101,9,'Sissejuhatus informaatikasse', MTAT ',3,'Arvestus') Lisame kursusele samad inimesed kes osalevad kursusel Sissejuhatus ettevõtte majandusse INSERT INTO registration (CourseId,PersonId,FinalGrade) SELECT 101, p.id, NULL FROM Course as c JOIN Registration as r ON (c.id = r.courseid) JOIN Person as p ON (r.personid = p.id) WHERE c.name = 'Sissejuhatus ettevõttemajandusse'

21 Näited Kuvame mõlemal kursusel õppivad õpilased SELECT p.firstname+' '+p.lastname as PersonName, c.name as CourseName FROM Course as c JOIN Registration as r ON (r.courseid = c.id) JOIN Person as p ON (r.personid = p.id) WHERE c.id = 101 OR c.id = 75 ORDER BY PersonName

22 Ülesanded 1. Luua vaade v_persons_atleast_4eap (FirstName, LastName) õpilastest, kes õpivad Matemaatika-informaatikateaduskonna ainetel, mis annavad vähemalt 4 EAP-d 2. Luua vaade v_mosta(firstname, LastName, NrOfA) õpilastest, kes on saanud kõige rohkem A-sid Matemaatika-informaatikateaduskonna ainetest 3. Luua uus kursus "Andmebaaside teooria". Matemaatika-informaatikateaduskond, MTAT , 6EAP, Arvestus Lisada sinna kõik õpilased, kes said aines Andmebaasid A või B

23 Ülesanded 4. Luua vaade v_andmebaasideteooria õpilastest, kes õpivad ainet andmebaaside teooria. (PersonId, FirstName, LastName) 5. Luua vaade v_top20a (FirstName, LastName, nrofa) päringule TOP 20 õpilastest, kes on saanud kõige rohkem A-sid. Järjestada saadud nimekiri ka perenimede järgi. 6. Luua vaade v_top20students(firstname, LastName, AvarageGrade) päringule TOP 20 õpilastest, kelle keskmine hinne on kõige kõrgem. Järjestada saadud nimekiri ka perenimede järgi.

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

A basic create statement for a simple student table would look like the following. Creating Tables A basic create statement for a simple student table would look like the following. create table Student (SID varchar(10), FirstName varchar(30), LastName varchar(30), EmailAddress varchar(30));

More information

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

Online shopping cart. Tarik Guelzim Graduate school of computer science at Monmouth University. CS517 Database management systems Project 2 Tarik Guelzim Graduate school of computer science at Monmouth University CS517 Database management systems Project 2 Page 1 of 9 Database Schema Page 2 of 9 Table name Indexed fields reason Page 3 of 9

More information

DbSchema Tutorial with Introduction in MongoDB

DbSchema Tutorial with Introduction in MongoDB DbSchema Tutorial with Introduction in MongoDB Contents MySql vs MongoDb... 2 Connect to MongoDb... 4 Insert and Query Data... 5 A Schema for MongoDb?... 7 Relational Data Browse... 8 Virtual Relations...

More information

Recognizing PL/SQL Lexical Units. Copyright 2007, Oracle. All rights reserved.

Recognizing PL/SQL Lexical Units. Copyright 2007, Oracle. All rights reserved. What Will I Learn? In this lesson, you will learn to: List and define the different types of lexical units available in PL/SQL Describe identifiers and identify valid and invalid identifiers in PL/SQL

More information

Information Systems SQL. Nikolaj Popov

Information Systems SQL. Nikolaj Popov Information Systems SQL Nikolaj Popov Research Institute for Symbolic Computation Johannes Kepler University of Linz, Austria popov@risc.uni-linz.ac.at Outline SQL Table Creation Populating and Modifying

More information

How To Create A Table In Sql 2.5.2.2 (Ahem)

How To Create A Table In Sql 2.5.2.2 (Ahem) Database Systems Unit 5 Database Implementation: SQL Data Definition Language Learning Goals In this unit you will learn how to transfer a logical data model into a physical database, how to extend or

More information

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

There are five fields or columns, with names and types as shown above. 3 THE RELATIONAL MODEL Exercise 3.1 Define the following terms: relation schema, relational database schema, domain, attribute, attribute domain, relation instance, relation cardinality, andrelation degree.

More information

Define terms Write single and multiple table SQL queries Write noncorrelated and correlated subqueries Define and use three types of joins

Define terms Write single and multiple table SQL queries Write noncorrelated and correlated subqueries Define and use three types of joins Chapter 7 Advanced SQL 1 Define terms Objectives Write single and multiple table SQL queries Write noncorrelated and correlated subqueries Define and use three types of joins 2 Nested Queries (Subqueries)

More information

Multimedia im Netz Online Multimedia Winter semester 2015/16

Multimedia im Netz Online Multimedia Winter semester 2015/16 Multimedia im Netz Online Multimedia Winter semester 2015/16 Tutorial 04 Minor Subject Ludwig-Maximilians-Universität München Online Multimedia WS 2015/16 - Tutorial 04 (NF) - 1 Today s Agenda Repetition:

More information

Mul$media im Netz (Online Mul$media) Wintersemester 2014/15. Übung 03 (Nebenfach)

Mul$media im Netz (Online Mul$media) Wintersemester 2014/15. Übung 03 (Nebenfach) Mul$media im Netz (Online Mul$media) Wintersemester 2014/15 Übung 03 (Nebenfach) Online Mul?media WS 2014/15 - Übung 3-1 Databases and SQL Data can be stored permanently in databases There are a number

More information

CSC 443 Data Base Management Systems. Basic SQL

CSC 443 Data Base Management Systems. Basic SQL CSC 443 Data Base Management Systems Lecture 6 SQL As A Data Definition Language Basic SQL SQL language Considered one of the major reasons for the commercial success of relational databases SQL Structured

More information

SQL. Short introduction

SQL. Short introduction SQL Short introduction 1 Overview SQL, which stands for Structured Query Language, is used to communicate with a database. Through SQL one can create, manipulate, query and delete tables and contents.

More information

P_Id LastName FirstName Address City 1 Kumari Mounitha VPura Bangalore 2 Kumar Pranav Yelhanka Bangalore 3 Gubbi Sharan Hebbal Tumkur

P_Id LastName FirstName Address City 1 Kumari Mounitha VPura Bangalore 2 Kumar Pranav Yelhanka Bangalore 3 Gubbi Sharan Hebbal Tumkur SQL is a standard language for accessing and manipulating databases. What is SQL? SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National

More information

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB Outline Database concepts Conceptual Design Logical Design Communicating with the RDBMS 2 Some concepts Database: an

More information

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG)

History of SQL. Relational Database Languages. Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG) Relational Database Languages Tuple relational calculus ALPHA (Codd, 1970s) QUEL (based on ALPHA) Datalog (rule-based, like PROLOG) Domain relational calculus QBE (used in Access) History of SQL Standards:

More information

Relational Schema of Database:

Relational Schema of Database: Relational Schema of Database: DDL Commands(with an instance example used for testing the page): phpmyadmin SQL Dump version 3.4.10.1deb1 http://www.phpmyadmin.net Servidor: localhost Tiempo de generación:

More information

Database Development and Management with SQL

Database Development and Management with SQL Chapter 4 Database Development and Management with SQL Objectives Get started with SQL Create database objects with SQL Manage database objects with SQL Control database object privileges with SQL 4.1

More information

Web Application Development Using UML

Web Application Development Using UML Web Application Development Using UML Dilip Kothamasu West Chester University West Chester, PA - 19382 dk603365@wcupa.edu Zhen Jiang Department of Computer Science Information Assurance Center West Chester

More information

SQL NULL s, Constraints, Triggers

SQL NULL s, Constraints, Triggers CS145 Lecture Notes #9 SQL NULL s, Constraints, Triggers Example schema: CREATE TABLE Student (SID INTEGER PRIMARY KEY, name CHAR(30), age INTEGER, GPA FLOAT); CREATE TABLE Take (SID INTEGER, CID CHAR(10),

More information

!"# $ %& '( ! %& $ ' &)* + ! * $, $ (, ( '! -,) (# www.mysql.org!./0 *&23. mysql> select * from from clienti;

!# $ %& '( ! %& $ ' &)* + ! * $, $ (, ( '! -,) (# www.mysql.org!./0 *&23. mysql> select * from from clienti; ! "# $ %& '(! %& $ ' &)* +! * $, $ (, ( '! -,) (# www.mysql.org!./0 *&23 mysql> select * from from clienti; " "!"# $!" 1 1 5#',! INTEGER [(N)] [UNSIGNED] $ - 6$ 17 8 17 79 $ - 6: 1 79 $.;0'

More information

A Brief Introduction to MySQL

A Brief Introduction to MySQL A Brief Introduction to MySQL by Derek Schuurman Introduction to Databases A database is a structured collection of logically related data. One common type of database is the relational database, a term

More information

Logical Schema Design: The Relational Data Model

Logical Schema Design: The Relational Data Model Logical Schema Design: The Relational Data Model Basics of the Relational Model From Conceptual to Logical Schema Logical Schema Design Select data model Hierarchical data model: hierarchies of record

More information

6 CHAPTER. Relational Database Management Systems and SQL Chapter Objectives In this chapter you will learn the following:

6 CHAPTER. Relational Database Management Systems and SQL Chapter Objectives In this chapter you will learn the following: 6 CHAPTER Relational Database Management Systems and SQL Chapter Objectives In this chapter you will learn the following: The history of relational database systems and SQL How the three-level architecture

More information

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25)

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) Which three statements inserts a row into the table? A. INSERT INTO employees

More information

Introduction to SQL and database objects

Introduction to SQL and database objects Introduction to SQL and database objects IBM Information Management Cloud Computing Center of Competence IBM Canada Labs 1 2011 IBM Corporation Agenda Overview Database objects SQL introduction The SELECT

More information

Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA)

Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA) 13 November 2007 22:30 Extracting META information from Interbase/Firebird SQL (INFORMATION_SCHEMA) By: http://www.alberton.info/firebird_sql_meta_info.html The SQL 2003 Standard introduced a new schema

More information

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

The Relational Model. Why Study the Relational Model? Relational Database: Definitions The Relational Model Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Microsoft, Oracle, Sybase, etc. Legacy systems in

More information

Oracle Database 10g Express

Oracle Database 10g Express Oracle Database 10g Express This tutorial prepares the Oracle Database 10g Express Edition Developer to perform common development and administrative tasks of Oracle Database 10g Express Edition. Objectives

More information

Lecture 6. SQL, Logical DB Design

Lecture 6. SQL, Logical DB Design Lecture 6 SQL, Logical DB Design Relational Query Languages A major strength of the relational model: supports simple, powerful querying of data. Queries can be written intuitively, and the DBMS is responsible

More information

Advance DBMS. Structured Query Language (SQL)

Advance DBMS. Structured Query Language (SQL) Structured Query Language (SQL) Introduction Commercial database systems use more user friendly language to specify the queries. SQL is the most influential commercially marketed product language. Other

More information

EECS 647: Introduction to Database Systems

EECS 647: Introduction to Database Systems EECS 647: Introduction to Database Systems Instructor: Luke Huan Spring 2013 Administrative Take home background survey is due this coming Friday The grader of this course is Ms. Xiaoli Li and her email

More information

A table is a collection of related data entries and it consists of columns and rows.

A table is a collection of related data entries and it consists of columns and rows. CST 250 MySQL Notes (Source: www.w3schools.com) MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables.

More information

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

Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization Requirement Analysis & Conceptual Database Design Problem analysis Entity Relationship notation Integrity constraints Generalization Introduction: Lifecycle Requirement analysis -> Text Conceptual Design

More information

More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan

More on SQL. Juliana Freire. Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan More on SQL Some slides adapted from J. Ullman, L. Delcambre, R. Ramakrishnan, G. Lindstrom and Silberschatz, Korth and Sudarshan SELECT A1, A2,, Am FROM R1, R2,, Rn WHERE C1, C2,, Ck Interpreting a Query

More information

A brief MySQL tutorial. CSE 134A: Web Service Design and Programming Fall 2001 9/28/2001

A brief MySQL tutorial. CSE 134A: Web Service Design and Programming Fall 2001 9/28/2001 A brief MySQL tutorial CSE 134A: Web Service Design and Programming Fall 2001 9/28/2001 Creating and Deleting Databases 1) Creating a database mysql> CREATE database 134a; Query OK, 1 row affected (0.00

More information

a database design proposal for

a database design proposal for a database design proposal for wallance miranda may 15, 2013 table of contents 2 executive summary 3 create table statements 5 persons table 5 employees table 6 passengers table 7 aircrafts table 8 seat_classes

More information

SQL Programming. Student Workbook

SQL Programming. Student Workbook SQL Programming Student Workbook 2 SQL Programming SQL Programming Published by itcourseware, Inc., 7245 South Havana Street, Suite 100, Englewood, CO 80112 Contributing Authors: Denise Geller, Rob Roselius,

More information

Database Administration with MySQL

Database Administration with MySQL Database Administration with MySQL Suitable For: Database administrators and system administrators who need to manage MySQL based services. Prerequisites: Practical knowledge of SQL Some knowledge of relational

More information

2/3/04 Doc 7 SQL Part 1 slide # 1

2/3/04 Doc 7 SQL Part 1 slide # 1 2/3/04 Doc 7 SQL Part 1 slide # 1 CS 580 Client-Server Programming Spring Semester, 2004 Doc 7 SQL Part 1 Contents Database... 2 Types of Databases... 6 Relational, Object-Oriented Databases and SQL...

More information

Answers to the Try It Yourself Sections

Answers to the Try It Yourself Sections APPENDIX D Answers to the Try It Yourself Sections Chapter 1, PL/SQL Concepts 1) To calculate the area of a circle, you must square the circle s radius and then multiply it by π. Write a program that calculates

More information

A Project Presentation on Online Car Rental System

A Project Presentation on Online Car Rental System A Project Presentation on Online Car Rental System Submitted To: Department of Computer Science, Ganpat University,384012 Group No: 74 Submitted By: Internal Guide: Khushbu Patel (13084231136) Niyati Patel

More information

CSC 443 Fall 2011 Dr. R. M. Siegfried. Answers to Assignment #1

CSC 443 Fall 2011 Dr. R. M. Siegfried. Answers to Assignment #1 Answers to Assignment #1 1.14. Consider the Database below: If the name of the 'CS' (Computer Science) Department changes to 'CSSE' (Computer Science and Software Engineering) Department and the corresponding

More information

Faculty of Engineering and Architecture. Computer Engineering Department DATABASE MANAGEMENT SYSTEMS POSTLAB #3 SOLUTION

Faculty of Engineering and Architecture. Computer Engineering Department DATABASE MANAGEMENT SYSTEMS POSTLAB #3 SOLUTION Faculty of Engineering and Architecture Computer Engineering Department DATABASE MANAGEMENT SYSTEMS POSTLAB #3 SOLUTION CREATING TABLES DVD Company Table create table dvd_company ( name varchar(15) not

More information

Data Modeling. Database Systems: The Complete Book Ch. 4.1-4.5, 7.1-7.4

Data Modeling. Database Systems: The Complete Book Ch. 4.1-4.5, 7.1-7.4 Data Modeling Database Systems: The Complete Book Ch. 4.1-4.5, 7.1-7.4 Data Modeling Schema: The structure of the data Structured Data: Relational, XML-DTD, etc Unstructured Data: CSV, JSON But where does

More information

Create a Database Driven Application

Create a Database Driven Application Create a Database Driven Application Prerequisites: You will need a Bluemix account and an IBM DevOps Services account to complete this project. Please review the Registration sushi card for these steps.

More information

DbSchema Tutorial with Introduction in SQL Databases

DbSchema Tutorial with Introduction in SQL Databases DbSchema Tutorial with Introduction in SQL Databases Contents Connect to the Database and Create First Tables... 2 Create Foreign Keys... 7 Create Indexes... 9 Generate Random Data... 11 Relational Data

More information

Using Variables in PL/SQL. Copyright 2007, Oracle. All rights reserved.

Using Variables in PL/SQL. Copyright 2007, Oracle. All rights reserved. What Will I Learn? In this lesson, you will learn to: List the uses of variables in PL/SQL Identify the syntax for variables in PL/SQL Declare and initialize variables in PL/SQL Assign new values to variables

More information

Relational Databases and SQLite

Relational Databases and SQLite Relational Databases and SQLite Charles Severance Python for Informatics: Exploring Information www.pythonlearn.com SQLite Browser http://sqlitebrowser.org/ Relational Databases Relational databases model

More information

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA www.sybex.com

2874CD1EssentialSQL.qxd 6/25/01 3:06 PM Page 1 Essential SQL Copyright 2001 SYBEX, Inc., Alameda, CA www.sybex.com Essential SQL 2 Essential SQL This bonus chapter is provided with Mastering Delphi 6. It is a basic introduction to SQL to accompany Chapter 14, Client/Server Programming. RDBMS packages are generally

More information

ISYS 365 - PL/SQL Basics. Week 03

ISYS 365 - PL/SQL Basics. Week 03 ISYS 365 - PL/SQL Basics Week 03 1 Agenda PL/SQL Block Structure Declaration Syntax Variable Scope IF-THEN-ELSE CASE 2 PL/SQL Block Structure Basic building block of PL/SQL programs Three possible sections

More information

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks]

Question 1. Relational Data Model [17 marks] Question 2. SQL and Relational Algebra [31 marks] EXAMINATIONS 2005 MID-YEAR COMP 302 Database Systems Time allowed: Instructions: 3 Hours Answer all questions. Make sure that your answers are clear and to the point. Write your answers in the spaces provided.

More information

Tutorial: How to Use SQL Server Management Studio from Home

Tutorial: How to Use SQL Server Management Studio from Home Tutorial: How to Use SQL Server Management Studio from Home Steps: 1. Assess the Environment 2. Set up the Environment 3. Download Microsoft SQL Server Express Edition 4. Install Microsoft SQL Server Express

More information

SQL: joins. Practices. Recap: the SQL Select Command. Recap: Tables for Plug-in Cars

SQL: joins. Practices. Recap: the SQL Select Command. Recap: Tables for Plug-in Cars Recap: the SQL Select Command SQL: joins SELECT [DISTINCT] sel_expression [, sel_expression ] FROM table_references [WHERE condition] [GROUPBY column [,column ] [[HAVING condition]] [ORDER BY columns [ASC

More information

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

Boats bid bname color 101 Interlake blue 102 Interlake red 103 Clipper green 104 Marine red. Figure 1: Instances of Sailors, Boats and Reserves Tutorial 5: SQL By Chaofa Gao Tables used in this note: Sailors(sid: integer, sname: string, rating: integer, age: real); Boats(bid: integer, bname: string, color: string); Reserves(sid: integer, bid:

More information

-- ROSE-MARIE BRISSON MATRICULE: 14033798 -- MARIE-?VE BERTHIAUME MATRICULE: 14151972 DROP TABLE VOL CASCADE CONSTRAINT; CREATE TABLE VOL (

-- ROSE-MARIE BRISSON MATRICULE: 14033798 -- MARIE-?VE BERTHIAUME MATRICULE: 14151972 DROP TABLE VOL CASCADE CONSTRAINT; CREATE TABLE VOL ( -- ROSE-MARIE BRISSON MATRICULE: 14033798 -- MARIE-?VE BERTHIAUME MATRICULE: 14151972 DROP TABLE VOL CASCADE CONSTRAINT; CREATE TABLE VOL ( VARCHAR(6), TYPE_DE_VOL VARCHAR(8) NOT NULL CHECK (TYPE_DE_VOL

More information

CPS352 Database Systems: Design Project

CPS352 Database Systems: Design Project CPS352 Database Systems: Design Project Purpose: Due: To give you experience with designing and implementing a database to model a real domain Various milestones due as shown in the syllabus Requirements

More information

Chapter 8. SQL-99: SchemaDefinition, Constraints, and Queries and Views

Chapter 8. SQL-99: SchemaDefinition, Constraints, and Queries and Views Chapter 8 SQL-99: SchemaDefinition, Constraints, and Queries and Views Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations) of a database

More information

Introduction to SQL (3.1-3.4)

Introduction to SQL (3.1-3.4) CSL 451 Introduction to Database Systems Introduction to SQL (3.1-3.4) Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Summary Parts

More information

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems

Part A: Data Definition Language (DDL) Schema and Catalog CREAT TABLE. Referential Triggered Actions. CSC 742 Database Management Systems CSC 74 Database Management Systems Topic #0: SQL Part A: Data Definition Language (DDL) Spring 00 CSC 74: DBMS by Dr. Peng Ning Spring 00 CSC 74: DBMS by Dr. Peng Ning Schema and Catalog Schema A collection

More information

Online Course Registration System

Online Course Registration System COP 5725 - Database Management Systems University of Florida Online Course Registration System Project Report Tolstoy Newtonraja Aditya Nafde Computer and Information Science & Eng Computer and Information

More information

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

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst Outline Data Modeling Yanlei Diao UMass Amherst v Conceptual Design: ER Model v Relational Model v Logical Design: from ER to Relational Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 2 Conceptual

More information

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

The Relational Model. Why Study the Relational Model? Relational Database: Definitions. Chapter 3 The Relational Model Chapter 3 Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase,

More information

Normal Form vs. Non-First Normal Form

Normal Form vs. Non-First Normal Form Normal Form vs. Non-First Normal Form Kristian Torp Department of Computer Science Aalborg Univeristy www.cs.aau.dk/ torp torp@cs.aau.dk September 1, 2009 daisy.aau.dk Kristian Torp (Aalborg University)

More information

Restoring Data with Database Snapshots

Restoring Data with Database Snapshots ASPE RESOURCE SERIES Restoring Data with Database Snapshots Prepared for ASPE by Global Knowledge's Neil Tucker, MCT, MCITP, MCDBA, MCTS, MCSE Real Skills. Real Results. Real IT. in partnership with Restoring

More information

The Relational Model. Why Study the Relational Model?

The Relational Model. Why Study the Relational Model? The Relational Model Chapter 3 Instructor: Vladimir Zadorozhny vladimir@sis.pitt.edu Information Science Program School of Information Sciences, University of Pittsburgh 1 Why Study the Relational Model?

More information

SQL Server Table Design - Best Practices

SQL Server Table Design - Best Practices CwJ Consulting Ltd SQL Server Table Design - Best Practices Author: Andy Hogg Date: 20 th February 2015 Version: 1.11 SQL Server Table Design Best Practices 1 Contents 1. Introduction... 3 What is a table?...

More information

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

In This Lecture. SQL Data Definition SQL SQL. Notes. Non-Procedural Programming. Database Systems Lecture 5 Natasha Alechina This Lecture Database Systems Lecture 5 Natasha Alechina The language, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly and Begg chapter

More information

Using Multiple Operations. Implementing Table Operations Using Structured Query Language (SQL)

Using Multiple Operations. Implementing Table Operations Using Structured Query Language (SQL) Copyright 2000-2001, University of Washington Using Multiple Operations Implementing Table Operations Using Structured Query Language (SQL) The implementation of table operations in relational database

More information

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

Structured Query Language. Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics Structured Query Language HANS- PETTER HALVORSEN, 2014.03.03 Faculty of Technology, Postboks 203,

More information

Tutorial 3 The Relational Database Model

Tutorial 3 The Relational Database Model Tutorial 3 The Relational Database Model References: Topic 3 Lecture notes. Rob, P. & Coronel, C. Database Systems: Design, Implementation & Management, 6th Edition, 2004, Chapter 3, Review Questions 1

More information

Oracle PL/SQL Language. CIS 331: Introduction to Database Systems

Oracle PL/SQL Language. CIS 331: Introduction to Database Systems Oracle PL/SQL Language CIS 331: Introduction to Database Systems Topics: Structure of a PL/SQL program Exceptions 3-valued logic Loops (unconditional, while, for) Cursors Procedures Functions Triggers

More information

RECURSIVE COMMON TABLE EXPRESSIONS DATABASE IN ORACLE. Iggy Fernandez, Database Specialists INTRODUCTION

RECURSIVE COMMON TABLE EXPRESSIONS DATABASE IN ORACLE. Iggy Fernandez, Database Specialists INTRODUCTION RECURSIVE COMMON TABLE EXPRESSIONS IN ORACLE DATABASE 11G RELEASE 2 Iggy Fernandez, Database Specialists INTRODUCTION Oracle was late to the table with recursive common table expressions which have been

More information

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model CS2Bh: Current Technologies Introduction to XML and Relational Databases Spring 2005 The Relational Model CS2 Spring 2005 (LN6) 1 The relational model Proposed by Codd in 1970. It is the dominant data

More information

This appendix provides information on the DB2 sample

This appendix provides information on the DB2 sample This appendix provides information on the DB2 sample tables used in most of the figures and examples in this book. These tables are used as examples in this book as a convenience because they are bundled

More information

PRIMARY KEY, FOREIGN KEY and CHECK Constraints. Copyright 2011, Oracle. All rights reserved.

PRIMARY KEY, FOREIGN KEY and CHECK Constraints. Copyright 2011, Oracle. All rights reserved. PRIMARY KEY, FOREIGN KEY and CHECK Constraints What Will I Learn? Objectives In this lesson, you will learn to: Define and give an example of a PRIMARY KEY, FOREIGN KEY and CHECK constraint Explain the

More information

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina

SQL Data Definition. Database Systems Lecture 5 Natasha Alechina Database Systems Lecture 5 Natasha Alechina In This Lecture SQL The SQL language SQL, the relational model, and E/R diagrams CREATE TABLE Columns Primary Keys Foreign Keys For more information Connolly

More information

Once the schema has been designed, it can be implemented in the RDBMS.

Once the schema has been designed, it can be implemented in the RDBMS. 2. Creating a database Designing the database schema... 1 Representing Classes, Attributes and Objects... 2 Data types... 5 Additional constraints... 6 Choosing the right fields... 7 Implementing a table

More information

DDL is short name of Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database.

DDL is short name of Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database. Snippets Datenmanagement Version: 1.1.0 Study: 2. Semester, Bachelor in Business and Computer Science School: Hochschule Luzern - Wirtschaft Author: Janik von Rotz (http://janikvonrotz.ch) Source: https://gist.github.com/janikvonrotz/6e27788f662fcdbba3fb

More information

Object-Relational Databases

Object-Relational Databases C H A P T E R 14 Object-Relational Databases Learning Objectives After studying this chapter, you should be able to: Concisely define each of the following terms: persistence, serialization, object-relational

More information

SQL Tables, Keys, Views, Indexes

SQL Tables, Keys, Views, Indexes CS145 Lecture Notes #8 SQL Tables, Keys, Views, Indexes Creating & Dropping Tables Basic syntax: CREATE TABLE ( DROP TABLE ;,,..., ); Types available: INT or INTEGER REAL or FLOAT CHAR( ), VARCHAR( ) DATE,

More information

Using Relational Databases to Provide Object Persistence

Using Relational Databases to Provide Object Persistence Chapter 14 Using Relational Databases to Provide Object Persistence Learning Objectives After studying this chapter, you should be able to: Concisely define each of the following terms: persistence, serialization,

More information

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

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1 The Relational Model Ramakrishnan&Gehrke, Chapter 3 CS4320 1 Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. Legacy systems in older models

More information

Supplement IV.D: Tutorial for MS Access. For Introduction to Java Programming By Y. Daniel Liang

Supplement IV.D: Tutorial for MS Access. For Introduction to Java Programming By Y. Daniel Liang Supplement IV.D: Tutorial for MS Access For Introduction to Java Programming By Y. Daniel Liang This supplement covers the following topics: Creating Databases and Executing SQL Creating ODBC Data Source

More information

A Tool for Generating Relational Database Schema from EER Diagram

A Tool for Generating Relational Database Schema from EER Diagram A Tool for Generating Relational Schema from EER Diagram Lisa Simasatitkul and Taratip Suwannasart Abstract design is an important activity in software development. EER diagram is one of diagrams, which

More information

Databases and BigData

Databases and BigData Eduardo Cunha de Almeida eduardo.almeida@uni.lu Outline of the course Introduction Database Systems (E. Almeida) Distributed Hash Tables and P2P (C. Cassagnes) NewSQL (D. Kim and J. Meira) NoSQL (D. Kim)

More information

--- Vincent Hamel, hamv2701 14 162 988

--- Vincent Hamel, hamv2701 14 162 988 --- Vincent Hamel, hamv2701 14 162 988 ------------------------------------------------- drop table Aeroport cascade constraints; create table Aeroport ( codeaeroport varchar(20), ville varchar(20), etat

More information

Database Systems. S. Adams. Dilbert. Available: http://dilbert.com. Hans-Petter Halvorsen, M.Sc.

Database Systems. S. Adams. Dilbert. Available: http://dilbert.com. Hans-Petter Halvorsen, M.Sc. Database Systems S. Adams. Dilbert. Available: http://dilbert.com Hans-Petter Halvorsen, M.Sc. Old fashion Database (Data-storage) Systems Not too long ago, this was the only data-storage device most companies

More information

SQL 2: GETTING INFORMATION INTO A DATABASE. MIS2502 Data Analytics

SQL 2: GETTING INFORMATION INTO A DATABASE. MIS2502 Data Analytics SQL 2: GETTING INFORMATION INTO A DATABASE MIS2502 Data Analytics Our relational database A series of tables Linked together through primary/foreign key relationships To create a database We need to define

More information

The Relational Data Model and Relational Database Constraints

The Relational Data Model and Relational Database Constraints The Relational Data Model and Relational Database Constraints Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations and Dealing with Constraint

More information

A SQL Injection : Internal Investigation of Injection, Detection and Prevention of SQL Injection Attacks

A SQL Injection : Internal Investigation of Injection, Detection and Prevention of SQL Injection Attacks A SQL Injection : Internal Investigation of Injection, Detection and Prevention of SQL Injection Attacks Abhay K. Kolhe Faculty, Dept. Of Computer Engineering MPSTME, NMIMS Mumbai, India Pratik Adhikari

More information

Programming Database lectures for mathema

Programming Database lectures for mathema Programming Database lectures for mathematics students April 25, 2015 Functions Functions are defined in Postgres with CREATE FUNCTION name(parameter type,...) RETURNS result-type AS $$ function-body $$

More information

Using SQL Server Management Studio

Using SQL Server Management Studio Using SQL Server Management Studio Microsoft SQL Server Management Studio 2005 is a graphical tool for database designer or programmer. With SQL Server Management Studio 2005 you can: Create databases

More information

SQL Server An Overview

SQL Server An Overview SQL Server An Overview SQL Server Microsoft SQL Server is designed to work effectively in a number of environments: As a two-tier or multi-tier client/server database system As a desktop database system

More information

Corporate Card Payments and Credits

Corporate Card Payments and Credits Introduction Purpose This work instruction provides an overview of how to process corporate cards payments and credits. Prerequisites Helpful Hints Documentation supporting the transaction A Harvard ID

More information

Review: Participation Constraints

Review: Participation Constraints Review: Participation Constraints Does every department have a manager? If so, this is a participation constraint: the participation of Departments in Manages is said to be total (vs. partial). Every did

More information

Integrating Application Express with PayPal Payments Pro. An Oracle White Paper September 2007

Integrating Application Express with PayPal Payments Pro. An Oracle White Paper September 2007 Integrating Application Express with PayPal Payments Pro An Oracle White Paper September 2007 Integrating Application Express with PayPal Payments Pro Introduction... 3 How Application Express Can Integrate

More information

Intermediate SQL C H A P T E R4. Practice Exercises. 4.1 Write the following queries in SQL:

Intermediate SQL C H A P T E R4. Practice Exercises. 4.1 Write the following queries in SQL: C H A P T E R4 Intermediate SQL Practice Exercises 4.1 Write the following queries in SQL: a. Display a list of all instructors, showing their ID, name, and the number of sections that they have taught.

More information

Database Design--from E-R Diagram to SQL Statement

Database Design--from E-R Diagram to SQL Statement Database Design--from E-R Diagram to SQL Statement Problem Set 3 In problem set 3 * you will: Create an entity-relationship diagram for a database Construct a simple database design Input records into

More information

Guide to Completing the Data Integration Template

Guide to Completing the Data Integration Template Guide to Completing the Data Integration Template Contents 1 Preface... 2 2 Introduction... 2 2.1 About this guide... 2 2.2 About the Data Integration Template... 2 2.3 Definitions... 3 3 Phase A: Requirements

More information