UNIT 1-3 Flashcards
SQL includes commands to create database objects such as tables, indexes, and views, as well as commands to define access rights to those database objects.
data definition language (DDL):
SQL includes commands to insert, update, delete, and retrieve data within the database tables.
data manipulation language (DML):
You merely command what is to be done; you don’t have to worry about how it is to be done.
SQL is a nonprocedural language
a group of database objects—such as tables and indexes—that are related to each other.
Schema
They help distinguish the kinds of data that can be stored or processed inside our database objects.
Data Types
Fixed character length data, 1 to 255 characters
CHAR
Variable character length data,1 to 2,000 characters.
VARCHAR
Numeric data. decimal(9,2)is used to specify numbers with two decimal places and up to nine digits long, including the decimal places. Some RDBMSs permit the use of a MONEY or a CURRENCY data type.
Decimal
Integer values only
INT
Small integer values only
SMALLINT
formats vary. Commonly accepted formats are: ’DD-MON-YYYY’, ’DD-MON-YY’, ’MM/DD/YYYY’, and ’MM/DD/YY’
DATE
a collection of related data held in a table format within a database. It consists of columns and rows.
TABLE
In ___________ and flat file databases, a table is a set of data elements (values) using a model of vertical columns (identifiable by name) and horizontal rows, the cell being the unit where a row and c.
relational databases
Each _____ type has an associated T-SQL statement format with various implementations.
constraint
A column or combination of columns whose values uniquely identify each row in the table
PRIMARY KEY
A column or combination of columns used to establish and enforce a link between the data in two tables
FOREIGN KEY
Ensures that no duplicate values are entered in specific columns that do not participate in a primary key
UNIQUE
Enforces domain integrity by limiting the values that are accepted by a column
CHECK
Defines column values stored when no value has been assigned
DEFAULT
Designates that a column will accept null values
Nullability
_____ can be used to improve the efficiency of searches and to avoid duplicate column values.
indexesCREATE[UNIQUE] INDEX indexname ON tablename(column1[, column2])
is a function that returns the current system date
getdate()
is a TSQL function that add a particular date interval from a given column or value. Its accepts the following parameters :
dateadd()dateadd ([day type such as year, day, hour, minute etc.], [integer value], [column name or date value])
is a MySQL function that subtracts a particular date interval from a given column or value.
date_subdate_sub([column name or date value], INTERVAL [integer value] [day type such as year, day, hour, minute etc.])
Remember the rule of precedence
- Perform operations within parentheses.2. Perform power operations.3. Perform multiplications and divisions.4. Perform additions and subtractions.
We use ___ if both conditions are true, ___ if at least one of the condition and ___ if we want to negate the result of a conditional expression.
AND, OR, NOT
ANSI-standard SQL allows the use of _______ in conjunction with the WHERE clause
Special Operators
Used to check whether an attribute value is within a range
BETWEENselect * from tbl_food where fd_price between 10 and 100;
Used to check whether an attribute value is null
IS NULLselect * from tbl_food where fd_name is null;