Professional Documents
Culture Documents
Q Define Database, Data, DBMS, State Purpose of Database
Q Define Database, Data, DBMS, State Purpose of Database
Q Define Database, Data, DBMS, State Purpose of Database
Data : Data is nothing but facts and statistics stored or free flowing over a
network, generally it's raw and unprocessed. For example: When you visit any
website, they might store you IP address, that is data, in return they
might add a cookie in your browser, marking you that you visited the
website, that is data, your name, it's data, your age, it's data.
Internal/Physical Level/Schema
The internal schema defines the physical storage structure of the
database. 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
•It helps you to keeps information about the actual representation of the entire
database. Like the actual storage of the data on the disk in the form of records
• The internal view tells us what data is stored in the database and how
• It never deals with the physical devices. Instead, internal schema views a physical
device as a collection of physical pages
Conceptual Schema/Level
The conceptual schema describes the Database structure of the whole database for
the community of users. This schema hides information about the physical storage
structures and focuses on describing data types, entities, relationships, etc. This
logical level comes between the user level and physical storage view. However,
there is only single conceptual view of a single database.
Facts about Conceptual schema:
•Defines all database entities, their attributes, and their relationships
• Security and integrity information
•In the conceptual level, the data available to a user must be contained in or
derivable from the physical level
External Schema/User Level :
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.
There may be “n” number of external views for each database .Each external view
is defined using an external schema, which consists of definitions of various
types of external record of that specific view. An external view is just the content
of the database as it is seen by some specific particular user. For example, a
user from the sales department will see only sales related data.
Facts about external schema:
•An external level is only related to the data which is viewed by specific end users
.•This level includes some external schemas.
•External schema level is nearest to the user
•The external schema describes the segment of the database which is needed for a
certain user group and hides the remaining details from the database from the
specific user group
Q SN on data independence
Data Independence is defined as a property of DBMS that helps you to change the
Database schema at one level of a database system without requiring to change the
schema at the next higher level. Data independence helps you to keep data
separated from all programs that make use of it. You can use this stored data for
computing and presentation. In many systems, data independence is an essential
function for components of the system.
Types of Data Independence
In DBMS there are two types of data independence
1.Physical data independence
2.Logical data independence
Physical Data Independence
Physical data independence helps you to separate conceptual levels from the
internal/physical levels. It allows you to provide a logical description of the database
without the need to specify physical structures. Compared to Logical Independence,
it is easy to achieve physical data independence. With Physical independence, you
can easily change the physical storage structures or devices with an effect on the
conceptual schema. Any change done would be absorbed by the mapping
between the conceptual and internal levels. Physical data independence is achieved
by the presence of the internal level of the database and then the transformation
from the conceptual level of the database to the internal level.
Examples of changes under Physical Data Independence
Due to Physical independence, any of the below change will not affect
the conceptual layer
.•Using a new storage device like Hard Drive or Magnetic Tapes
•Modifying the file organization technique in the Database
•Switching to different data structures.
•Changing the access method
.•Modifying indexes.
•Changes to compression techniques or hashing algorithms
.•Change of Location of Database from say C drive to D Drive
1-Tier Architecture
1 Tier Architecture in DBMS is the simplest architecture of Database in which the
client, server, and Database all reside on the same machine. A simple one tier
architecture example would be anytime you install a Database in your system and
access it to practice SQL queries. But such architecture is rarely used in production.
2-Tier Architecture
A2 Tier Architecture in DBMS is a Database architecture where the presentation
layer runs on a client (PC, Mobile, Tablet, etc.), and data is stored on a server called
the second tier. Two tier architecture provides added security to the DBMS as it is
not exposed to the end-user directly. It also provides direct and faster
communication.
3-Tier Architecture
A3 Tier Architecture in DBMS is the most popular client server architecture in DBMS
in which the development and maintenance of functional processes, logic, data
access, data storage, and user interface is done independently as separate
modules.
Three Tier architecture contains a presentation layer, an application layer, and a
database server.3-Tier database Architecture design is an extension of the 2-tier
client-server architecture. A 3-tier architecture has the following layers:
1.Presentation layer (your PC, Tablet, Mobile, etc.)
2.Application layer (server)
3.Database Server
The Application layer resides between the user and the DBMS, which is responsible
for communicating the user’s request to the DBMS system and send the response
from the DBMS to the user. The application layer(business logic layer) also
processes functional logic, constraint, and rules before passing data to the user or
down to the DBMS.
The goal of Three Tier client-server architecture is:
•To separate the user applications and physical database
•To support DBMS characteristics
•Program-data independence
•Supporting multiple views of the data
6. Monitoring Performance
•The DBA monitors performance of the system. The DBA ensures that better
performance is maintained by making changes in physical or logical schema if
required.
7. Backup and Recovery
•Database should not be lost or damaged.
•The DBA ensures this periodically backing up the database on magnetic
tapes or remote servers.
•In case of failure, such as virus attack database is recovered from this
backup.
2. No Coding Skills –
For data retrieval, large number of lines of code is not required. All basic
keywords such as SELECT, INSERT INTO, UPDATE, etc are used and
also the syntactical rules are not complex in SQL, which makes it a user-
friendly language.
3. Standardized Language –
Due to documentation and long establishment over years, it provides a
uniform platform worldwide to all its users.
4. Portable –
It can be used in programs in PCs, server, laptops independent of any
platform (Operating System, etc). Also, it can be embedded with other
applications as per need/requirement/use.
5. Interactive Language –
Easy to learn and understand, answers to complex queries can be
received in seconds.
Characteristics :
Syntax
The basic syntax of a GROUP BY clause is shown in the following code block. The
GROUP BY clause must follow the conditions in the WHERE clause and must
precede the ORDER BY clause if one is used.
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2
For eg :
If you want to know the total amount of the salary on each customer, then the GROUP
BY query would be as follows.
SQL> SELECT NAME, SUM(SALARY) FROM CUSTOMERS
GROUP BY NAME;
Orderby :
The SQL ORDER BY clause is used to sort the data in ascending or descending
order, based on one or more columns. Some databases sort the query results in an
ascending order by default.
You can use more than one column in the ORDER BY clause. Make sure whatever
column you are using to sort that column should be in the column-list.
Syntax
For eg :
The following code block has an example, which would sort the result in an ascending
order by the NAME and the SALARY −
SQL> SELECT * FROM CUSTOMERS
ORDER BY NAME, SALARY;
Having clause
The HAVING Clause enables you to specify conditions that filter which group results
appear in the results.
The WHERE clause places conditions on the selected columns, whereas the
HAVING clause places conditions on groups created by the GROUP BY clause.
Syntax
The following code block shows the position of the HAVING Clause in a query.
SELECT
FROM
WHERE
GROUP BY
HAVING
ORDER BY
The HAVING clause must follow the GROUP BY clause in a query and must also
precede the ORDER BY clause if used. The following code block has the syntax of
the SELECT statement including the HAVING clause −
SELECT column1, column2
FROM table1, table2
WHERE [ conditions ]
GROUP BY column1, column2
HAVING [ conditions ]
ORDER BY column1, column2
Example
Following is an example, which would display a record for a similar age count that
would be more than or equal to 2.
SQL > SELECT ID, NAME, AGE, ADDRESS, SALARY
FROM CUSTOMERS
GROUP BY age
HAVING COUNT(age) >= 2;
• COUNT(*): Counts all the number of rows of the table including null.