Mid-term Exam Answer Keys Week 7 Spring 2011. I. Multiple Choices Questions Each may have more than one answer (6 x 4 = 24 points total)

Slides:



Advertisements
Similar presentations
MySQL. To start go to Login details: login: labuser password:macimd15 – There.
Advertisements

OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Accounting System Design
THE RELATIONAL DATABASE MODEL & THE DATABASE DEVELOPMENT PROCESS Fact of the Week: According to a Gartner study in ‘06, Microsoft SQL server had the highest.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
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.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Computer Science & Engineering 2111 Introduction to Database Management Systems Relationships and Database Creation 1 CSE 2111 Introduction to Database.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Chapter 4 Relational Databases and Enterprise Systems
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Oracle Data Definition Language (DDL)
Primary & Foreign Keys. PK & FK 1.Primary key is required 2.The PK must be unique 3.If the primary key from one table is related to a field in another.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 13 Database Management Systems: Getting Data Together.
ASP.NET Programming with C# and SQL Server First Edition
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
ZEIT2301 Design of Information Systems SQL: Creating a Database School of Engineering and Information Technology Dr Kathryn Merrick.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
SQL Data Definition (CB Chapter 6) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
Chapter 7 Working with Databases and MySQL PHP Programming with MySQL 2 nd Edition.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
DAY 12: DATABASE CONCEPT Tazin Afrin September 26,
CSCI 3140 Module 3 – Logical Database Design for the Relational Model Theodore Chiasson Dalhousie University.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
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.
Microsoft Access Intro Class 6 Relationships.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Intro to SQL| MIS 2502  Spacing not relevant › BUT… no spaces in an attribute name or table name  Oracle commands keywords, table names, and attribute.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database revision.
1 Chapter 17 Methodology - Local Logical Database Design.
CS 3630 Database Design and Implementation. Database Schema Branch (Bno…) Staff (Sno…Bno) Owner (Ono…) PropertyForRent (Pno…Ono) Renter (Rno…) Viewing.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Q1 - Show all the records in the basket ball player table select * from BSKT_BALL_PLAYER;
Database Management Supplement 1. 2 I. The Hierarchy of Data Database File (Entity, Table) Record (info for a specific entity, Row) Field (Attribute,
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Connecting (relating) Data Tables to get Custom Records (Queries) Database Basics.
Chapter 3: Relational Databases
Lecture 4: Logical Database Design and the Relational Model 1.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
For more course tutorials visit CIS 336 All iLabs Week 1 to Week 7 Devry University CIS 336: All iLabs Week 1 to Week 7: Devry University.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Fundamentals of DBMS Notes-1.
SQL: Schema Definition and Constraints Chapter 6 week 6
CS 3630 Database Design and Implementation
Introduction to Database Systems
Lecturer: Mukhtar Mohamed Ali “Hakaale”
CS4222 Principles of Database System
CS122 Using Relational Databases and SQL
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
CS122 Using Relational Databases and SQL
CS1222 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
Presentation transcript:

Mid-term Exam Answer Keys Week 7 Spring 2011

I. Multiple Choices Questions Each may have more than one answer (6 x 4 = 24 points total)

I.1 Which of the following statements about database systems is (are) not right? – A. Business intelligence refers to a bunch of computer- based techniques. – B. Relational database model is the most popular database models in use today – C. A DBMS is the software you use to create and work with a database. – D. Microsoft Access is a network model because it allows many-to-many relationships. D. Access is a database tool which is irrelevant to database model.

I.2 If I were creating a table and I wanted a particular value to be populated automatically in a field but the user could enter a new value in its place if desired, I would create which of the following: – A. Check constraint – B. Default constraint – C. Cascade constraint – D. Define constraint – E. None of the above B.

I.3 Which of the following associated relationships is (are) M:N? – A. Dad:: Child – B. Customer:: Hotel Room – C. Traveler:: Flight – D. Product:: Review – E: Owner:: Pet Not A or D

I.4 When do you need a where clause in a SQL statement? – A. When you are filtering so that only records that match a particular criteria are retrieved. – B. When you are filtering so that only columns that match a particular criteria are retrieved. – C. A and B – D. None of above A. Qualified records will be returned.

I.5 Which command is used to remove a record from a table? – A. Drop Table – B. Alter Table – C. Delete from – D. Update – E. Drop column C.

I.6 To student entity, which of following can be used as Primary key? – A. Date of Birth – B. SSN – C. Passport No. – D. Full Name – E. Parent’s Names – F. Driver License Number B or BCF

II. BI Maturity stage of Temple U. Changing Information Usage BusinessValueCreation BI Maturity Greater Maturity Greater Value Creation Stage 3 Changed Information Usage Paradigms Across Enterprise to Leverage BI Stage 2 Changed Information Usage Paradigms in One or More Functions to Leverage BI Stage 1 No Change to Information Usage Paradigms Stage 0 No DW / BI Experience Status Quo Improved / Focused / Custom Reporting Building and Using Information Assets Information Fully Integrated into Business

III.SQL (35 points total)

Write the following SQL queries based on the basketball player database

III.1 (6 points) Assume the college table is already there. Please write code to create the player table with all attributes. You also need to add the primary key and foreign key to player table. – CREATE TABLE player – ( – Player_ID int NOT NULL PRIMARY KEY, – Fname varchar(255), – Lname varchar(255), – Jersey number int, – College int NOT NULL, – Year_graduation int, – DOB date, – GPA float, – FOREIGN KEY(College) REFERENCES college(College_ID) – )

III.2 Show all the records in the basketball player table. Order the results by descending Lname then descending Fname. – SELECT * – FROM player – ORDER BY Lname Desc, Fname Desc

III.3 Show the unique cities of all colleges (each city should display just once in the results). – SELECT DISTINCT College_city – FROM college

III.4 Show the player’s first and last name, college, GPA if the college ID is 1 and the student’s GPA is greater than 3.5, or if the college ID is 2. – SELECT Fname, Lname, College, GPA – FROM player – WHERE (College=1 AND GPA>3.5) OR (College=2)

III.5 Display the player’s first and last name, college, GPA if the college is 1, 2, 3, 4, or 5. Order the output by player’s last name. – SELECT player.Fname, player.Lname, college.College_name, player.GPA – FROM player, college – WHERE (player.College=college.ID) – AND player.College>=1 AND player.College<=5 – ORDER BY player.Lname Other options for college ID specification: – Player.College IN (‘1’, ‘2’, ‘3’, ‘4’, ‘5’) – Player.College BETWEEN ‘1’ AND ‘5’

III.6 Show the player’s first and last name if the player’s last name starts with ‘S’. – SELECT Fname, Lname – FROM player – WHERE Lname LIKE ‘S%’

IV. Hotel ERD (35 points)

Step 1. Entities, primary keys, and intrinsic attributes Going to connect all to Invoice!

Step 2. Relationships? Guest::Invoice = ?::? Inn:: Invoice = ?::? Service:: Invoice = ?::?

Step 2 Continued Guest::Invoice = ?::? 1 guest is associated with many invoice (1:M) 1 invoice is associated with only 1 guest (1:1) After all, Guest::Invoice = 1::M

Step 2 Continued Inn:: Invoice = ?::? 1 Inn is associated with many invoice (1:M) 1 invoice is associated with only 1 Inn (1:1) After all, Inn::Invoice = 1::M

Step 2 Continued Service:: Invoice = ?::? 1 service is associated with many invoice (1:M) 1 invoice is associated with many services (1:M) After all, Service::Invoice = M::N

Step 3. Solve M::N issue M::N will introduce redundancy. We need a bridge entity here! 1::M M::N

Step 3: Solve M::N, add bridge entity 1::M M::1 Next, Q1: How many foreign keys are needed? Q2: Which sides to add foreign keys? “M” or “1”?

Step 4: Add foreign keys to M sides 1::M M::1 4 foreign keys are added to M sides

Step 5. Connect PK to FK DONE!