You are on page 1of 17

Review Questions chapter 1

**Some basic terminology of chapter 1 :-

Data The raw facts are called as data. The word “raw” indicates that they
have not been processed.

Database A database is a collection of related data.


or
A database is a collection of information that is organized
so that it can be easily accessed, managed and updated

DBMS A database-management system (DBMS) is a collection of interrelated


data and a set of programs to access those data.
The DBMS is a general purpose software system that facilitates the
process of defining constructing and manipulating
databases for various applications.

Database A Database Management System (DBMS) is a system (software) that


provides an interface to database for
system information storage and retrieval. We are more interested
in software systems rather than manual systems because
they can do the job more efficiently.

Uses of DBMS :

- Effective and efficient management of data. - Query processing and


management.
- Security and integrity of data. - Data sharing and
storage.
Advantages of DBMS :
- Less space consumes. - Reduction of redundancy.
- Data integrity, security, and continuity. -
Backup and recovery process.
- Data model can be developed. - Concurrency
control.
- Data independence. -
Performance is good.
Disadvantages of DBMS :
- Required large size of memory. - Time-consuming.
- Required a processor with the high - Complex.
speed of data processing.
- Cost of data conversion. -
Expensive.
- Database failure (DB corrupted due - Higher impact of a
failure (if any component
to power failure or whole system stops).
can bring the operation to a halt).
- Cost of DBMS (depend on the environment
function or recurrent annual maintenance cost.

Database Catalog A catalogue is a book or magazine containing details and


pictures of items currently being
offered for sale, especially as used by companies that do
much of their business by mail order.
The database catalogue of a database instance
consists of metadata in which definitions of database
objects such as base tables, views, synonyms,
value ranges, indexes, users, and user groups are stored.

Data Independence It means we change the physical storage/level without


affecting the conceptual or
external view of the data. The new changes are absorbed by
mapping techniques. Logical data independence
is the ability to modify the logical schema without
causing application program to be rewritten.

User View A database view is a searchable object in a database that is defined


by a query. Though a view doesn't store data,
some refer to a views as “virtual tables,” you can query a
view like you can a table. A view can combine data from two
or more table, using joins, and also just contain a subset
of information

DBA A database administrator (DBA) is a specialized computer systems


administrator who maintains a successful
database environment by directing or performing all related activities
to keep the data secure. The top responsibility
of a DBA professional is to maintain data integrity.Database
administrators use specialized software to store and
organize data.
The role may include capacity planning, installation, configuration,
database design, migration, performance monitoring,
security, troubleshooting, as well as backup and data recovery

End User An end user is the person that a software program or hardware
device is designed for. The term is based
on the idea that the "end goal" of a software or hardware
product is to be useful to the consumer.

Canned Transaction Canned transactions are standard types of queries and updates
which are frequently
used by Naive end users to constantly querying and updating
database. These are the transactions
that are carefully programmed and tested in advance

Deductive A deductive database is a database system that can make deductions


Database (i.e., conclude additional facts) based on rules and
facts stored in the (deductive) database.
System Datalog is the language typically used to specify facts, rules
and queries in deductive databases

Persistent Object A persistent object is an object that has been assigned a


storage location in a federated database.
When you commit the transaction in which you
create a persistent object, that object's data is saved in the database;
the object can then be accessed by other processes.
A persistent object store is a type of computer storage system
that records and retrieves complete objects, or
provides the illusion of doing so.

Meta-Data Metadata is data that describes other data. Meta is a prefix that in
most information technology usages
means "an underlying definition or description." Metadata
summarizes basic information about data, which can make
finding and working with particular instances of data
easier.

Transaction Transaction processing means dividing information processing up into


individual,
indivisible operations, called transactions, that complete or
fail as a whole; a transaction can’t remain in an
intermediate, incomplete, state (so other processes can’t access the
transaction’s data until either the transaction
has completed or it has been “rolled back” after failure).
Transaction processing is designed to maintain database
integrity (the consistency of related data items) in a
known, consistent state

Q.2. What four main types of actions involve databases?


Database Administration
Database Designing,
Database user,
System Analysis, and
Application programming

3. Discuss the main characteristics of the database approach and how it differs
from traditional file systems.

* Represent Some Aspects of real world applications


A database represents some features of real world applications. Any change in
the real world is reflected in the database.
If we have some changes in our real applications like railway reservation
system then it will be reflected in database too.
For example, let us take railway reservation system; we have in our mind some
certain applications of maintaining records
of attendance, waiting list, train arrival and departure time, certain day
etc. related to each train.

* Manages Information
A database always takes care of its information because information is always
helpful for whatever work we do.
It manages all the information that is required to us. By managing
information using a database, we become more deliberated
user of our data.

* Easy Operation implementation


All the operations like insert, delete, update, search etc. are carried out
in a flexible and easy way.
Database makes it very simple to implement these operations. A user with
little knowledge can perform these operations.
This characteristic of database makes it more powerful.
* Multiple views of database
Basically, a view is a subset of the database. A view is defined and devoted
for a particular user of the system.
Different users of the system may have different views of the same system.
Every view contains only the data of
interest to a user or a group of users. It is the responsibility of users to
be aware of how and where the data of their interest is stored.

* Data for specific purpose


A database is designed for data of specific purpose. For example, a database
of student management system is designed to maintain the record of
student’s marks, fees and attendance etc. This data has a specific purpose of
maintaining student record.

* It has Users of Specific interest


A database always has some indented group of users and applications in which
these user groups are interested.
For example, in a library system, there are three users, official
administration of the college, the librarian, and the students.

* Self Describing nature


A database is of self describing nature; it always describes and narrates
itself. It contains the description of the whole data structure,
the constraints and the variables. It makes it different from traditional
file management system in which definition was not the part
of application program. These definitions are used by the users and DBMS
software when needed.

* Logical relationship between records and data


A database gives a logical relationship between its records and data. So a
user can access various records depending upon the logical conditions by a
single query from the database.

* Shelter between program and data


In traditional file management system, if any user makes changes in the
structure of a file then all the programs accessed by
that file needed to be changed. The structure of data files is defined by the
application programs.
But in database approach the data structure is carried in system catalog not
in the program.

Q. 4. What are the responsibilities of the DBA and the database designers?
Database administrators (DBAs) use specialized software to store and organize data.
The role may include capacity planning, installation,
configuration, database design, migration, performance monitoring, security,
troubleshooting, as well as backup and data recovery.
The database designer is responsible for defining the detailed database design,
including tables, indexes, views, constraints, triggers,
stored procedures, and other database-specific constructs needed to store,
retrieve, and delete persistent objects. This information is
maintained in the Artifact: Data Model.

Q.5. What are the different types of database end users?


End users are basically those people whose jobs require access to the database for
querying, updating and generating reports.
The database primarily exists for their use. There are several categories of end
users these are as follows:

1. Casual End Users –


These are the users who occasionally access the database but they require different
information each time.
They use a sophisticated database query language basically to specify their request
and are typically middle or level
managers or other occasional browsers. These users learn very few facilities that
they may use repeatedly from the multiple facilities
provided by DBMS to access it.

2. Naive or parametric end users –


These are the users who basically make up a sizeable portion of database end users.
The main job function revolves basically
around constantly querying and updating the database for this we basically use a
standard type of query known as canned
transaction that have been programmed and tested. These users need to learn very
little about the facilities provided by
the DBMS they basically have to understand the users’ interfaces of the standard
transaction designed and implemented for their use.
The following tasks are basically performed by Naive end users:

The person who is working in the bank will basically tell us the account balance
and post-withdrawal and deposits.
Reservation clerks for airlines, railway, hotels, and car rental companies
basically check availability for a given request
and make the reservation.
Clerks who are working at receiving end for shipping companies enter the package
identifies via barcodes and
descriptive information through buttons to update a central database of received
and in transit packages.

3. Sophisticated end users –


These users basically include engineers, scientist, business analytics and others
who thoroughly familiarize
themselves with the facilities of the DBMS in order to implement their application
to meet their complex requirement.
These users try to learn most of the DBMS facilities in order to achieve their
complex requirements.

4. Standalone users –
These are those users whose job is basically to maintain personal databases by
using a ready-made program package
that provides easy to use menu-based or graphics-based interfaces, An example is
the user of a tax package that basically
stores a variety of personal financial data of tax purposes. These users become
very proficient in using a specific software package.

Q.6. What are the capabilities that should be provided by a DBMS.


create objects to hold data
insert data into an object
update data elements in an object
delete data elements from an object
retrieve data elements from an object
prevent loss of data

Q. 7. Discuss the difference between DBMS and FILE SYSTEM.


FILE SYSTEM - A file system is a software that manages the data files in a computer
system.
DBMS - DBMS is a software to create and manage databases.

1 Usage
File system helps to store a collection of raw data files into the hard disk.
DBMS helps to easily store, retrieve and manipulate data in a database.
This is the main difference between file system and DBMS.

2 Operations
Tasks such as storing, retrieving and searching are done manually in a file system.
Therefore, it is difficult
to manage data using a file system. On the other hand, operations such as updating,
searching,
selecting data is easier in DBMS because it allows using SQL querying.

3 Data Consistency
File system has data inconsistency whereas DBMS provides higher data consistency
using normalization.

4 Data Redundancy
There is more redundant data in a file system whereas there is low data redundancy
in a DBMS.

5 Security
DBMS provides more security to the data than the file system.

6 Backup and Recovery Process


Backup and recovery process is not efficient in files system because it is not
possible to
recover the lost data. On the contrary, a DBMS has a sophisticated backup and
recovery.

7 Users
File system is appropriate to handle data of a small-scale organization or
individual users.
On the other hand, DBMS is suitable for medium to large organizations or multiple
users.

8 Complexity
Handling the file system is simple but handling a DBMS is complex.

Examples
NTFS and Ext are some examples of file systems. MySQL, MSSQL, Oracle, and DB2 are
some examples of DBMS.

---------------===========----------------THE END OF CHAPTER 1-----------------


============------------------

**Some basic terminology of chapter 2 :-

Data Model Data models define how the logical structure of a


database is modeled. Data Models are fundamental entities to introduce
abstraction in a DBMS.
Data models define how data is connected to each other and how they are
processed and stored inside the system.
Database Schema A database schema is the skeleton structure that represents
the logical view of the entire
database. It defines how the data is organized and how the relations
among them are associated.
It formulates all the constraints that are to be applied on the data.

Database State Database state may refer to Database state; in database


technology the set of stored data.
Entering, modifying, or deleting information changes the database
state.
Actual data stored in a particular moment in time. See also State
transition system and Finite-state
machine models.

Internal Schema The internal schema is a very low-level representation of the


entire database. It contains
multiple occurrences of multiple types of internal record. In the ANSI
term, it is also called "stored record'.
Facts about Internal schema: The internal schema is the lowest level of
data abstraction.

Conceptual Schema A 'conceptual schema' is a high-level description of a


business's informational needs.
It typically includes only the main concepts and the main relationships
among them. Typically this is a
first-cut model, with insufficient detail to build an actual database.

External Schema An external schema describes the part of the database which
specific user is interested in.
It hides the unrelated details of the database from the user.

Data Independence Data independence is the type of data transparency that matters
for a centralized DBMS.
Meta data follows a layered architecture, so that when we change data
at one layer, it does not affect the data
at another level. Data independence is ability to modify a schema
definition in one level without affecting
a schema definition in the next higher level.
There are two levels of data independence: Physical Data Independence,
Logical Data Independence.

DDL(Data Definition : DDL or Data Definition Language actually consists of the


SQL commands
Language) that can be used to define the database schema.

DML(Data Manipulation : The SQL commands that deals with the manipulation of data
present
Language) in database belong to DML or Data Manipulation Language and this
includes most of the SQL statements

SDL (Specification SDL is a program design and implementation language that is


used to build real-time
Description event-driven systems that involve parallel processing .
Language)

View Definition This language is used to specify user views and their mapping to
conceptual
Language schema. It defines the subset of records available to classes of
users.
It creates virtual tables and the view appears to users like conceptual
level.It specifies user interfaces.

Query Language - Query language (QL) refers to any computer programming language
that requests and retrieves
data from database and information systems by sending queries. It works on user
entered structured and formal
programming command based queries to find and extract data from host databases.
Query language may also be termed database query language.

Host Language - The language that is used for database application programming is
the host language for the DBMS.
As mentioned earlier, a host language may be a traditional programming language,
such as C or COBOL, or it may
be an application-level language, such as Microsoft Access or Visual Basic, as it
is for the Jet DBMS.

Database Utility - The database utility is the interface between the ABAP
Dictionary and the relational database
underlying the SAP system. The database utility allows you to edit (create, delete
and adjust to changes to their
definition in the ABAP Dictionary) database objects derived from objects of the
ABAP Dictionary.

Client/server Architecture - Client/server architecture is a computing model in


which the server hosts, delivers and
manages most of the resources and services to be consumed by the client. This type
of architecture has one or more
client computers connected to a central server over a network or internet
connection.

Three-tier Architecture, and n-tier Architecture - A three-tier architecture is a


client-server architecture in which the
functional process logic, data access, computer data storage and user interface
are developed and
maintained as independent modules on separate platforms.
N-tier architecture is also called multi-tier architecture because the software is
engineered to have the processing,
data management, and presentation functions physically and logically separated.

Q.2. Discuss the main categories of data models. What are the basic differences
between the relational model,
the object model, and the XML model?
There are mainly three different types of data models:
1. Conceptual: This Data Model defines WHAT the system contains. This model is
typically created by Business
stakeholders and Data Architects. The purpose is to organize, scope and define
business concepts and rules.
2. Logical: Defines HOW the system should be implemented regardless of the DBMS.
This model is typically
created by Data Architects and Business Analysts. The purpose is to developed
technical map of rules and
data structures.
3. Physical: This Data Model describes HOW the system will be implemented using a
specific DBMS system.
This model is typically created by DBA and developers. The purpose is actual
implementation of the database.
The relational model used the basic concept of a relation or table. The columns or
fields in the table identify
the attributes such as name, age, and so. A tuple or row contains all the data of a
single instance of the
table such as a person named Doug.
Three concepts are critical to understanding object models. They are:
Data Abstraction
Encapsulation
Inheritance
XML - Enabled Database
XML enabled database is nothing but the extension provided for the conversion of
XML document.
This is a relational database, where data is stored in tables consisting of rows
and columns.
The tables contain set of records, which in turn consist of fields.

Q.3. What is the difference between a database schema and a database state?
A database schema or an intention gives a description of the database. This can be
considered as a
blueprint of a database, and gives a list of fields in the database with their data
types. In other words,
it describes the organization and structure of data in a database system, along
with the relationships
mapped between the entities.
A database state provides the present state of the database and its data. It can be
considered as an
extension of the database schema. When a database is newly defined, the
corresponding database state
is empty. Factors that affect a database state are entering, deleting or modifying
information in the database.

Q. 4. Describe the three-schema architecture.Why do we need mappings between


schema levels?
How do different schema definition languages support this architecture?
The three schema architecture is also called ANSI/SPARC architecture or three-level
architecture.
This framework is used to describe the structure of a specific database system.
The three schema architecture is also used to separate the user applications and
physical database.
The three schema architecture contains three-levels. It breaks the database down
into three different categories.
1. Internal Level
The internal level has an internal schema which describes the physical storage
structure of the database.
The internal schema is also known as a physical schema.
It uses the physical data model. It is used to define that how the data will be
stored in a block.
The physical level is used to describe complex low-level data structures in detail.
2. Conceptual Level
The conceptual schema describes the design of a database at the conceptual level.
Conceptual level is also known
as logical level. The conceptual schema describes the structure of the whole
database.
The conceptual level describes what data are to be stored in the database and also
describes
what relationship exists among those data. In the conceptual level, internal
details such as an implementation
of the data structure are hidden. Programmers and database administrators work at
this level.
3. External Level
At the external level, a database contains several schemas that sometimes called as
subschema.
The subschema is used to describe the different view of the database.
An external schema is also known as view schema. Each view schema describes the
database part
that a particular user group is interested and hides the remaining database from
that user group.
The view schema describes the end user interaction with database systems.

Q.5. What is the difference between logical data independence and physical data
independence?
Which one is harder to achieve? Why?

Q.6. What is the difference between procedural and nonprocedural DMLs?


Non-procedural DMLis called high level DML. Can be used on its own to specify
complex database operations.
Specifies which/what data to retrieve rather than how to retrieve it. declarative
languages
Procedural DMLis low level DML. Must be embedded in a general purpose language.
Individual records are
objects from the database and process each separately. Needs program language for
looping etc

Q.7. Discuss the different types of user-friendly interfaces and the types of
users who typically use each.
Types of user-friendly interfaces and who uses them:Interfaces for the DBA:
Interfaces for DBA include commands for creating accounts, setting system
parameters, granting account
authorization, changing a schema, and reorganizing the storage structures of a
database.
Interfaces for parametric Users: Interfaces for parametric users usually have a
small set of operations that
they must perform repeatedly. Example: some of these parametric users are bank
tellers.
Speech Input and Output - Speech input and output have limited use of speech as an
input query and
speech as an answer. Speech input is detected using a library of predefined words
and also sets up the
parameters that are supplied to queries.
Natural Language Interfaces - Natural language interfaces can accept a request
written in a distinct
language and try to understand them. Interpretations can be successful and
generates a high level query
corresponding to the natural language and submits it to the DBS for processing.
Graphical User Interfaces - Graphical user interface also known as GUI typically
displays a schema to the
user in diagrammatic form. GUIs are mostly user friendly and use components such
as: pointers, buttons,
text fields.
Forms Based Interfaces - Forms based interfaces display a certain form to each
user. A user can fill out all
of the form entries to insert new data, or they can fill out only certain entries,
in which case the
DBMS will retrieve matching data for the other remaining entries.
Menu Based Interfaces for Web Clients or Browsing - Throughout this menu based
interface for web
clients or browsing users are presented a list of options through the menus that
lead the user through
the formulation of a request. One of the most popular technique in web based user
interface are
the pull down menus.

Q.8. What is the difference between the two-tier and three-tier client/server
architectures?
The two-tier is based on Client Server architecture. The two-tier architecture is
like client server application.
The direct communication takes place between client and server. There is no
intermediate between client
and server. Because of tight coupling a 2 tiered application will run faster.
Three-tier architecture typically comprise a presentation tier, a business or data
access tier, and a data tier.
Three layers in the three tier architecture are as follows:

1) Client layer
2) Business layer
3) Data layer

1) Client layer:
It is also called as Presentation layer which contains UI part of our application.
This layer is used for the
design purpose where data is presented to the user or input is taken from the user.
For example designing
registration form which contains text box, label, button etc.
2) Business layer:
In this layer all business logic written like validation of data, calculations,
data insertion etc. This acts as a
interface between Client layer and Data Access Layer. This layer is also called
the intermediary layer helps
to make communication faster between client and data layer.
3) Data layer:
In this layer actual database is comes in the picture. Data Access Layer contains
methods to connect with
database and to perform insert, update, delete, get data from database based on our
input data.

Q.9. Discuss some types of database utilities and tools and their functions.
The database utility is the interface between the ABAP Dictionary and the
relational database underlying
the SAP system. The database utility allows you to edit (create, delete and adjust
to changes to their definition
in the ABAP Dictionary) database objects derived from objects of the ABAP
Dictionary.
phpMyAdmin.
Navicat for MySQL. ...
SQLyog. ...
Sequel Pro. ...
Microsoft SQL Server Management Studio. ...

Q.10 What is the additional functionality incorporated in n-tier architecture (n


> 3)?

============================END OF CHAPTER - 2
=========================================

****Some basic terminology of chapter 3 :-

Tuple - A single row of a table, which contains a single record for that relation
is called a tuple.

Domain - a Domain refers to all the values which a data element may contain.

Attributes - An attribute is a characteristic. In a database management system


(DBMS), an attribute
refers to a database component, such as a table. It also may refer to a
database field.
Attributes describe the instances in the row of a database.

Relation A set of attributes is called a relation schema (or relation scheme).


A relation schema is also known
schema: as table schema (or table scheme). Relational schema may also refer
to as database schema.
A database schema is the collection of relation schemas for a whole
database.

Relational A collection of relations, each one consistent with its specified


relational schema.
Database:

Degree - The degree of relationship (also known as cardinality) is the number


of occurrences in one entity
of which are associated (or linked) to the number of occurrences
in another. There are three degrees
relation of relationship, known as : one-to-one (1:1), one-to-many (1:M),
many-to-many (M:N)

relational - A relational database schema is the tables, columns and


relationships that make up a relational database.
database A schema is often depicted visually in modeling software such as
SQLdbm
schema

Constraints - Constraints enforce limits to the data or type of data that can be
inserted/updated/deleted from a table.
This ensures the accuracy and reliability of the data in the database.
Constraints could be either on a column
level or a table level.

Keys - A DBMS key is an attribute or set of an attribute which helps you to


identify a row(tuple) in a relation(table).
They allow you to find the relation between two tables. Keys help
you uniquely identify a row in a table by a
combination of one or more columns in that table. Example: Employee
ID

Super Key - The set of attributes which can uniquely identify a tuple is known as
Super Key.
Primary Key – A primary is a column or set of columns in a table that uniquely
identifies tuples (rows) in that table.

Candidate Key – A super key with no redundant attribute is known as candidate key

Foreign Key – Foreign keys are the columns of a table that points to the primary
key of another table. They act as a cross-reference
between tables.

Entity Integrity - Entity Integrity ensures that there are no duplicate records
within the table and that the field that identifies
each record within the table is unique and never null.

Referential - Referential integrity is a relational database concept, which


states that table relationships must always
integrity be consistent. In other words, any foreign key field must agree
with the primary key that is referenced by
the foreign key.

Transaction - A transaction is a very small unit of a program and it may contain


several lowlevel tasks.
Transactions access data using read and write operations.

---------------------==================------------------END OF CHAPTER
3---------------=================----------------------------

****Some basic terminology of chapter 3 :-

The six clauses of the SELECT statement. There are six clauses that can be used in
an SQL statement.
These six clauses are SELECT, FROM, WHERE, GROUP BY, HAVING, and ORDER BY.
Clauses must be coded in a specific sequence

NULLs in SQL - syntax - SELECT SCHEMA_NAME


FROM ATRIBUTE_NAME
WHERE AMOUNT IS NULL

What is the difference between nested query and subquery?


With a normal nested subquery, the inner SELECT query runs first and executes once,
returning values to be used by the main query.
A correlated subquery, however, executes once for each candidate row considered by
the outer query. ...
NOTE : You can also use the ANY and ALL operator in a correlated subquery

What is nested queries in DBMS?


A subquery, also known as a nested query or subselect, is a SELECT query embedded
within the WHERE or HAVING
clause of another SQL query. The data returned by the subquery is used by the outer
statement in the same way a literal value
would be used. A Subquery or Inner query or a Nested query is a query within
another SQL query and embedded within the WHERE clause.
A subquery is used to return data that will be used in the main query as a
condition to further restrict the data to be retrieved.

An outer join is like an inner join, but adds the remaining rows from one of the
tables. Outer joins are directional: a left outer join
includes all the records from the left table – the first table in the join – and a
right outer join includes all the records from the
right table – the second table in the join.
Outer joins
When performing an inner join, rows from either table that are unmatched in the
other table are not returned.
In an outer join, unmatched rows in one or both tables can be returned. There are a
few types of outer joins:

LEFT JOIN returns only unmatched rows from the left table.
RIGHT JOIN returns only unmatched rows from the right table.
FULL OUTER JOIN returns unmatched rows from both tables.

What is difference between inner join and outer join?


Inner join - An inner join using either of the equivalent queries gives the
intersection of the two tables, i.e. the
two rows they have in common. Left outer join - A left outer join will give all
rows in A, plus any common rows in B.
Inner join matches tables on keys, but outer join matches keys just for one side.

What is Inner Join in SQL?


The INNER JOIN selects all rows from both participating tables as long as there is
a match between the columns.
An SQL INNER JOIN is same as JOIN clause, combining rows from two or more tables.

Syntax: SELECT *
FROM table1 INNER JOIN table2
ON table1.column_name = table2.column_name;

What are the SQL aggregate functions?


The following are the most commonly used SQL aggregate functions:
AVG – calculates the average of a set of values.
COUNT – counts rows in a specified table or view.
MIN – gets the minimum value in a set of values.
MAX – gets the maximum value in a set of values.
SUM – calculates the sum of values.

The GROUP BY Statement in SQL is used to arrange identical data into groups with
the help of some functions.
i.e if a particular column has same values in different rows then it will arrange
these rows in a group.

Important Points: GROUP BY clause is used with the SELECT statement.


In the query, GROUP BY clause is placed after the WHERE clause.
In the query, GROUP BY clause is placed before ORDER BY clause
if used any.
Syntax: SELECT column1, function_name(column2)
FROM table_name
WHERE condition
GROUP BY column1, column2
ORDER BY column1, column2;
function_name: Name of the function used for example, SUM() , AVG().
table_name: Name of the table.
condition: Condition used.

A trigger is a stored procedure in database which automatically invokes whenever a


special event in the database
occurs. For example, a trigger can be invoked when a row is inserted into a
specified table or when certain table
columns are being updated.
An assertion is a statement in SQL that ensures a certain condition will always
exist in the database. Assertions are
like column and table constraints, except that they are specified separately from
table definitions.

Schema Change Statements in SQL


1. The DROP Command 2. The ALTER Command

SQL data types can be broadly divided into following categories.

Numeric data types such as int, tinyint, bigint, float, real etc.
Date and Time data types such as Date, Time, Datetime etc.
Character and String data types such as char, varchar, text etc.
Unicode character string data types, for example nchar, nvarchar, ntext etc.
Binary data types such as binary, varbinary etc.
Miscellaneous data types – clob, blob, xml, cursor, table etc.

Keywords in MySQL

Keywords :- Keywords are preserved words that have special meaning in programming
language.
The meaning of keywords has already been described to any programming
language's compiler.

Keyword Description

ADD Adds a column in an existing table


ADD CONSTRAINT Adds a constraint after a table is already created
ALTER Adds, deletes, or modifies columns in a table, or changes the
data type of a column in a table
ALTER COLUMN Changes the data type of a column in a table
ALTER TABLE Adds, deletes, or modifies columns in a table
ALL Returns true if all of the subquery values meet the condition
AND Only includes rows where both conditions is true
ANY Returns true if any of the subquery values meet the condition
AS Renames a column or table with an alias
ASC Sorts the result set in ascending order
BACKUP DATABASE Creates a back up of an existing database
BETWEEN Selects values within a given range
CASE Creates different outputs based on conditions
CHECK A constraint that limits the value that can be placed in a column
COLUMN Changes the data type of a column or deletes a column in a
table
CONSTRAINT Adds or deletes a constraint
CREATE Creates a database, index, view, table, or procedure
CREATE DATABASE Creates a new SQL database
CREATE INDEX Creates an index on a table (allows duplicate values)
CREATE OR REPLACE VIEW Updates a view
CREATE TABLE Creates a new table in the database
CREATE PROCEDURE Creates a stored procedure
CREATE UNIQUE INDEX Creates a unique index on a table (no duplicate values)
CREATE VIEW Creates a view based on the result set of a SELECT statement
DATABASE Creates or deletes an SQL database
DEFAULT A constraint that provides a default value for a column
DELETE Deletes rows from a table
DESC Sorts the result set in descending order
DISTINCT Selects only distinct (different) values
DROP Deletes a column, constraint, database, index, table, or view
DROP COLUMN Deletes a column in a table
DROP CONSTRAINT Deletes a UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK
constraint
DROP DATABASE Deletes an existing SQL database
DROP DEFAULT Deletes a DEFAULT constraint
DROP INDEX Deletes an index in a table
DROP TABLE Deletes an existing table in the database
DROP VIEW Deletes a view
EXEC Executes a stored procedure
EXISTS Tests for the existence of any record in a subquery
FOREIGN KEY A constraint that is a key used to link two tables together
FROM Specifies which table to select or delete data from
FULL OUTER JOIN Returns all rows when there is a match in either left table
or right table
GROUP BY Groups the result set (used with aggregate functions: COUNT, MAX,
MIN, SUM, AVG)
HAVING Used instead of WHERE with aggregate functions
IN Allows you to specify multiple values in a WHERE clause
INDEX Creates or deletes an index in a table
INNER JOIN Returns rows that have matching values in both tables
INSERT INTO Inserts new rows in a table
INSERT INTO SELECT Copies data from one table into another table
IS NULL Tests for empty values
IS NOT NULL Tests for non-empty values
JOIN Joins tables
LEFT JOIN Returns all rows from the left table, and the matching rows from
the right table
LIKE Searches for a specified pattern in a column
LIMIT Specifies the number of records to return in the result set
NOT Only includes rows where a condition is not true
NOT NULL A constraint that enforces a column to not accept NULL values
OR Includes rows where either condition is true
ORDER BY Sorts the result set in ascending or descending order
OUTER JOIN Returns all rows when there is a match in either left table or
right table
PRIMARY KEY A constraint that uniquely identifies each record in a database
table
PROCEDURE A stored procedure
RIGHT JOIN Returns all rows from the right table, and the matching rows from
the left table
ROWNUM Specifies the number of records to return in the result set
SELECT Selects data from a database
SELECT DISTINCT Selects only distinct (different) values
SELECT INTO Copies data from one table into a new table
SELECT TOP Specifies the number of records to return in the result set
SET Specifies which columns and values that should be updated in a
table
TABLE Creates a table, or adds, deletes, or modifies columns in a
table, or deletes a table or data inside a table
TOP Specifies the number of records to return in the result set
TRUNCATE TABLE Deletes the data inside a table, but not the table itself
UNION Combines the result set of two or more SELECT statements (only
distinct values)
UNION ALL Combines the result set of two or more SELECT statements (allows
duplicate values)
UNIQUE A constraint that ensures that all values in a column are
unique
UPDATE Updates existing rows in a table
VALUES Specifies the values of an INSERT INTO statement
VIEW Creates, updates, or deletes a view
WHERE Filters a result set to include only records that fulfill a
specified condition

You might also like