You are on page 1of 46

ISM PRACTICAL FILE

ASSIGNMENT-1

Q1) What is SQL? Features of SQL?

ANS1) SQL (Structured Query Language) is a standardized programming language that's used to
manage relational databases and perform various operations on the data in them. The uses of
SQL include modifying database table and index structures; adding, updating and deleting rows
of data; and retrieving subsets of information from within a database for transaction processing
and analytics applications. Queries and other SQL operations take the form of commands written
as statements -- commonly used SQL statements include select, add, insert, update, delete,
create, alter and truncate. SQL became the de facto standard programming language
for relational databases after they emerged in the late 1970s and early 1980s. Also known as
SQL databases, relational systems comprise a set of tables containing data in rows and columns.
Each column in a table corresponds to a category of data -- for example, customer name or
address -- while each row contains a data value for the intersecting column.

SQL commands and syntax-SQL commands are divided into several different types, among them
data manipulation language (DML) and data definition language (DDL) statements, transaction
controls and security measures. The DML vocabulary is used to retrieve and manipulate data,
while DDL statements are for defining and modifying database structures. The transaction
controls help manage transaction processing, ensuring that transactions are either completed or
rolled back if errors or problems occur.

Features of SQL are-

1. Relational Database System: Like almost all other database systems on the market, My
SQL is a relational database system.
2. Client/Server Architecture: My SQL is a client/server system. There is a database server
(My SQL) and arbitrarily many clients (application programs), which communicate with
the server; that is, they query data, save changes, etc. The clients can run on the same
computer as the server or on another computer (communication via a local network or the
Internet).
3. SQL compatibility: My SQL supports as its database language -- as its name suggests –
SQL (Structured Query Language). SQL is a standardized language for querying and
updating data and for the administration of a database. There are several SQL dialects
(about as many as there are database systems). My SQL adheres to the current SQL
standard, although with significant restrictions and a large number of extensions.

43390301717Page 1
ISM PRACTICAL FILE

Q2) Data types in SQL?

ANS2) SQL data types can be broadly divided into following categories.

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

SQL Data Types important points

 Not all data types are supported by every relational database vendors. For example, Oracle
database doesn’t support DATETIME and My SQL doesn’t support CLOB data type. So
while designing database schema and writing SQL queries, make sure to check if the data
types are supported or not.
 Data types listed here doesn’t include all the data types, these are the most popularly used
data types. Some relational database vendors have their own data types that might be not
listed here. For example, Microsoft SQL Server has money and small money data types
but since it’s not supported by other popular database vendors, it’s not listed here.
 Every relational database vendor has it’s own maximum size limit for different data types,
you don’t need to remember the limit. Idea is to have the knowledge of what data type to
be used in a specific scenario.

Q3) Create student table and modify the structure of the table.

TABLE CREATED

43390301717Page 2
ISM PRACTICAL FILE

ALTER TABLE

43390301717Page 3
ISM PRACTICAL FILE

Q4) Create employee table and modify the structure of the table.

TABLE CREATED

43390301717Page 4
ISM PRACTICAL FILE

ALTER TABLE

43390301717Page 5
ISM PRACTICAL FILE

43390301717Page 6
ISM PRACTICAL FILE

ASSIGNMENT-2

TABLE CREATED

VALUES INSERTED

43390301717Page 7
ISM PRACTICAL FILE

DISPLAY CID AND FNAME

43390301717Page 8
ISM PRACTICAL FILE

DISPLAY FNAME, LNAME AND STATE

DISPLAY ALL RECORDS WHERE STATE IS DELHI

43390301717Page 9
ISM PRACTICAL FILE

DISPLAY FNAME, LNAME CONCATENATED WITH STATE

DISPLAY THE RECORDS WHOSE PIN IS NOT ENTERED

43390301717Page 10
ISM PRACTICAL FILE

DISPLAY THE STATES TO WHICH THE CUSTOMER BELONGS

SELECT RECORDS OF DELHI HAVING NAME RAJ

43390301717Page 11
ISM PRACTICAL FILE

DISPLAY RECORDS DELHI OR PUNJAB

DISPLAY DETAILS OF CUSTOMER WITH CID=104

43390301717Page 12
ISM PRACTICAL FILE

DISPLAY DETAILS OF CUSTOMER EXCEPT CID=104

USE ALIAS NAME TO DISPLAY CID

43390301717Page 13
ISM PRACTICAL FILE

RETRIEVE ALL ROWS WHERE CID IS BETWEEN 102 AND 104

DISPLAY THOSE ROWS WHERE STATE NAME BEGINS WITH ‘D’

43390301717Page 14
ISM PRACTICAL FILE

RETRIEVE ALL ROWS WHERE FIRST NAME CONTAINS THE WORD ‘RAJ’

RETRIEVE ALL ROWS WHERE NAME FIELD CONTAINS THE WORD ‘RAJESH’

43390301717Page 15
ISM PRACTICAL FILE

RETRIEVE ALL ROWS WHERE CITY IS DELHI, KARNATAKA OR BANGALORE

RENAME THE TABLE CUSTOMER TO CUST

43390301717Page 16
ISM PRACTICAL FILE

DELETE ALL THOSE ROWS OF CUSTOMERS WHO STAY IN BANGALORE

43390301717Page 17
ISM PRACTICAL FILE

DELETE THOSE CUSTOMERS WHO DO NOT HAVE PIN CODE

43390301717Page 18
ISM PRACTICAL FILE

RENAME COLUMN CITY TO ADDRESS

43390301717Page 19
ISM PRACTICAL FILE

DELETE THE CUSTOMERS WHO DO NOT BELONG TO BANGALORE

43390301717Page 20
ISM PRACTICAL FILE

ASSIGNMENT-3

TABLE CREATED

VALUES INSERTED

43390301717Page 21
ISM PRACTICAL FILE

LIST NAME OF ALL EMPLOYEES WHO WORK IN DEPT NO. 5

43390301717Page 22
ISM PRACTICAL FILE

FIND NAMES AND SALARY OF ALL THE EMPLOYEES SORTED ACCORDING TO


SALARY

LIST NAMES OF EMPLOYEES HAVING SALARY BETWEEN 30,000 AND 50,000

43390301717Page 23
ISM PRACTICAL FILE

LIST NAME OF EMPLOYEES WHO LIVE IN JANAKPURI

LIST NAME OF ALL FEMALE EMPLOYEES

43390301717Page 24
ISM PRACTICAL FILE

LIST NAME OF THOSE EMPLOYEES WHOSE BDATE IS BEFORE 2 NOV. 1996

LIST ALL EMPLOYEES WHOSE FNAME IS “RAM” AND LNAME IS “KAPOOR”

43390301717Page 25
ISM PRACTICAL FILE

RENAME THE COLUMN ADDRESS TO CITY

43390301717Page 26
ISM PRACTICAL FILE

SORT THE EMPLOYEES IN DESCENDING ORDER OF CITY

UPDATE THE PERSON NAMED “RAM” TO “VIKAS”

43390301717Page 27
ISM PRACTICAL FILE

UPDATE CITY OF EMPID 101 TO JAIPUR

43390301717Page 28
ISM PRACTICAL FILE

DELETE RECORD OF EMPID 102

43390301717Page 29
ISM PRACTICAL FILE

DISPLAY THOSE EMPLOYEES WHOSE SALARY IS NOT EQUAL TO 20,000

43390301717Page 30
ISM PRACTICAL FILE

ASSIGNMENT-4

TABLE CREATED

VALUES INSERTED

43390301717Page 31
ISM PRACTICAL FILE

FIND AVERAGE AND TOTAL SALARIES OF ALL EMPLOYEES

AVERAGE SALARY

43390301717Page 32
ISM PRACTICAL FILE

TOTAL SALARY

FIND MINIMUM SALARY OF MANAGER

43390301717Page 33
ISM PRACTICAL FILE

FIND MAXIMUM SALARY OF MANAGER

HOW MANY EMPLOYEES ARE MANAGERS

43390301717Page 34
ISM PRACTICAL FILE

ADD 50% SALARY TO SALARY COLUMN AND NAME IT HRA

43390301717Page 35
ISM PRACTICAL FILE

COUNT THE TOTAL NO. EMPLOYEES

COUNT THE NO. OF DEPARTMENTS AVAILABLE

43390301717Page 36
ISM PRACTICAL FILE

COUNT THE NO. OF EMPLOYEES IN EACH DEPARTMENT

UPDATE THE COMMISSION TO 10%OF SALARY FOR ALL THE EMPLOYEES HAVING
SALARY GREATER THAN 50000

43390301717Page 37
ISM PRACTICAL FILE

FIND THE NAME OF LOWEST PAID EMPLOYEE FOR EACH MANAGER

UPDATE THE SALARIES OF ALL EMPLOYEES IN DEPARTMENT 10 BY HIKING IT BY


15%.

43390301717Page 38
ISM PRACTICAL FILE

FIND THE DIFFERENCE BETWEEN HIGHEST AND LOWEST SALARIES FOR EACH
DEPT

LIST AVERAGE SALARY FOR ALL THE DEPTS WHICH HAVE MORE THAN 5 PEOPLE

43390301717Page 39
ISM PRACTICAL FILE

LIST JOBS OF ALL THE EMPLOYEES WHERE MAXIMUM SALARY IS MORE THAN
40000

LIST JOBS AND NO. OF EMPLOYEES IN EACH JOB

43390301717Page 40
ISM PRACTICAL FILE

LIST AVERAGE SALARY OF EACH JOB EXCLUDING MANAGERS

LIST TOTAL, MAX, MIN, AVERAGE SALARY OF EMPLOYEES JOB WISE

43390301717Page 41
ISM PRACTICAL FILE

ASSIGNMENT-5

Q Create entity relationship diagrams between three tables using MS-Access

43390301717Page 42
ISM PRACTICAL FILE

43390301717Page 43
ISM PRACTICAL FILE

43390301717Page 44
ISM PRACTICAL FILE

43390301717Page 45
ISM PRACTICAL FILE

43390301717Page 46

You might also like