CH2

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall with Kai
GameKnowt Play
New
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/56

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

57 Terms

1
New cards

In the relational model, an unnamed tuple of values is a ______.

row

2
New cards

What is the result of a relational operation?

Table

3
New cards

In a relational model, a column is _______.

A name and a data type

4
New cards

A ______ is a collection of values with no inherent order.

set

5
New cards

_____ is not a relational algebra operation

Merge

6
New cards

What does SQL stand for?

Structured Query Language

7
New cards

UPDATE, SELECT, and ORDER BY are ____ in an SQL Statement

keyword

8
New cards

In the SQL below, which of the following is an identifier?

UPDATE Product

SET UnitPrice = 9.50

WHERE ProductId = 20;

Product

9
New cards

What language defines statements used for creating and dropping tables?

Data definition language

10
New cards

The statement below is an example from which SQL sublanguage?

SELECT ProductName

FROM Product;

Data Query Language

11
New cards

What is the correct statement for creating a database called reservationDB?

CREATE DATABASE reservationDB;

12
New cards

A database system has a database called onlineShop. What is the result of a CREATE statement that tries to create onlineShop a second time.

The statement produces an error that indicates the database already exists.

13
New cards

What is the correct statement for deleting a database?

DROP DATABASE DatabaseName;

14
New cards

What should be added to the SQL statements to produce the Result table below?

USE ______;

SHOW _________;

Result:

Tables_in_onlineShop

blah

blah

blah

blah

onlineShop

TABLES

15
New cards

In a table, columns are _____ and rows are ______.

ordered

not ordered

16
New cards

Data independence means

rows of a table have no inherent order

17
New cards

How many columns are created by the SQL statement below?

CREATE TABLE Supplier (

SupplierId INT,

CompanyName VARCHAR(40),

ContactName VARCHAR(50),

City VARCHAR(40),

Country VARCHAR(40),

Phone VARCHAR(30)

);

6

18
New cards

Which SQL statement deletes the table supplier?

DROP TABLE Supplier;

19
New cards

Which SQL statement adds a new column Fax to the Supplier table?

ALTER TABLE Supplier

ADD Fax VARCHAR(30);

20
New cards

Which SQL Statement deletes the City column from the Supplier table?

ALTER TABLE Supplier

DROP City;

21
New cards

What data type stores binary values?

BLOB

22
New cards

Which data type should a database use to store negative numbers?

INT

23
New cards

Choose the best data types to replace XXX and YYY.

CREATE TABLE Product (

ProductId INT,

ProductName XXX,

UnitPrice YYY

);

VARCHAR(50)

DECIMAL(8,2)

24
New cards

A value that is used in a computation is known as a/an ______.

operand

25
New cards

What is the correct order of operator precedence in SQL (high to low)?

* + = NOT AND OR

26
New cards

Which statement selects all rows and just the ProductName and Size columns from the Product table?

SELECT ProductName, Size

FROM Product;

27
New cards

Refer to the product table. Which columns are preset in the query's result table?

SELECT * FROM Product;

all columns are present

28
New cards

Refer to the product table. Which columns are preset in the query's result table?

SELECT ProductName FROM Product WHERE Quantity >= 10;

onesies set, sunsuit, pj set

29
New cards

Refer to the Product table. Which products are selected by the query below?

SELECT * FROM Product WHERE Quantity > 5 AND UnitPrice <= 15.00;

onsies set, pj set, shorts set

30
New cards

In mySQL what is the result of TRUE AND NULL?

NULL

31
New cards

what should be added so null values are not allowed in productname?

CREATE TABLE Product ( ProductId INT, ProductName _____, UnitPrice DECIMAL(5,2), SupplierId INT );

VARCHAR(50) NOT NULL

32
New cards

In mySQL, what is the result of TRUE OR NULL

TRUE

33
New cards

a null value represents ____.

missing data

34
New cards

In MySQL, if salary is null then salary > 5000 is ___ and Salary IS NOT NULL is ____.

NULL

False

35
New cards

Which of the following is true about the insert statement?

FALSE: A single INSERT statement can only add one row.

The column names can be omitted in an INSERT statement.

The INSERT statement is used to add new values to a table.

The VALUES order must match the column order in the INTO clause.

36
New cards

Refer to the Supplier table. Which statement correctly changes Adan Stevens to Maria Stevens?

UPDATE Supplier SET ContactName = 'Maria Stevens' WHERE SupplierID = 5;

37
New cards

What values for CountryID do the suppliers Sugarplum and Periwinkle have after the UPDATE statement executes?

UPDATE Supplier SET CountryID = 2 WHERE CountryID IS NULL;

2, 2

38
New cards

Which suppliers remain in the Supplier table after the DELETE statement executes?

DELETE FROM Supplier WHERE CountryID <= 2;

Lin Ming Co.

39
New cards

A column or group of columns that serves as the unique identifier in a relational database table is called a/an _____.

primary key

40
New cards

Which two rules apply to primary keys?

values must be unique and may not be NULL

41
New cards

Which column is best to replace XXX in the SQL statement below?

CREATE TABLE Supplier ( SupplierID INT AUTO_INCREMENT, CompanyName VARCHAR(40), ContactName VARCHAR(50), Phone VARCHAR(30), PRIMARY KEY (XXX) );

SupplierID

42
New cards

In the Reservation table below, a room may be reserved several times, so the RoomNumber column is not unique. To ensure that a room can only be reserved by only one guest for the day, the minimal primary key consists of which columns?

(RoomNumber, DateOfStay)

43
New cards

The Department table was created as follows:

CREATE TABLE Department ( DepartmentCode SMALLINT UNSIGNED AUTO_INCREMENT,

DepartmentName VARCHAR(20) NOT NULL,

PRIMARY KEY (DepartmentCode)

);

The Department table now contains the following rows:

Department CodeDepartmentName

1 Sales

2 Marketing

3 Development

What is the result of the following statement?

INSERT INTO Department (DepartmentName) VALUES ('Shipping');

The row (4, 'Shipping') is inserted.

44
New cards

Refer to the Teacher and Class tables. The TeacherID in the Class table references the TeacherID in the Teacher table. The TeacherID in the Class table is a/an _____.

Foreign key

45
New cards

what statement is a special case of foreign keys?

FALSE: Foreign key referring to a foreign key in the same table

Foreign key referring to a primary key in the same table

Multiple foreign keys referring to the same primary key

Composite foreign key referring to a composite primary key

46
New cards

A database designer wants to create three tables: Supplier, Product, and Country. The Supplier table has a CountryID column with values that must appear in the Country table's CountryID column. The Product table has a ProductID column. Which table's CREATE TABLE statement(s) must specify a FOREIGN KEY?

Supplier

47
New cards

ShipPartCode is a foreign key in the Shipment table. ShipPartCode refers to the primary key PartCode of the Part table. What replaces XXX in the following statement?

CREATE TABLE Shipment ( ShipNumber INT UNSIGNED, ShipPartCode CHAR(3) NOT NULL, Quantity SMALLINT UNSIGNED, PRIMARY KEY (ShipNumber), XXX );

FOREIGN KEY (ShipPartCode) REFERENCES Part (PartCode)

48
New cards

Refer to the Teacher and Class tables. To maintain referential integrity, which foreign key action rejects the deletion of the row containing Rosa Lopez?

RESTRICT

49
New cards

Refer to the Teacher and Class tables. The action ON UPDATE SET NULL is specified for the TeacherID foreign key. What is the result when Bryan McNeal's TeacherID is changed to 45672?

The teacherid for web development is set to NULL

50
New cards

Refer to the Teacher and Class tables. Which foreign key action updates the TeacherID for the Web Development course to 45672 when Bryan McNeal's TeacherID is updated to 45672?

CASCADE

51
New cards

Refer to the Teacher and Class tables. When Bryan McNeal is deleted from the Teacher table, the TeacherID for the Web Development course automatically changes to 11234. Which action has been specified for the TeacherID foreign key?

SET DEFAULT

52
New cards

What foreign key action should be added to ensure that if a supplier is removed from the Supplier table, the products associated with the same supplier are also removed?

CREATE TABLE Product ( ProductId INT NOT NULL AUTO_INCREMENT, ProductName VARCHAR(50), UnitPrice DECIMAL(5,2), SupplierId INT, PRIMARY KEY (ProductId), FOREIGN KEY (SupplierId) REFERENCES Supplier(SupplierId) _____ );

ON DELETE CASCADE

53
New cards

A/an ______ us a rule enforced on a table's data.

constraint

54
New cards

A ____ constraint specifies a column value that is used when no value is provided in an INSERT statement.

DEFAULT

55
New cards

Which of the following values violates the CHECK constraint below?

CREATE TABLE Customer ( CustomerId INT AUTO_INCREMENT, Name VARCHAR(60), Age INT CHECK (Age BETWEEN 18 AND 50), ShippingAddress VARCHAR(200), PRIMARY KEY (CustomerId) );

(456, "Sarah Mcgraw", 61, "12301 270th Pl, Seattle, WA 98126")

56
New cards

In the following statement, the UNIQUE clause is a _____ constraint.

CREATE TABLE Employee ( ID SMALLINT UNSIGNED, FullName VARCHAR(60), Extension CHAR(4), UNIQUE (ID, Extension), PRIMARY KEY (ID) );

table

57
New cards

which statement creates a primary key constraint on the ID column of the employee table?

ALTER TABLE Employee ADD PRIMARY KEY (ID);