Assignment 7: Integrity Constraints
|
|
- Gwen Bradley
- 5 years ago
- Views:
Transcription
1 Data Modelling and Databases Exercise dates: April 19, 2018 Ce Zhang, Gustavo Alonso Last update: April 19, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 7: Integrity Constraints This assignment will be discussed during the exercise slots indicated above. If you want feedback for your copy, hand it in during the lecture on the Wednesday before (preferably stapled and with your address). You can also annotate your copy with questions you think should be discussed during the exercise session. If you have questions that are not answered by the solution we provide, send them to Renato 1 Foreign Keys and Constraints: Theory 1. Given a database with multiple tables, which of the following constraints can be used in a way to ensure, or will by definition not allow NULL values to be inserted? UNIQUE NOT NULL FOREIGN KEY PRIMARY KEY CHECK 2. Are the following statements true or false? Place a checkmark in the correct ones. In principle a CHECK constraint could be added to a table that makes it impossible to insert any data. A PRIMARY KEY attribute can have up to one NULL value. The PRIMARY KEY constraint can be augmented with an ON DELETE SET NULL. The ON DELETE CASCADE constraint specified for an attribute in a table leads to record deletions in the referenced tables. The CHECK constraint cannot alter values in a table.
2 3. In the lecture, we have seen the following ways to ensure consistency in a database: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK, and DEFAULT. Fill in the following grid answering which of these applies to which use case. Mark cases that apply with an. Explain why. Consistency Keyword NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY CHECK DEFAULT Ensure referential consistency between relations. Can be used to... Enforce that each row has some attribute. Limit the domain of values that can be stored in an attribute. Enforce a constraint based on the content of a different table. Enforce a constraint based on two different attributes. Uniquely identify records.
3 2 Foreign Keys and Constraints: SQL 1 1. Consider the following schema creation statement for a university: CREATE TABLE student ( id INT PRIMARY KEY, age INT NOT NULL CREATE TABLE lecture ( id INT PRIMARY KEY, name VARCHAR (32) NOT NULL CREATE TABLE attends ( sid INT, lid INT, CONSTRAINT fk1 FOREIGN KEY ( sid ) REFERENCES student ( id) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT fk2 FOREIGN KEY ( lid ) REFERENCES lecture ( id) ON DELETE NO ACTION ON UPDATE SET NULL Initially, the three tables contain the following entries: student id age id lecture name 2 Databases 3 Literature 4 Biology attends sid lid Fill in the table, showing how many tuples the tables contain after executing each set of SQL statements. Assume that each set of SQL statements is executed on the initial state of the database above and that individual SQL statements are executed in a separate transaction. SQL student lecture attends INSERT INTO lecture VALUES (1, ' Math I' INSERT INTO lecture VALUES (2, ' Math II ' INSERT INTO student VALUES (9, 30) ; INSERT INTO attends VALUES (9, 2 DELETE FROM lecture WHERE id >2; UPDATE lecture SET id =99 WHERE id <=2; DELETE FROM student WHERE age > ( SELECT AVG ( age ) FROM student
4 2. Consider the following schemas: Schema A Schema B Schema C tab1_key INT NOT NULL UNIQUE tab1_key INT NOT NULL UNIQUE tab1_key INT NOT NULL tab2_ref INT NOT NULL, FOREIGN KEY ( tab2_ref ) REFERENCES tab1 ( tab1_key ) ON DELETE RESTRICT ON UPDATE NO ACTION tab2_ref INT NOT NULL, FOREIGN KEY ( tab2_ref ) REFERENCES tab1 ( tab1_key ) tab2_ref INT NOT NULL Schema D tab1_key INT PRIMARY KEY tab2_key INT PRIMARY KEY, tab2_ref INT NOT NULL, CONSTRAINT tab2_fk FOREIGN KEY ( tab2_ref ) REFERENCES tab1 ( tab1_key ) ON DELETE CASCADE ON UPDATE SET NULL CREATE TABLE tab3 ( tab3_ref INT, CONSTRAINT tab3_fk FOREIGN KEY ( tab3_ref ) REFERENCES tab2 ( tab2_key ) ON DELETE CASCADE ON UPDATE CASCADE Schema E tab1_key INT PRIMARY KEY tab2_key INT PRIMARY KEY, tab2_ref INT NOT NULL, FOREIGN KEY ( tab2_ref ) REFERENCES tab1 ( tab1_key ) ON DELETE CASCADE ON UPDATE CASCADE CREATE TABLE tab3 ( tab3_ref INT, FOREIGN KEY ( tab3_ref ) REFERENCES tab2 ( tab2_key ) ON DELETE SET NULL ON UPDATE CASCADE For schemas A, B and C, the tables tab1 and tab2 initially have the following content: tab1_key 1 2 tab2_key 1 2 For schemas D and E, the tables tab1, tab2 and tab3 initially have the following content: tab1_key 1 2 tab2_key tab2_ref tab3_ref 10 20
5 How many records will each schema hold (summed over all of its tables) after executing individually one of the following statements? Fill in the table below with the resulting number of records or mark an execution error with in the corresponding cell. Statements: I. UPDATE tab2 SET tab2_ ref =3 WHERE tab2_ ref =1; II. UPDATE tab1 SET tab1_ key =3 WHERE tab1_ key =1; III. DELETE FROM tab1 WHERE tab1_ key =1; A B C D E I II III 3 Foreign Keys and Constraints: SQL 2 For this exercise, you need exercise07-2_schemas.sql and exercise07-2_queries.sql. First, take a look at exercise07-2_schemas.sql. It contains four different schema variations of the Employees database. Furthermore, exercise07-2_queries.sql contains 16 queries that can be executed on top of these schemas and one modification of each of these schemas that should be executed before running queries The queries as well as schemas are numbered in the.sql files the same way as they are numbered in this document. 1. Run all combinations of schemas and queries and mark your findings in the table below. Use an to note whether a query failed to run. What is the reason that this query/schema combination failed? Schema a) b) c) d) Queries For queries 15 and 16, list the row count of the following query (if running): SELECT * FROM dept_manager Schema a) b) c) d) Queries 15 16
6 4 Foreign Keys and Constraints: SQL 3 If you want to test your solutions for this exercise, set up the tables in exercise07-3.sql in a new database. They follow this relational schema: readers: (reader_id, last_name, first_name, birth_date) books: (isbn, title, author_id, publisher_id, number_of_pages, year_of_publication) publishers: (publisher_id, name, address) categories: (category_name, subcategory_of) authors: (author_id, first_name, last_name) copies: (isbn, copy_id, shelf_no, position) borrows: (reader_id, isbn, copy_id, return_date) 1. Mark all of the following statements which are true regarding the use of integrity constraints. If primary keys are not used, two categories with the same name can exist. If there is a foreign key reference FOREIGN KEY (isbn) REFERENCES books(isbn) ON DELETE NO ACTION from copies to books, removing a book from the database without removing its copies is possible. A foreign key reference FOREIGN KEY (subcategory_of) REFERENCES categories(category_name) ON UPDATE CASCADE from categories to categories enforces that changing a category s name will cause all subcategory_of values with the original name to change to the new name. If there is a foreign key reference FOREIGN KEY(reader_id)REFERENCES readers(reader_id)on DELETE NO ACTION from borrows to readers, a malicious reader with access to the database could write a query to delete all of her borrowing records. 2. What foreign key constraints are necessary and which strategies (ON UPDATE/ON DELETE) have to be applied when changing them? Please give an explanation why you chose a particular strategy. 3. According to your solution to the previous task: What is the implication of deleting a publisher, i.e., removing a row from the publishers relation? What is the consequence of updating a reader_id? 4. Enforce that all the readers must be older than 18 years.
7 5 Employee Database Constraints Consider the employee database from previous exercises: departments: (dept_no:string, dept_name:string) dept_emp: (emp_no:int, dept_no:string, from_date:date, to_date:date) dept_manager: (emp_no:int, dept_no:string, from_date:date, to_date:date) employees: (emp_no:int, birth_date:date, first_name:string, last_name:string, gender:enum, hire_date:date) salaries: (emp_no:int, salary:int, from_date:date, to_date:date) title: (emp_no:int, title:string, from_date:date, to_date:date) How would you add the following constraints, when you create the corresponding table in SQL? Write a complete CREATE TABLE query with the required constraints. 1. The start date of salary has to be before the end date. 2. The end date in dept_emp table is either NULL (meaning sometime future) or is in the past. 3. Let s assume the following statement has to be enforced: One employee can only be the manager of one department at a time. This implies that the date entries in dept_manager table cannot have overlaps for a certain employee. How would you ensure this? 6 Basketball Tournament Suppose that you were chosen to design a simple database for a basketball tournament. According to the project description, players belong to only one team and can be identified by their name. Each player has a number, and the total number of points scored by each player should be recorded. In this tournament, each team plays against each other. A team has exactly one coach and one captain. It has also a name and is identified by a subscription number. A coach has a unique name and an address. The captain is a real player while the coach is not. As soon as a match is done, the number of points scored by each team has to be stored separately. ER diagram of the tournament:
8 Relational model: coach: (name, ) player: (name, number, score, team_id) team: (sub_id, name, coach, captain) game: (teama, teamb, scorea, scoreb) 1. Create all required tables for your new database (using CREATE statements) including the appropriate primary and foreign key constraints. If you have cyclic foreign key dependencies (table A refers to table B and table B refers to table A), remember that you won t be able to insert any rows. You can always remove and add foreign keys using ALTER TABLE command before/after inserting rows. 2. After creating the tables, the project manager realizes that he forgot to give you some additional rules that the database must respect. Add these new constraints based on the following description (using ALTER TABLE statements). Do not forget to apply appropriate relational actions (e.g. CASCADE, NO ACTION, etc.) to foreign key constraints. Team names must be unique. Scores should always be non-negative. A game must be between different teams. Coaches cannot have the same address. Players have a number that range from four to 15. If a player is expelled from the tournament, he is discarded from the database. However, there must always be a captain. If the coach is expelled, its team is removed from the tournament but all its previous games should be kept (to compute final score of other teams). 3. After the tournament, the total number of points that each team scored during the whole tournament have to be computed. Additionally, in order to reward the best players, one would like to retrieve all players that score more than the half of the points of their team. For example, if a team has scored 100 points, we want to find the player that scored more than 50 points (if any). Write two SQL queries that express these requirements.
Data Modelling and Databases. Exercise Session 7: Integrity Constraints
Data Modelling and Databases Exercise Session 7: Integrity Constraints 1 Database Design Textual Description Complete Design ER Diagram Relational Schema Conceptual Modeling Logical Modeling Physical Modeling
More informationAssignment 6: SQL III Solution
Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III Solution This assignment
More informationAssignment 2: Relational Model
Data Modelling and Databases Exercise dates: March 8/March 9, 208 Ce Zhang, Gustavo Alonso Last update: March 6, 208 Spring Semester 208 Head TA: Ingo Müller Assignment 2: Relational Model This assignment
More informationAssignment 6: SQL III
Data Modelling and Databases Exercise dates: April 12/April 13, 2018 Ce Zhang, Gustavo Alonso Last update: April 16, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 6: SQL III This assignment
More informationAssignment 2: Relational Model Solution
Data Modelling and Databases Exercise dates: March 8/March 9, 208 Ce Zhang, Gustavo Alonso Last update: March 6, 208 Spring Semester 208 Head TA: Ingo Müller Assignment 2: Relational Model Solution This
More informationAssignment 3: Relational Algebra Solution
Data Modelling and Databases Exercise dates: March 15/March 16, 2018 Ce Zhang, Gustavo Alonso Last update: April 13, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 3: Relational Algebra Solution
More informationAssignment 1: Entity-Relationship Model Solution
Data odelling and Databases Exercise dates: arch /arch 2, 208 Ce Zhang, Gustavo Alonso Last update: arch 08, 208 Spring Semester 208 Head TA: Ingo üller Assignment : Entity-Relationship odel Solution This
More informationData Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018.
Data Modelling and Databases Exercise dates: March 22/March 23, 2018 Ce Zhang, Gustavo Alonso Last update: March 26, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 4: SQL This assignment will
More informationAssignment 12: Commit Protocols and Replication
Data Modelling and Databases Exercise dates: May 24 / May 25, 2018 Ce Zhang, Gustavo Alonso Last update: June 04, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 12: Commit Protocols and Replication
More informationData Modelling and Databases. Exercise Session 2: Relational Model
Data Modelling and Databases Exercise Session 2: Relational Model 1 Interactive Session Format You can watch others swim as often as you want. In the end, you can only learn it by doing it yourself. Alfons
More informationAssignment 12: Commit Protocols and Replication Solution
Data Modelling and Databases Exercise dates: May 24 / May 25, 2018 Ce Zhang, Gustavo Alonso Last update: June 04, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 12: Commit Protocols and Replication
More informationEGCI 321: Database Systems. Dr. Tanasanee Phienthrakul
1 EGCI 321: Database Systems Dr. Tanasanee Phienthrakul 2 Chapter 10 Data Definition Language (DDL) 3 Basic SQL SQL language Considered one of the major reasons for the commercial success of relational
More informationExam. Question: Total Points: Score:
FS 2016 Data Modelling and Databases Date: June 9, 2016 ETH Zurich Systems Group Prof. Gustavo Alonso Exam Name: Question: 1 2 3 4 5 6 7 8 9 10 11 Total Points: 15 20 15 10 10 15 10 15 10 10 20 150 Score:
More informationAssignment 5: SQL II Solution
Data Modelling and Databases Exercise dates: March 29/March 30, 2018 Ce Zhang, Gustavo Alonso Last update: April 12, 2018 Spring Semester 2018 Head TA: Ingo Müller Assignment 5: SQL II Solution This assignment
More informationCSE 530A. ER Model to Relational Schema. Washington University Fall 2013
CSE 530A ER Model to Relational Schema Washington University Fall 2013 Relational Model A relational database consists of a group of relations (a.k.a., tables) A relation (table) is a set of tuples (rows)
More informationWhere Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams
Where Are We? Introduction to Data Management CSE 344 Lecture 15: Constraints We know quite a bit about using a DBMS Start with real-world problem, design ER diagram From ER diagram to relations -> conceptual
More informationCSC 453 Database Technologies. Tanu Malik DePaul University
CSC 453 Database Technologies Tanu Malik DePaul University A Data Model A notation for describing data or information. Consists of mostly 3 parts: Structure of the data Data structures and relationships
More informationCSC 261/461 Database Systems Lecture 6. Fall 2017
CSC 261/461 Database Systems Lecture 6 Fall 2017 Use of WITH The WITH clause allows a user to define a table that will only be used in a particular query (not available in all SQL implementations) Used
More informationConsistency The DBMS must ensure the database will always be in a consistent state. Whenever data is modified, the database will change from one
Data Management We start our studies of Computer Science with the problem of data storage and organization. Nowadays, we are inundated by data from all over. To name a few data sources in our lives, we
More informationCS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen
CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen LECTURE 10: INTRODUCTION TO SQL FULL RELATIONAL OPERATIONS MODIFICATION LANGUAGE Union, Intersection, Differences (select
More informationRelational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011
Relational Model IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 Overview What is the relational model? What are the most important practical elements of the relational model? 2 Introduction
More informationCIS 2010 Individual Database Assignment Detailed Instructions Fall 2007 (Last updated 8/15/07)
CIS 200 Individual Database Assignment Detailed Instructions Fall 2007 (Last updated 8/5/07) Section - Database Design Hershey College is a small liberal arts college in Hershey, Pennsylvania. Because
More informationCS 327E Lecture 2. Shirley Cohen. January 27, 2016
CS 327E Lecture 2 Shirley Cohen January 27, 2016 Agenda Announcements Homework for today Reading Quiz Concept Questions Homework for next time Announcements Lecture slides and notes will be posted on the
More informationIntroduction to Databases and SQL
Introduction to Databases and SQL Files vs Databases In the last chapter you learned how your PHP scripts can use external files to store and retrieve data. Although files do a great job in many circumstances,
More informationWHAT IS SQL. Database query language, which can also: Define structure of data Modify data Specify security constraints
SQL KEREM GURBEY WHAT IS SQL Database query language, which can also: Define structure of data Modify data Specify security constraints DATA DEFINITION Data-definition language (DDL) provides commands
More informationAsst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa
ICS 321 Spring 2011 Constraints, Triggers, Views & Indexes Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 04/04/2011 Lipyeow Lim -- University of Hawaii
More informationConstraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2
CMPT 354 Constraints Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers John Edgar 2 firstname type balance city customerid lastname accnumber rate branchname phone
More informationTutorial 2: Relational Modelling
Tutorial 2: Relational Modelling Informatics 1 Data & Analysis Week 4, Semester 2, 2014 2015 This worksheet has three parts: tutorial Questions, followed by some Examples and their Solutions. Before your
More informationSQL Server 2008 Tutorial 3: Database Creation
SQL Server 2008 Tutorial 3: Database Creation IT 5101 Introduction to Database Systems J.G. Zheng Fall 2011 DDL Action in SQL Server Creating and modifying structures using the graphical interface Table
More informationChapter 1 SQL and Data
Chapter 1 SQL and Data What is SQL? Structured Query Language An industry-standard language used to access & manipulate data stored in a relational database E. F. Codd, 1970 s IBM 2 What is Oracle? A relational
More informationExercise 12: Commit Protocols and Replication
Data Modelling and Databases (DMDB) ETH Zurich Spring Semester 2017 Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: May 22, 2017 Assistant(s): Claude Barthels, Eleftherios Sidirourgos, Eliza
More informationThe DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.
Managing Data Data storage tool must provide the following features: Data definition (data structuring) Data entry (to add new data) Data editing (to change existing data) Querying (a means of extracting
More informationETH Zurich Spring Semester Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: August 19, Exam. Questions
Data Modelling and Databases (DMDB) ETH Zurich Spring Semester 2017 Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: August 19, 2017 Assistant(s): Claude Barthels, Eleftherios Sidirourgos, Last
More informationThe Relational Model
The Relational Model What is the Relational Model Relations Domain Constraints SQL Integrity Constraints Translating an ER diagram to the Relational Model and SQL Views A relational database consists
More informationIntermediate SQL ( )
CSL 451 Introduction to Database Systems Intermediate SQL (4.1-4.4) Department of Computer Science and Engineering Indian Institute of Technology Ropar Narayanan (CK) Chatapuram Krishnan! Summary Join
More informationCreating databases using SQL Server Management Studio Express
Creating databases using SQL Server Management Studio Express With the release of SQL Server 2005 Express Edition, TI students and professionals began to have an efficient, professional and cheap solution
More information3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key
Unit 3: Types of Keys & Data Integrity 3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key Different Types of SQL Keys A key is a single or combination of multiple fields in a
More informationExercise 12: Commit Protocols and Replication
Data Modelling and Databases (DMDB) ETH Zurich Spring Semester 2017 Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: May 22, 2017 Assistant(s): Claude Barthels, Eleftherios Sidirourgos, Eliza
More informationACS-3902 Fall Ron McFadyen 3D21 Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition)
ACS-3902 Fall 2016 Ron McFadyen 3D21 ron.mcfadyen@acs.uwinnipeg.ca Slides are based on chapter 5 (7 th edition) (chapter 3 in 6 th edition) 1 The Relational Data Model and Relational Database Constraints
More informationSchool of Computing and Information Technology Session: Spring CSCI835 Database Systems (Bridging Subject) Sample class test 23 July 2018
School of Computing and Information Technology Session: Spring 2018 University of Wollongong Lecturer: Janusz R. Getta CSCI835 Database Systems (Bridging Subject) Sample class test 23 July 2018 THE QUESTIONS
More informationIntroduction to Database Systems CSE 414
Introduction to Database Systems CSE 414 Lecture 16: Constraints CSE 414 - Spring 2015 1 Announcements Reminders: Web quiz due Monday night XML homework due Wednesday night Today: Constraints (7.1, 7.2,
More informationData Modelling and Databases Exercise dates: March 20/March 27, 2017 Ce Zhang, Gustavo Alonso Last update: February 17, 2018.
Data Modelling and Databases Exercise dates: March 20/March 27, 2017 Ce Zhang, Gustavo Alonso Last update: February 17, 2018 Spring Semester 2018 Head TA: Ingo Müller Datasets set-up This assignment will
More informationData Modeling. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke
Data Modeling Yanlei Diao UMass Amherst Slides Courtesy of R. Ramakrishnan and J. Gehrke 1 Outline v Conceptual Design: ER Model v Relational Model v Logical Design: from ER to Relational 2 Conceptual
More informationDatabase Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.
Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 5 Structured Query Language Hello and greetings. In the ongoing
More informationKing Fahd University of Petroleum and Minerals
1 King Fahd University of Petroleum and Minerals Information and Computer Science Department ICS 334: Database Systems Semester 041 Major Exam 1 18% ID: Name: Section: Grades Section Max Scored A 5 B 25
More informationDatabase Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.
Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No. # 13 Constraints & Triggers Hello and welcome to another session
More informationDatabases and MySQL. COMP 342: Programming Methods. 16 September Databases and MySQL
Databases and MySQL COMP 342: Programming Methods 16 September 2008 Databases and MySQL Database basics What is a database? A database consists of some number of tables. Each table consists of field names
More informationExercise 11: Transactions
Data Modelling and Databases (DMDB) ETH Zurich Spring Semester 2017 Systems Group Lecturer(s): Gustavo Alonso, Ce Zhang Date: Assistant(s): Claude Barthels, Eleftherios Sidirourgos, Eliza Last update:
More informationComp 5311 Database Management Systems. 4b. Structured Query Language 3
Comp 5311 Database Management Systems 4b. Structured Query Language 3 1 SQL as Data Definition Language Creates the Students relation. The type (domain) of each field is specified, and enforced by the
More informationCS W Introduction to Databases Spring Computer Science Department Columbia University
CS W4111.001 Introduction to Databases Spring 2018 Computer Science Department Columbia University 1 in SQL 1. Key constraints (PRIMARY KEY and UNIQUE) 2. Referential integrity constraints (FOREIGN KEY
More informationStructure Query Language (SQL)
Structure Query Language (SQL) 1 6.12.2 OR operator OR operator is also used to combine multiple conditions with Where clause. The only difference between AND and OR is their behavior. When we use AND
More informationData about data is database Select correct option: True False Partially True None of the Above
Within a table, each primary key value. is a minimal super key is always the first field in each table must be numeric must be unique Foreign Key is A field in a table that matches a key field in another
More informationMTAT Introduction to Databases
MTAT.03.105 Introduction to Databases Lecture #12 DB Administration Ljubov Jaanuska (ljubov.jaanuska@ut.ee) Lecture 11. Summary Functions Procedures Lecture 11. What will you learn Users User rights Revision
More informationOracle 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 informationLogical database design
Databases 2013 2014/Ia Homework 2 Due date: September 27, 2013 Logical database design This homework consists of two parts. In the first part of this homework, we will go through some of the design decisions
More informationDatabase Management Systems,
Database Management Systems SQL Query Language (1) 1 Topics Introduction SQL History Domain Definition Elementary Domains User-defined Domains Creating Tables Constraint Definition INSERT Query SELECT
More informationIntroduction to Data Management. Lecture #4 (E-R Relational Translation)
Introduction to Data Management Lecture #4 (E-R Relational Translation) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements v Today
More informationThe Entity-Relationship Model (ER Model) - Part 2
Lecture 4 The Entity-Relationship Model (ER Model) - Part 2 By Michael Hahsler Based on slides for CS145 Introduction to Databases (Stanford) Lecture 4 > Section 2 What you will learn about in this section
More informationCMPT 354: Database System I. Lecture 2. Relational Model
CMPT 354: Database System I Lecture 2. Relational Model 1 Outline An overview of data models Basics of the Relational Model Define a relational schema in SQL 2 Outline An overview of data models Basics
More informationName: Answers Q
p.1 of 10 INFS 4240/6240 (Section A) Database Management System Fall 2018 Test 3 December 4, 2018 2:00 3:15 pm Q.1-1 10 10 Q.1-2 8 8 Q.2 12 12 Name: Answers Q.3-1 6 6 Q.3-2 32 32 Q.3-3 32 32 Total 100
More informationChapter 2 Introduction to Relational Models
CMSC 461, Database Management Systems Spring 2018 Chapter 2 Introduction to Relational Models These slides are based on Database System Concepts book and slides, 6th edition, and the 2009 CMSC 461 slides
More informationDatabase Management Systems MIT Introduction By S. Sabraz Nawaz
Database Management Systems MIT 22033 Introduction By S. Sabraz Nawaz Recommended Reading Database Management Systems 3 rd Edition, Ramakrishnan, Gehrke Murach s SQL Server 2008 for Developers Any book
More informationHandout 6 Logical design: Translating ER diagrams into SQL CREATE statements
06-13584 Fundamentals of Databases Spring Semester 2005 The University of Birmingham School of Computer Science Achim Jung February 16, 2005 Handout 6 Logical design: Translating ER diagrams into SQL CREATE
More informationUnit 27 Web Server Scripting Extended Diploma in ICT
Unit 27 Web Server Scripting Extended Diploma in ICT Dynamic Web pages Having created a few web pages with dynamic content (Browser information) we now need to create dynamic pages with information from
More informationDATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E)
1 DATA AND SCHEMA MODIFICATIONS CHAPTERS 4,5 (6/E) CHAPTER 8 (5/E) 2 LECTURE OUTLINE Updating Databases Using SQL Specifying Constraints as Assertions and Actions as Triggers Schema Change Statements in
More information6 February 2014 CSE-3421M Test #1 w/ answers p. 1 of 14. CSE-3421M Test #1. Design
6 February 2014 CSE-3421M Test #1 w/ answers p. 1 of 14 CSE-3421M Test #1 Design Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 75 minutes Term: Winter 2014 Answer
More informationThe Relational Model of Data (ii)
ICS 321 Fall 2013 The Relational Model of Data (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1 Defining Relational Schema in SQL Two aspects: Data
More informationDatabase Programming - Section 10. Instructor Guide
Database Programming - Section 10 Instructor Guide Table of Contents...1 Lesson 1 - Defining NOT NULL and UNIQUE Constraints...1 What Will I Learn?...2 Why Learn It?...3...4 Try It / Solve It...13 Lesson
More informationWho, where, when. Database Management Systems (LIX022B05) Literature. Evaluation. Lab Sessions. About this course. After this course...
Who, where, when base Management Systems (LIX022B05) Instructor: Çağrı Çöltekin c.coltekin@rug.nl Information science/informatiekunde Fall 2012 Course bases (LIX022B05) 2012/13 Instructor Çağrı Çöltekin
More informationL Information Systems for Engineers. Final exam. ETH Zurich, Autumn Semester 2017 Friday
252-0834-00L Information Systems for Engineers Final exam ETH Zurich, Autumn Semester 2017 Friday 09.02.2018 First name: Last name: Legi number: Signature: You can fill out the above fields immediately,
More informationSQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017
SQL: Data Definition Language csc343, Introduction to Databases Diane Horton Fall 2017 Types Table attributes have types When creating a table, you must define the type of each attribute. Analogous to
More informationCOGS 121 HCI Programming Studio. Week 03 - Tech Lecture
COGS 121 HCI Programming Studio Week 03 - Tech Lecture Housekeeping Assignment #1 extended to Monday night 11:59pm Assignment #2 to be released on Tuesday during lecture Database Management Systems and
More informationCS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model
CS425 Fall 2016 Boris Glavic Chapter 2: Intro to Relational Model Modifies from: Database System Concepts, 6 th Ed. See www.db-book.com for conditions on re-use Textbook: Chapter 2 2.2 Example of a Relation
More informationIntroduction to Data Management CSE 344
Introduction to Data Management CSE 344 Lecture 16: Constraints CSE 344 - Winter 2014 1 Announcements WQ5 due tonight deadline extended only for this WQ HW4 due tomorrow HW 5 posted, due next Thursday
More informationIntegrity and Security
C H A P T E R 6 Integrity and Security This chapter presents several types of integrity constraints, including domain constraints, referential integrity constraints, assertions and triggers, as well as
More informationLet s briefly review important EER inheritance concepts
Let s briefly review important EER inheritance concepts 1 is-a relationship Copyright (c) 2011 Pearson Education 2 Basic Constraints Partial / Disjoint: Single line / d in circle Each entity can be an
More informationCS425 Midterm Exam Summer C 2012
Q1) List five responsibilities of a database-management system. Q2) Fill in the terms in the right hand side of the table that match the description from the list below: Instance SQL Integrity constraints
More informationMySQL. A practical introduction to database design
MySQL A practical introduction to database design Dr. Chris Tomlinson Bioinformatics Data Science Group, Room 126, Sir Alexander Fleming Building chris.tomlinson@imperial.ac.uk Database Classes 24/09/18
More informationSQL Server. Lecture3 Cascading referential integrity constraint
SQL Server Lecture3 Cascading referential integrity constraint insert into tblperson values (4,'May','Ma@m.com',4) Msg 547, Level 16, State 0, Line 1 The INSERT statement conflicted with the FOREIGN KEY
More informationLecture 04: SQL. Wednesday, October 4, 2006
Lecture 04: SQL Wednesday, October 4, 2006 1 Outline The Project Nulls (6.1.6) Outer joins (6.3.8) Database Modifications (6.5) 2 The Project Application: Boutique online music and book store Project:
More informationExam. Question: Total Points: Score:
FS 2016 Data Modelling and Databases Date: August 17, 2016 ETH Zurich Systems Group Prof. Gustavo Alonso Exam Name: Question: 1 2 3 4 5 6 7 8 9 10 11 Total Points: 11 11 10 12 9 10 11 10 15 10 8 117 Score:
More informationIntroduction to Data Management CSE 344
Introduction to Data Management CSE 344 Lecture 16: Constraints CSE 344 - Fall 2014 1 Announcements Sections tomorrow: XML. Quiz and next HW on XML posted soon, due next week after midterm HW 4 due tomorrow
More informationALLAMA IQBAL OPEN UNIVERSITY, ISLAMABAD (Department of Computer Science)
ALLAMA IQBAL OPEN UNIVERSITY, ISLAMABAD (Department of Computer Science) WARNING 1. PLAGIARISM OR HIRING OF GHOST WRITER(S) FOR SOLVING THE ASSIGNMENT(S) WILL DEBAR THE STUDENT FROM AWARD OF DEGREE/CERTIFICATE,
More informationMIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: Time: 60 min Marks: 38
Student Info StudentID: Center: ExamDate: MIDTERM EXAMINATION Spring 2010 CS403- Database Management Systems (Session - 4) Ref No: 1356458 Time: 60 min Marks: 38 BC080402322 OPKST 5/28/2010 12:00:00 AM
More informationDatabase Management Systems
Sample Questions 1 Write SQL query to create a table for describing a book. The table should have Book Title, Author, Publisher, Year published, and ISBN fields. Your table should have a primary key. For
More informationEE221 Databases Practicals Manual
EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School
More informationPart 9: More Design Techniques
9. More Design Techniques 9-1 Part 9: More Design Techniques References: Batini/Ceri/Navathe: Conceptual Database Design. Benjamin/Cummings, 1992. Elmasri/Navathe: Fundamentals of Database Systems, 3rd
More informationChapter 4. Windows Database Using Related Tables The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill
Chapter 4 Windows Database Using Related Tables McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Objectives - 1 Explain the types of table relationships Display master/detail records
More informationCS2300: File Structures and Introduction to Database Systems
CS2300: File Structures and Introduction to Database Systems Lecture 14: SQL Doug McGeehan From Theory to Practice The Entity-Relationship Model: a convenient way of representing the world. The Relational
More informationFile Processing Approaches
Relational Database Basics Review Overview Database approach Database system Relational model File Processing Approaches Based on file systems Data are recorded in various types of files organized in folders
More informationIn mathematical terms, the relation itself can be expressed simply in terms of the attributes it contains:
The Relational Model The relational data model organises data as 2-dimensional tables or relations. An example of one such relation would be STUDENT shown below. As we have seen in the wine list example,
More informationEECS 647: Introduction to Database Systems
EECS 647: Introduction to Database Systems Instructor: Luke Huan Spring 2009 Stating Points A database A database management system A miniworld A data model Conceptual model Relational model 2/24/2009
More informationData Management Lecture Outline 2 Part 2. Instructor: Trevor Nadeau
Data Management Lecture Outline 2 Part 2 Instructor: Trevor Nadeau Data Entities, Attributes, and Items Entity: Things we store information about. (i.e. persons, places, objects, events, etc.) Have relationships
More informationCOMP 430 Intro. to Database Systems
COMP 430 Intro. to Database Systems Multi-table SQL Get clickers today! Slides use ideas from Chris Ré and Chris Jermaine. The need for multiple tables Using a single table leads to repeating data Provides
More informationPrivate Institute of Aga NETWORK DATABASE LECTURER NIYAZ M. SALIH
Private Institute of Aga 2018 NETWORK DATABASE LECTURER NIYAZ M. SALIH Data Definition Language (DDL): String data Types: Data Types CHAR(size) NCHAR(size) VARCHAR2(size) Description A fixed-length character
More informationThe Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)
The Relational Model Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) Why Study the Relational Model? Most widely used model in Commercial DBMSs: Vendors: IBM, Microsoft,
More informationRelational Data Model. Christopher Simpkins
Relational Data Model Christopher Simpkins 1 / 22 Relational Data Model A relation schema R(A a,..., A n ) is a relation name R and a list of attributes A 1,..., A n. Each attribute A i is the name of
More informationSQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7
SQL DATA DEFINITION: KEY CONSTRAINTS CS121: Relational Databases Fall 2017 Lecture 7 Data Definition 2 Covered most of SQL data manipulation operations Continue exploration of SQL data definition features
More informationThe 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 informationCS352 - DATABASE SYSTEMS. To give you experience with developing a database to model a real domain
CS352 - DATABASE SYSTEMS Database Design Project - Various parts due as shown in the syllabus Purposes: To give you experience with developing a database to model a real domain Requirements At your option,
More information