1unit4 Notes

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Operating System:

An operating system (OS) is the program that, after being initially loaded into the computer by a boot program,
manages all of the other application programs in a computer. The application programs make use of the operating
system by making requests for services through a defined application program interface (API). In addition, users
can interact directly with the operating system through a user interface such as a command line or a graphical
user interface (GUI).

Need of Operating System:


• OS as a platform for Application programs: Operating system provides a platform, on top of which,
other programs, called application programs can run. These application programs help the users to
perform a specific task easily. It acts as an interface between the computer and the user. It is designed in
such a manner that it operates, controls and executes various applications on the computer.
•Managing Input-Output unit: Operating System also allows the computer to manage its own resources
such as memory, monitor, keyboard, printer etc. Management of these resources is required for an effective
utilization.The operating system controls the various system input-output resources and allocates them to
the users or programs as per their requirement.
•Consistent user interface: Operating System provides the user an easy-to-work user interface, so the user
doesn’t have to learn a different UI every time and can focus on the content and be productive as quickly as
possible. Operating System provides templates, UI components to make the working of a computer, really
easy for the user.
•Multitasking: Operating System manages memory and allow multiple programs to run in their own space
and even communicate with each other through shared memory. Multitasking gives users a good
experience as they can perform several tasks on a computer at a time.

Functions of an Operating System:


An operating system has variety of functions to perform. Some of the prominent functions of an operating
system can be broadly outlined as:

•Processor Management: This deals with management of the Central Processing Unit (CPU). The operating
system takes care of the allotment of CPU time to different processes. When a process finishes its CPU
processing after executing for the allotted time period, this is called scheduling. There are various type of
scheduling techniques that are used by the operating systems:
1.Shortest Job First(SJF): Process which need the shortest CPU time are scheduled first.
2.Round Robin Scheduling: Each process is assigned a fixed CPU execution time in cyclic way.
3.Priority Based scheduling (Non Preemptive): In this scheduling, processes are scheduled according
to their priorities, i.e., highest priority process is schedule first. If priorities of two processes match,
then schedule according to arrival time
•Device Management:
The Operating System communicates with hardware and the attached devices and maintains a balance
between them and the CPU. This is all the more important because the CPU processing speed is much
higher than that
of I/O devices. In order to optimize the CPU time, the operating system employs two techniques –
Buffering and Spooling.
•Buffering:
In this technique, input and output data is temporarily stored in Input Buffer and Output Buffer. Once the
signal for input or output is sent to or from the CPU respectively, the operating system through the device
controller moves the data from the input device to the input buffer and for the output device to the output
buffer. In case of input, if the buffer is full, the operating system sends a signal to the program which
processes the data stored in the buffer. When the buffer becomes empty, the program informs the operating
system which reloads the buffer and the input operation continues.
•Spooling (Simultaneous Peripheral Operation on Line):
This is a device management technique used for processing of different tasks on the same input/output
device. When there are various users on a network sharing the same resource then it can be a possibility
that more than one user might give it a command at the same point of time. So, the operating system
temporarily stores the data of every user on the hard disk of the computer to which the resource is attached.
The individual user need not wait for the execution process to be completed. Instead the operating system
sends the data from the hard disk to the resource one by one.
Example: printer
•Memory management:
In a computer, both the CPU and the I/O devices interact with the memory. When a program needs to be
executed it is loaded onto the main memory till the execution is completed. Thereafter that memory space
is freed and is available for other programs. The common memory management techniques used by the
operating system are Partitioning and Virtual Memory.
•Partitioning:
The total memory is divided into various partitions of same size or different sizes. This helps to
accommodate number of programs in the memory. The partition can be fixed i.e. remains same for all the
programs in the memory or variable i.e. memory is allocated when a program is loaded on to the memory.
The later approach causes less wastage of memory but in due course of time, it may become fragmented.
•Virtual Memory:
This is a technique used by the operating systems which allow the user can load the programs which are
larger than the main memory of the computer. In this technique the program is executed even if the
complete program can not be loaded inside the main memory leading to efficient memory utilization.
•File Management:
The operating System manages the files, folders and directory systems on a computer. Any data on a
computer is stored in the form of files and the operating system keeps information about all of them using
File Allocation Table (FAT). The FAT stores general information about files like filename, type (text or
binary), size, starting address and access mode (sequential/indexed sequential/direct/relative). The file
manager of the operating system helps to create, edit, copy, allocate memory to the files and also updates
the FAT. The operating system also takes care that files are opened with proper access rights to read or edit
them.

Types of Operating Systems


An Operating System performs all the basic tasks like managing file,process, and memory. Thus operating
system acts as manager of all the resources, i.e. resource manager. Thus operating system becomes an interface
between user and machine.
Types of Operating Systems: Some of the widely used operating systems are as follows-
1. Batch Operating System –
This type of operating system does not interact with the computer directly. There is an operator which takes
similar jobs having same requirement and group them into batches. It is the responsibility of operator to sort the
jobs with similar needs.
Advantages of Batch Operating System:
•It is very difficult to guess or know the time required by any job to complete. Processors of the batch
systems know how long the job would be when it is in queue
•Multiple users can share the batch systems
•The idle time for batch system is very less
•It is easy to manage large work repeatedly in batch systems
Disadvantages of Batch Operating System:
•The computer operators should be well known with batch systems
•Batch systems are hard to debug
•It is sometime costly
•The other jobs will have to wait for an unknown time if any job fails
Examples of Batch based Operating System: Payroll System, Bank Statements etc.
2. Time-Sharing Operating Systems –
Each task is given some time to execute, so that all the tasks work smoothly. Each user gets time of CPU as they
use single system. These systems are also known as Multitasking Systems. The task can be from single user or
from different users also. The time that each task gets to execute is called quantum. After this time interval is
over OS switches over to next task.
Advantages of Time-Sharing OS:
•Each task gets an equal opportunity
•Less chances of duplication of software
•CPU idle time can be reduced
Disadvantages of Time-Sharing OS:
•Reliability problem
•One must have to take care of security and integrity of user programs and data
•Data communication problem
Examples of Time-Sharing OSs are: Multics, Unix etc.
3. Distributed Operating System –
These types of operating system is a recent advancement in the world of computer technology and are being
widely accepted all-over the world and, that too, with a great pace. Various autonomous interconnected
computers communicate each other using a shared communication network. Independent systems possess their
own memory unit and CPU. These are referred as loosely coupled systems or distributed systems. These
system’s processors differ in size and function. The major benefit of working with these types of operating
system is that it is always possible that one user can access the files or software which are not actually present on
his system but on some other system connected within this network i.e., remote access is enabled within the
devices connected in that network.

Advantages of Distributed Operating System:


•Failure of one will not affect the other network communication, as all systems are independent from each
other
•Electronic mail increases the data exchange speed
•Since resources are being shared, computation is highly fast and durable
•Load on host computer reduces
•These systems are easily scalable as many systems can be easily added to the network
•Delay in data processing reduces
Disadvantages of Distributed Operating System:
•Failure of the main network will stop the entire communication
•To establish distributed systems the language which are used are not well defined yet
•These types of systems are not readily available as they are very expensive. Not only that the underlying
software is highly complex and not understood well yet
Examples of Distributed Operating System are- LOCUS etc.
4. Network Operating System –
These systems run on a server and provide the capability to manage data, users, groups, security, applications,
and other networking functions. These type of operating systems allow shared access of files, printers, security,
applications, and other networking functions over a small private network. One more important aspect of
Network Operating Systems is that all the users are well aware of the underlying configuration, of all other users
within the network, their individual connections etc. and that’s why these computers are popularly known
as tightly coupled systems.
Advantages of Network Operating System:
•Highly stable centralized servers
•Security concerns are handled through servers
•New technologies and hardware up-gradation are easily integrated to the system
•Server access are possible remotely from different locations and types of systems
Disadvantages of Network Operating System:
•Servers are costly
•User has to depend on central location for most operations
•Maintenance and updates are required regularly
Examples of Network Operating System are: Microsoft Windows Server 2003, Microsoft Windows Server 2008,
UNIX, Linux, Mac OS X, Novell NetWare, and BSD etc.
5. Real-Time Operating System –
These types of OSs serves the real-time systems. The time interval required to process and respond to inputs is
very small. This time interval is called response time.
Real-time systems are used when there are time requirements are very strict like missile systems, air traffic
control systems, robots etc.
Two types of Real-Time Operating System which are as follows:
•Hard Real-Time Systems:
These OSs are meant for the applications where time constraints are very strict and even the shortest
possible delay is not acceptable. These systems are built for saving life like automatic parachutes or air
bags which are required to be readily available in case of any accident. Virtual memory is almost never
found in these systems.
•Soft Real-Time Systems:
These OSs are for applications where for time-constraint is less strict.

Advantages of RTOS:
•Maximum Consumption: Maximum utilization of devices and system,thus more output from all the
resources
•Task Shifting: Time assigned for shifting tasks in these systems are very less. For example in older
systems it takes about 10 micro seconds in shifting one task to another and in latest systems it takes 3 micro
seconds.
•Focus on Application: Focus on running applications and less importance to applications which are in
queue.
•Real time operating system in embedded system: Since size of programs are small, RTOS can also be used
in embedded systems like in transport and others.
•Error Free: These types of systems are error free.
•Memory Allocation: Memory allocation is best managed in these type of systems.
Disadvantages of RTOS:
•Limited Tasks: Very few tasks run at the same time and their concentration is very less on few applications
to avoid errors.
•Use heavy system resources: Sometimes the system resources are not so good and they are expensive as
well.
•Complex Algorithms: The algorithms are very complex and difficult for the designer to write on.
•Device driver and interrupt signals: It needs specific device drivers and interrupt signals to response
earliest to interrupts.
•Thread Priority: It is not good to set thread priority as these systems are very less prone to switching tasks.
Examples of Real-Time Operating Systems are: Scientific experiments, medical imaging systems, industrial
control systems, weapon systems, robots, air traffic control systems, etc.
Note: Main difference between multiprogramming and time sharing is that multiprogramming is the effective
utilization of CPU time, by allowing several programs to use the CPU at the same time but time sharing is the
sharing of a computing facility by several users that want to use the same facility at the same time. Each user on
a time sharing system gets her own terminal and gets the feeling that she is using the CPU alone. Actually, time
sharing systems use the concept of multiprogramming to share the CPU time between multiple users at the same
time.
Popular OSs:
• Windows is Microsoft’s flagship operating system, the de facto standard for home and business
computers. Introduced in 1985, the GUI-based OS has been released in many versions since then. The
user-friendly Windows 95 was largely responsible for the rapid development of personal computing.

•Mac OS is the operating system for Apple's Macintosh line of personal computers and workstations.

•Unix is a multi-user operating system designed for flexibility and adaptability. Originally developed in
the 1970s, Unix was one of the first operating systems to be written in C language.

•Linux is a Unix-like operating system that was designed to provide personal computer users a free or
very low-cost alternative. Linux has a reputation as a very efficient and fast-performing system.
DATABASE MANAGEMENT SYSTEM
Database is a collection of related data and data is a collection of facts and figures that can be processed to
produce information.
Mostly data represents recordable facts. Data aids in producing information, which is based on facts. For
example, if we have data about marks obtained by all students, we can then conclude about toppers and average
marks.
A database management system stores data in such a way that it becomes easier to retrieve, manipulate, and
produce information. Following are the important characteristics and applications of DBMS.
•ACID Properties − DBMS follows the concepts of Atomicity, Consistency, Isolation, and Durability
(normally shortened as ACID). These concepts are applied on transactions, which manipulate data in a
database. ACID properties help the database stay healthy in multi-transactional environments and in case
of failure.
•Multiuser and Concurrent Access − DBMS supports multi-user environment and allows them to
access and manipulate data in parallel. Though there are restrictions on transactions when users attempt to
handle the same data item, but users are always unaware of them.
•Multiple views − DBMS offers multiple views for different users. A user who is in the Sales department
will have a different view of database than a person working in the Production department. This feature
enables the users to have a concentrate view of the database according to their requirements.
•Security − Features like multiple views offer security to some extent where users are unable to access
data of other users and departments. DBMS offers methods to impose constraints while entering data into
the database and retrieving the same at a later stage. DBMS offers many different levels of security
features, which enables multiple users to have different views with different features. For example, a user
in the Sales department cannot see the data that belongs to the Purchase department. Additionally, it can
also be managed how much data of the Sales department should be displayed to the user. Since a DBMS
is not saved on the disk as traditional file systems, it is very hard for miscreants to break the code.
DBMS vs. Flat File:
DBMS Flat File Management System
Multi-user access It does not support multi-user access
Design to fulfil the need for small and large businesses It is only limited to smaller DBMS system.
Remove redundancy and Integrity Redundancy and Integrity issues
Expensive. But in the long term Total Cost of
It's cheaper
Ownership is cheap
Easy to implement complicated transactions No support for complicated transactions

Users of DBMS:
A typical DBMS has users with different rights and permissions who use it for different purposes. Some users
retrieve data and some back it up. The users of a DBMS can be broadly categorized as follows −
Administrators − Administrators maintain the DBMS and are responsible for administrating the database. They
are responsible to look after its usage and by whom it should be used. They create access profiles for users and
apply limitations to maintain isolation and force security. Administrators also look after DBMS resources like
system license, required tools, and other software and hardware related maintenance.
•Designers − Designers are the group of people who actually work on the designing part of the database.
They keep a close watch on what data should be kept and in what format. They identify and design the
whole set of entities, relations, constraints, and views.
•End Users − End users are those who actually reap the benefits of having a DBMS. End users can range
from simple viewers who pay attention to the logs or market rates to sophisticated users such as business
analysts.
Applications of DBMS:

Sector Use of DBMS


For customer information, account activities,
Banking
payments, deposits, loans, etc.
Airlines For reservations and schedule information.
For student information, course registrations, colleges
Universities
and grades.
It helps to keep call records, monthly bills,
Telecommunication
maintaining balances, etc.
For storing information about stock, sales, and
Finance purchases of financial instruments like stocks and
bonds.
Use for storing customer, product & sales
Sales
information.
It is used for the management of supply chain and for
Manufacturing tracking production of items. Inventories status in
warehouses.
For information about employees, salaries, payroll,
HR Management
deduction, generation of paychecks, etc.
Advantages of DBMS:
•DBMS offers a variety of techniques to store & retrieve data
•DBMS serves as an efficient handler to balance the needs of multiple applications using the same data
•Uniform administration procedures for data
•Application programmers never exposed to details of data representation and storage.
•A DBMS uses various powerful functions to store and retrieve data efficiently.
•Offers Data Integrity and Security
•The DBMS implies integrity constraints to get a high level of protection against prohibited access to
data.
•A DBMS schedules concurrent access to the data in such a manner that only one user can access the
same data at a time
•Reduced Application Development Time

Disadvantage of DBMS:
DBMS may offer plenty of advantages but, it has certain flaws-
•Cost of Hardware and Software of a DBMS is quite high which increases the budget of your
organization.
•Most database management systems are often complex systems, so the training for users to use the
DBMS is required.
•In some organizations, all data is integrated into a single database which can be damaged because of
electric failure or database is corrupted on the storage media
•Use of the same program at a time by many users sometimes lead to the loss of some data.
•DBMS can't perform sophisticated calculations

Data models:
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.
The very first data model could be flat data-models, where all the data used are to be kept in the same plane.
Earlier data models were not so scientific, hence they were prone to introduce lots of duplication and update
anomalies.

Entity-Relationship Model:

Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships among them.
While formulating real-world scenario into the database model, the ER Model creates entity set, relationship set,
general attributes and constraints.
ER Model is best used for the conceptual design of a database.
ER Model is based on −
•Entities and their attributes.
•Relationships among entities.
These concepts are explained below.

• Entity − An entity in an ER Model is a real-world entity having properties called attributes.


Every attribute is defined by its set of values called domain. For example, in a school database, a
student is considered as an entity. Student has various attributes like name, age, class, etc.
•Relationship − The logical association among entities is called relationship. Relationships are mapped
with entities in various ways. Mapping cardinalities define the number of association between two
entities.

Relational Model
The most popular data model in DBMS is the Relational Model. It is more scientific a model than others. This
model is based on first-order predicate logic and defines a table as an n-ary relation.
The main highlights of this model are −
•Data is stored in tables called relations.
•Relations can be normalized.
•In normalized relations, values saved are atomic values.
•Each row in a relation contains a unique value.
•Each column in a relation contains values from a same domain.
Hierarchical Model:
In a Hierarchical database, model data is organized in a tree-like structure. Data is Stored Hierarchically (top
down or bottom up) format. Data is represented using a parent-child relationship. In Hierarchical DBMS parent
may have many children, but children have only one parent.
Network Model:
The network database model allows each child to have multiple parents. It helps you to address the need to
model more complex relationships like as the orders/parts many-to-many relationship. In this model, entities are
organized in a graph which can be accessed through several paths.
Object-Oriented Model:
In Object-oriented Model data stored in the form of objects. The structure which is called classes which display
data within it. It defines a database as a collection of objects which stores both data members values and
operations.

DBMS Architecture:
•The DBMS design depends upon its architecture. The basic client/server architecture is used to deal with
a large number of PCs, web servers, database servers and other components that are connected with
networks.

•The client/server architecture consists of many PCs and a workstation which are connected via the
network.
•DBMS architecture depends upon how users are connected to the database to get their request done.

Types of DBMS Architecture:


Database architecture can be seen as a single tier or multi-tier. But logically, database architecture is of two types
like: 2-tier architecture and 3-tier architecture.

1-Tier Architecture:
•In this architecture, the database is directly available to the user. It means the user can directly sit on the
DBMS and uses it.

•Any changes done here will directly be done on the database itself. It doesn't provide a handy tool for
end users.

•The 1-Tier architecture is used for development of the local application, where programmers can directly
communicate with the database for the quick response.

2-Tier Architecture:
•The 2-Tier architecture is same as basic client-server. In the two-tier architecture, applications on the
client end can directly communicate with the database at the server side. For this interaction, API's
like: ODBC, JDBC are used.

•The user interfaces and application programs are run on the client-side.

•The server side is responsible to provide the functionalities like: query processing and transaction
management.

•To communicate with the DBMS, client-side application establishes a connection with the server side.

3-Tier Architecture:
•The 3-Tier architecture contains another layer between the client and server. In this architecture, client
can't directly communicate with the server.

•The application on the client-end interacts with an application server which further communicates with
the database system.

•End user has no idea about the existence of the database beyond the application server. The database also
has no idea about any other user beyond the application.

•The 3-Tier architecture is used in case of large web application.

What are 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 FirstName LastName
11 Andrew Johnson
22 Tom Wood
33 Alex Hale
In the above-given example, employee ID is a primary key because it uniquely identifies an employee record. In
this table, no other employee can have the same employee ID.

Why we need a Key?


Here, are reasons for using Keys in the DBMS system.
•Keys help you to identify any row of data in a table. In a real-world application, a table could contain
thousands of records. Moreover, the records could be duplicated. Keys ensure that you can uniquely
identify a table record despite these challenges.
•Allows you to establish a relationship between and identify the relation between tables
•Help you to enforce identity and integrity in the relationship.

Various Keys in Database Management System


DBMS has folwing seven types of Keys each have their different functionality:
•Super Key
•Primary Key
•Candidate Key
•Alternate Key
•Foreign Key
•Compound Key
•Composite Key
•Surrogate Key

What is the Super key?


A superkey is a group of single or multiple keys which identifies rows in a table. A Super key may have
additional attributes that are not needed for unique identification.
Example:
EmpSSN EmpNum Empname
9812345098 AB05 Shown
9876512345 AB06 Roslyn
199937890 AB07 James
In the above-given example, EmpSSN and EmpNum name are superkeys.

What is a Primary Key?


A column or group of columns in a table which helps us to uniquely identifies every row in that table is called a
primary key. This DBMS can't be a duplicate. The same value can't appear more than once in the table.
Rules for defining Primary key:
•Two rows can't have the same primary key value
•It must for every row to have a primary key value.
•The primary key field cannot be null.
•The value in a primary key column can never be modified or updated if any foreign key refers to that
primary key.
Example:
In the following example, <code>StudID</code> is a Primary Key.
StudID Roll No First Name LastName Email
1 11 Tom Price abc@gmail.com
2 12 Nick Wright xyz@gmail.com
3 13 Dana Natan mno@yahoo.com
What is the Alternate key?
All the keys which are not primary key are called an alternate key. It is a candidate key which is currently not the
primary key. However, A table may have single or multiple choices for the primary key.
Example: In this table.
StudID, Roll No, Email are qualified to become a primary key. But since StudID is the primary key, Roll No,
Email becomes the alternative key.
StudID Roll No First Name LastName Email
1 11 Tom Price abc@gmail.com
2 12 Nick Wright xyz@gmail.com
3 13 Dana Natan mno@yahoo.com

What is a Candidate Key?


A super key with no repeated attribute is called candidate key.
The Primary key should be selected from the candidate keys. Every table must have at least a single candidate
key.
Properties of Candidate key:
•It must contain unique values
•Candidate key may have multiple attributes
•Must not contain null values
•It should contain minimum fields to ensure uniqueness
•Uniquely identify each record in a table

Example: In the given table Stud ID, Roll No, and email are candidate keys which help us to uniquely identify
the student record in the table.
StudID Roll No First Name LastName Email
1 11 Tom Price abc@gmail.com
2 12 Nick Wright xyz@gmail.com
3 13 Dana Natan mno@yahoo.com
What is the Foreign key?
A foreign key is a column which is added to create a relationship with another table. Foreign keys help us to
maintain data integrity and also allows navigation between two different instances of an entity. Every
relationship in the model needs to be supported by a foreign key.
Example:
DeptCode DeptName
001 Science
002 English
005 Computer
Teacher ID Fname Lname
B002 David Warner
B017 Sara Joseph
B009 Mike Brunton
In this example, we have two table, teach and department in a school. However, there is no way to see which
search work in which department.
In this table, adding the foreign key in Deptcode to the Teacher name, we can create a relationship between the
two tables.
Teacher ID DeptCode Fname Lname
B002 002 David Warner
B017 002 Sara Joseph
B009 001 Mike Brunton
This concept is also known as Referential Integrity.

What is the Compound key?


Compound key has many fields which allow you to uniquely recognize a specific record. It is possible that each
column may be not unique by itself within the database. However, when combined with the other column or
columns the combination of composite keys become unique.
Example:
OrderNo PorductID Product Name Quantity
B005 JAP102459 Mouse 5
B005 DKT321573 USB 10
B005 OMG446789 LCD Monitor 20
B004 DKT321573 USB 15
B002 OMG446789 Laser Printer 3
In this example, OrderNo and ProductID can't be a primary key as it does not uniquely identify a record.
However, a compound key of Order ID and Product ID could be used as it uniquely identified each record.

What is the Composite key?


A key which has multiple attributes to uniquely identify rows in a table is called a composite key. The difference
between compound and the composite key is that any part of the compound key can be a foreign key, but the
composite key may or maybe not a part of the foreign key.

What is a Surrogate Key?


An artificial key which aims to uniquely identify each record is called a surrogate key. These kind of key are
unique because they are created when you don't have any natural primary key. They do not lend any meaning to
the data in the table. Surrogate key is usually an integer.
Fname Lastname Start Time End Time
Anne Smith 09:00 18:00
Jack Francis 08:00 17:00
Anna McLean 11:00 20:00
Shown Willam 14:00 23:00
Above, given example, shown shift timings of the different employee. In this example, a surrogate key is needed
to uniquely identify each employee.
Surrogate keys are allowed when
•No property has the parameter of the primary key.
•In the table when the primary key is too big or complicated.

Difference Between Primary key & Foreign key:


Primary Key Foreign Key
Helps you to uniquely identify a record in the It is a field in the table that is the primary key of another
table. table.
Primary Key never accept null values. A foreign key may accept multiple null values.
Primary key is a clustered index and data in the A foreign key cannot automatically create an index,
DBMS table are physically organized in the clustered or non-clustered. However, you can manually
sequence of the clustered index. create an index on the foreign key.
You can have the single Primary key in a table. You can have multiple foreign keys in a table.

SQL:
SQL is a database computer language designed for the retrieval and management of data in a relational
database. SQL stands for Structured Query Language.
SQL is Structured Query Language, which is a computer language for storing, manipulating and retrieving data
stored in a relational database.
SQL is the standard language for Relational Database System. All the Relational Database Management Systems
(RDMS) like MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL Server use SQL as their standard
database language.
Also, they are using different dialects, such as −
•MS SQL Server using T-SQL,
•Oracle using PL/SQL,
•MS Access version of SQL is called JET SQL (native format) etc.
SQL Architecture:

SQL Commands
The standard SQL commands to interact with relational databases are CREATE, SELECT, INSERT, UPDATE,
DELETE and DROP. These commands can be classified into the following groups based on their nature −

DDL - Data Definition Language: DDL is short name of Data Definition Language, which deals with database

schemas and descriptions, of how the data should reside in the database.

Sr.No. Command & Description


CREATE
1
Creates a new table, a view of a table, or other object in the database.

ALTER
2
Modifies an existing database object, such as a table.

DROP
3
Deletes an entire table, a view of a table or other objects in the database.

DML - Data Manipulation Language: DML is short name of Data Manipulation Language which deals with

data manipulation and includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE,

etc., and it is used to store, modify, retrieve, delete and update data in a database.

Sr.No. Command & Description

SELECT
1
Retrieves certain records from one or more tables.

INSERT
2
Creates a record.

UPDATE
3
Modifies records.

DELETE
4
Deletes records.

DCL - Data Control Language:

Sr.No. Command & Description

GRANT
1
Gives a privilege to user.

REVOKE
2
Takes back privileges granted from user.

Various Syntax in SQL:

SQL CREATE TABLE Statement


CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);
SQL SELECT Statement
SELECT column1, column2....columnN
FROM table_name;

SQL DISTINCT Clause

SELECT DISTINCT column1, column2....columnN


FROM table_name;

SQL WHERE Clause

SELECT column1, column2....columnN


FROM table_name
WHERE CONDITION;

SQL DROP TABLE Statement


DROP TABLE table_name;

SQL ALTER TABLE Statement


ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

SQL ALTER TABLE Statement (Rename)

ALTER TABLE table_name RENAME TO new_table_name;

SQL INSERT INTO Statement

INSERT INTO table_name( column1, column2....columnN)


VALUES ( value1, value2....valueN);

SQL UPDATE Statement

UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE CONDITION ];

SQL DELETE Statement

DELETE FROM table_name


WHERE {CONDITION};
SQL CREATE DATABASE Statement

CREATE DATABASE database_name;

SQL DROP DATABASE Statement

DROP DATABASE database_name;

SQL USE Statement

USE database_name;

You might also like