Chapter 6 Flashcards
Basic SQL.
SQL schema Identified by a _________ Includes an authorization _________ and ___________ for each element.
schema name, identifier, descriptors.
Each statement in SQL ends with a _________.
semicolon
T/F: Schema elements include tables, constraints, views, domains, and other constructs.
true.
___________ is the named collection of schemas in an SQL environment.
catalog
T/F: SQL also has the concept of a cluster of catalogs.
true.
What is the schema creation statement?
CREATE SCHEMA <schema>;</schema>
In Create table statement, you need to specify the _______, their _______, and _________.
attributes, types, intial constraints.
______________ are created through the CREATE VIEW statement. Do not correspond to any physical file.
Virtual relations (views)
___________ where the relation and its tuples are actually created and stored as a file by the DBMS.
Base tables (base relations)
T/F: There can be an attribute referencing another attribute within the same table.
True. EX: Super_ssn is referencing Ssn.
T/F: There can exist a table in which all of it’s attributes consist of a primary key and a foreign key.
true.
Write a creation statemement for: Table Employee with employee’s first name, sex, salary, birth date, department number, ssn, and super ssn.
CREATE TABLE Employee (
Fname VARCHAR(15) NOT NULL,
Sex CHAR,
Salary Decimal(10, 2),
Ssn CHAR(9),
Super_ssn CHAR(9),
Bdate DATE,
Dno INT NOT NULL,
PRIMARY KEY (Ssn) );
Name 2 reason why a foreign key might cause an error.
1- Circular references
2- They refer to a table that has not yet been created.
Name the 5 basic attribute data types in SQL.
Numeric, character-string, bit-string, boolean, date.
Name the 2 numeric data types in SQL.
Interger numbers, Floating-point(real) numbers.
Name the 2 character-string data types.
fixed length, varying length.
INT, INTEGER, and _________ are examples of integer data types.
SMALLINT
FLOAT (or _____) and DOUBLE PRECISION are examples of floating-point number data types.
REAL
T/F: CHAR (n), and CHARACTER (n) are examples of varying length character-string data types.
f, fixed.
VARCHAR (n), CHAR VARYING (n), and CHARACTER VARYING (n) are examples of ____________ data types.
character-string.
T/F: Bit-string data types can be fixed or varying length.
T, EX: BIT(n) is fixed length, and BIT VARYING (n) is varying length.
Boolean data types have values of TRUE or FALSE or _______ for NULL.
UNKNOWN.
The DATE data type has ____ positions.
ten
T/F: The DATE data type components are YEAR, MONTH, and DAY in the form YYYY-DD-MM.
False, it is in the form YYYY-MM-DD.