Full file at

Similar documents
Full file at

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

SQL: Concepts. Todd Bacastow IST 210: Organization of Data 2/17/ IST 210

SQL DATA DEFINITION LANGUAGE

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

SQL DATA DEFINITION LANGUAGE

SQL DATA DEFINITION LANGUAGE

Creating Tables, Defining Constraints. Rose-Hulman Institute of Technology Curt Clifton

D B M G. SQL language: basics. Managing tables. Creating a table Modifying table structure Deleting a table The data dictionary Data integrity

COSC 304 Introduction to Database Systems SQL DDL. Dr. Ramon Lawrence University of British Columbia Okanagan

SQL: Data Definition Language

Fname A variable character field up to 15 characters in length. Must have a value Lname A variable character field up to 15

Lab # 4. Data Definition Language (DDL)

Chapter 4. Basic SQL. SQL Data Definition and Data Types. Basic SQL. SQL language SQL. Terminology: CREATE statement

Handout 6 CS-605 Spring 18 Page 1 of 7. Handout 6. Physical Database Modeling

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2

Indexes (continued) Customer table with record numbers. Source: Concepts of Database Management

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

The Relational Model of Data (ii)

MTAT Introduction to Databases

Chapter # 7 Introduction to Structured Query Language (SQL) Part I

Chapter 1 SQL and Data

SQL: Data Definition Language. csc343, Introduction to Databases Diane Horton Fall 2017

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Lab # 2. Data Definition Language (DDL) Eng. Alaa O Shama

Chapter 17: Table & Integrity Contraints. Informatics Practices Class XII. By- Rajesh Kumar Mishra. KV No.1, AFS, Suratgarh

IBM DB2 UDB V7.1 Family Fundamentals.

Lecture 07. Spring 2018 Borough of Manhattan Community College

INTRODUCTION TO DATABASE

COGS 121 HCI Programming Studio. Week 03 - Tech Lecture

Slides by: Ms. Shree Jaswal

Chapter Five Physical Database Design

GlobAl EDITION. Database Concepts SEVENTH EDITION. David M. Kroenke David J. Auer

1 INTRODUCTION TO EASIK 2 TABLE OF CONTENTS

COSC344 Database Theory and Applications. Lecture 5 SQL - Data Definition Language. COSC344 Lecture 5 1

SQL Fundamentals. Chapter 3. Class 03: SQL Fundamentals 1

SQL functions fit into two broad categories: Data definition language Data manipulation language

SQL Data Definition: Table Creation

Announcements (September 18) SQL: Part II. Solution 1. Incomplete information. Solution 3? Solution 2. Homework #1 due today (11:59pm)

Data Modelling and Databases. Exercise Session 7: Integrity Constraints

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

Course Prerequisites: This course requires that you meet the following prerequisites:

Module 9: Managing Schema Objects

Databases 1. Defining Tables, Constraints

doc. RNDr. Tomáš Skopal, Ph.D. RNDr. Michal Kopecký, Ph.D.

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

CSC 453 Database Technologies. Tanu Malik DePaul University

Comp 5311 Database Management Systems. 4b. Structured Query Language 3

Principles of Data Management

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Chapter 7. Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel

Basic SQL. Basic SQL. Basic SQL

SQL language. Jaroslav Porubän, Miroslav Biňas, Milan Nosáľ (c)

Overview. Data Integrity. Three basic types of data integrity. Integrity implementation and enforcement. Database constraints Transaction Trigger

[MS20464]: Developing Microsoft SQL Server 2014 Databases

CS275 Intro to Databases

SQL: Data De ni on. B0B36DBS, BD6B36DBS: Database Systems. h p:// Lecture 3

Relational Model. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

SQL - Subqueries and. Schema. Chapter 3.4 V4.0. Napier University

Chapter 2. DB2 concepts

Chapter 9: Working with MySQL

SQL: Part III. Announcements. Constraints. CPS 216 Advanced Database Systems

Concepts of Database Management Seventh Edition. Chapter 4 The Relational Model 3: Advanced Topics

user specifies what is wanted, not how to find it

Data Definition Language (DDL)

Relational data model

MySQL. A practical introduction to database design

A7-R3: INTRODUCTION TO DATABASE MANAGEMENT SYSTEMS

The Relational Model. Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC)

Chapter-14 SQL COMMANDS

Tables From Existing Tables

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

SQL Introduction. CS 377: Database Systems

CS2300: File Structures and Introduction to Database Systems

Database Programming with PL/SQL

Relational Database Systems Part 01. Karine Reis Ferreira

SQL Constraints and Triggers

SQL DATA DEFINITION: KEY CONSTRAINTS. CS121: Relational Databases Fall 2017 Lecture 7

Chapter 8 SQL-99: Schema Definition, Basic Constraints, and Queries

SQL: Part II. Announcements (September 18) Incomplete information. CPS 116 Introduction to Database Systems. Homework #1 due today (11:59pm)

Introduction to Data Management. Lecture #4 (E-R Relational Translation)

3.1. Keys: Super Key, Candidate Key, Primary Key, Alternate Key, Foreign Key

SQL Data Definition and Data Manipulation Languages (DDL and DML)

Constraints. Local and Global Constraints Triggers

Lecture 5: SQL s Data Definition Language

Data Definition and Data Manipulation. Lecture 5: SQL s Data Definition Language CS1106/CS5021/CS6503 Introduction to Relational Databases

Interview Questions on DBMS and SQL [Compiled by M V Kamal, Associate Professor, CSE Dept]

SQL Interview Questions

Fundamentals, Design, and Implementation, 9/e Copyright 2004 Database Processing: Fundamentals, Design, and Implementation, 9/e by David M.

Introduction to Data Management CSE 344

Database Management Systems. Chapter 3 Part 1

Sql Server Syllabus. Overview

SQL: Part II. Introduction to Databases CompSci 316 Fall 2018

Lecture 08. Spring 2018 Borough of Manhattan Community College

ENHANCING DATABASE PERFORMANCE

Chapter 8: Working With Databases & Tables

ITCS 3160 DATA BASE DESIGN AND IMPLEMENTATION

5 Integrity Constraints and Triggers

Downloaded from

CSE 530A. Inheritance and Partitioning. Washington University Fall 2013

Transcription:

SQL for SQL Server 1 True/False Questions Chapter 2 Creating Tables and Indexes 1. In order to create a table, three pieces of information must be determined: (1) the table name, (2) the column names, and (3) the column data types. Answer: False Page Reference: 31 Difficulty: Easy 2. The NUMBER data type stores integer, fixed-point and floating-point, and monetary numbers. Answer: True Page Reference: 32 Difficulty: Hard 3. The default T-SQL date format is MM/DD/YY. Answer: False Page Reference: 36 Difficulty: Medium 4. Field names must include their table s name. For example, emp_ssn and emp_salary are fields in the emp table. Answer: False Page Reference: 38 Difficulty: Easy 5. Constraints are different types of data integrity. Answer: True Page Reference: 39 Difficulty: Easy 6. By default a PRIMARY KEY constraint is NOT NULL. Answer: True Page Reference: 40 Difficulty: Medium 7. The ALTER TABLE command can add a new column or modify an existing column. Answer: True Page Reference: 43 Difficulty: Medium 8. PRIMARY KEY constraints are used to enforce referential integrity. Answer: False Page Reference: 45 Difficulty: Easy 9. A FOREIGN KEY constraint cannot reference a column in a table that has not been created yet. Answer: True Page References: 45-46 Difficulty: Medium 10. The REFERENCES clause is required in a FOREIGN KEY constraint. Answer: True Page Reference: 47 Difficulty: Medium 11. By default the FOREIGN KEY constraint allows the user to delete rows that have associated dependent rows. Answer: False Page Reference: 47 Difficulty: Easy 12. The DELETE command is one of the simplest SQL statements, but can be very dangerous. Answer: True Page Reference: 52 Difficulty: Easy 13. The ALTER command changes the structure of a column, whereas the UPDATE command changes the contents of a column. Answer: True Page Reference: 52 Difficulty: Hard 14. The ROLLBACK command cancels operations to the database.

2 Chapter 2 Creating Tables and Indexes Answer: False Page Reference: 53 Difficulty: Hard 15. Indexes cannot be changed. Answer: True Page Reference: 58 Difficulty: Hard Multiple-Choice Questions 16. Numeric data not used for calculations should be stored in a column of what data type? a. FLOAT b. INTEGER c. REAL d. VARCHAR Answer: D Page Reference: 33 Difficulty: Hard 17. The default data format in T-SQL is: a. MM/DD/YYYY b. DD/MM/YYYY c. MMM DD YYYY d. DD-MON-YYYY Answer: C Page Reference: 36 Difficulty: Medium 18. A column or set of columns that uniquely identifies a row. a. Foreign key b. Primary key c. Secondary key d. Unique key Answer: B Page Reference: 39 Difficulty: Easy 19. A constraint that requires that the data values stored in a specific column must fall within some acceptable range of values. a. CHECK constraint b. NOT NULL constraint c. PRIMARY KEY constraint d. UNIQUE constraint Answer: A Page Reference: 40 Difficulty: Medium 20. Which of the following is NOT possible using the ALTER TABLE command? a. Add a new field b. Drop an existing field c. Modify the datatype of an existing field d. Change the name of an existing field Answer: D Page Reference: 44 Difficulty: Hard 21. A column or set of columns used to enforce referential integrity. a. Foreign key b. Primary key c. Secondary key d. Unique key Answer: A Page Reference: 47 Difficulty: Easy

SQL for SQL Server 3 22. Which of the following is NOT a valid optional clause in a FOREIGN KEY constraint? a. On Delete Cascade b. On Delete Modify c. On Delete No Action d. On Update Cascade Answer: B Page Reference: 47 Difficulty: Hard 23. A SQL command that removes a database object. a. DELETE b. DROP c. REMOVE d. TRUCATE Answer: B Page Reference: 50 Difficulty: Medium 24. A SQL command that adds a database object. a. ADD b. CREATE c. INSERT d. MAKE Answer: B Page Reference: 38 Difficulty: Medium 25. A SQL command that changes a database object. a. ALTER b. MODIFY c. REVISE d. UPDATE Answer: A Page Reference: 43 Difficulty: Medium 26. A SQL command that changes one or more values in a row. a. ALTER b. MODIFY c. REVISE d. UPDATE Answer: D Page Reference: 52 Difficulty: Medium 27. A SQL command that removes one or more rows. a. DELETE b. DROP c. REMOVE d. TRUCATE Answer: A Page Reference: 52 Difficulty: Medium 28. A SQL command that adds a row. a. ADD b. CREATE c. INSERT d. MAKE Answer: C Page Reference: 51 Difficulty: Medium 29. Which of the following is NOT a type of limitation on indexes? a. The maximum size of an index entry. b. The maximum number of columns in a composite index.

4 Chapter 2 Creating Tables and Indexes c. The number of indexes per table. d. The kind of index only nonclustered are supported. Answer: D Page Reference: 55 Difficulty: Easy Essay Questions 30. Compare and contrast the CHAR and VARCHAR data types. Answer: Both data types store character data. However, the CHAR data type stores fixed-length data (padding it with blank spaces if necessary) and the VARCHAR data type stores variablelength data. Page Reference: 34 Difficulty: Easy 31. What is the TIMESTAMP data type used for? Answer: The TIMESTAMP data type is used to determine the relative time when a data row was last modified or when a data row was initially created. Page Reference: 37 Difficulty: Medium 32. Briefly describe each of the four types of integrity constraints. Answer: The NOT NULL constraint means that a row of data must have a value for the column specified as NOT NULL. The UNIQUE constraint is used to enforce uniqueness for a column value. The CHECK constraint forces data values stored in a specific column to fall within some acceptable range of values. The PRIMARY KEY constraint is used to uniquely identify rows of data. Page References: 39-41 Difficulty: Hard 33. List at least three changes that can be made using the ALTER TABLE command. Answer: The ALTER TABLE command can: alter existing columns, add new columns, set default column values, disable and re-enable column constraints, and drop a column. Page Reference: 44 Difficulty: Hard 34. Describe referential integrity. Answer: Referential integrity stipulates that values of a foreign key must correspond to values of a primary key in the table that it references or be NULL. Page Reference: 47 Difficulty: Medium 35. Describe the three optional clauses in a FOREIGN KEY constraint. Answer: ON UPDATE CASCADE will propagate any update on the referenced table to the referencing table. ON DELETE CASCADE will propagate any deletion on the referenced table to the referencing table. ON DELETE NO ACTION will reject a deletion of a primary key value unless no foreign key references that value. Page Reference: 47 Difficulty: Hard 36. What is a composite primary key? Answer: A composite primary key is a primary key containing two or more columns in order to uniquely identify each row. Page Reference: 49 Difficulty: Medium 37. Briefly describe the SQL commands to populate, manipulate, and remove rows. Answer: The INSERT command adds a row to a table. The UPDATE command modifies an existing row. The DELETE command removes one or more rows from a table.

SQL for SQL Server 5 Page References: 51-52 Difficulty: Easy 38. How is updating a column different from modifying it? Answer: The ALTER command changes the table structure, but leaves the table data unaffected. The UPDATE command changes the table data, but not the table structure. Page Reference: 52 Difficulty: Medium 39. How are transactions handled in SQL Server by default? Answer: Unlike most relational DBMS products, SQL Server automatically commits after every INSERT, UDPATE, or DELETE operation. Page Reference: 53 Difficulty: Hard 40. What is a derived column? Answer: A derived or computed column where the values stored are derived by computations involving data stored in other columns in the table. Page References: 53-54 Difficulty: Hard 41. What is the primary benefit of an index? Answer: An index facilitates the rapid retrieval of information from tables. Page Reference: 54 Difficulty: Medium 42. What are the problems when using an index? Answer: All indexes on a table must be updated whenever a row is changed or deleted that is referenced by an index. Indexes also require disk space. Page References: 57-58 Difficulty: Medium