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.
T/F: There are multiple mapping functions available in RDBMSs to change date formats for the DATE data type.
true.
Timestamp date type include the ______ and _____ fields.
DATE, TIME.
T/F: The timestamp data type comes with an additional minimum of six positions for decimal fractions of seconds.
true.
T/F: The timestamp data type has an optional WITH TIME ZONE qualifier.
true.
The ______ data type specifies a relative value that can be used to increment or decrement an absolute value of a date, time, or timestamp
interval
DATE, TIME, Timestamp, INTERVAL data types can be _______ or converted to _______ formats for comparison.
cast, string.
T/F: The domain name is used with the attribute specification
true. EX: CREATE DOMAIN Ssn_types AS CHAR(9);
T/F: The domain makes it easier to change the data type for a domain that is used by numerous attributes.
true.
The domain improves schema ______.
readability.
T/F: User Defined Types (UDTs) are supported for object-oriented applications.
True.
Name the relational model’s 3 basic contraint types that are supported in SQL.
Key constraint, entity integrity constraint, and referential integrity.
The ______ constraint is where a primary key cannot be duplicated.
key
The _______ contraint is where a primary key value cannot be null.
entity integrity
The referential constraint is where the foreign key must have a value that is already present as a primary key or may be ______.
null.
Name the attribute constraint that is used on the attribute domain to assign a default value for an attribute.
DEFAULT <value|>
(ignore the line | it is only there because of a technical issue)