Professional Documents
Culture Documents
Ism Lab File-Compressed
Ism Lab File-Compressed
Ism Lab File-Compressed
Assignment- 1
1. Data is any sort of information which is stored in computer memory. This information can
later be used for a website, an application or any other client to store for future purpose. The
most common information is User information in the form of user personal, address and
banking information.
2. Database (DB) are organized, they have a structure, and all the data they store it fits into
that structure. More specifically, a database is an electronic system that allows data to be
stored, easily accessed, manipulated and updated.
3. Information is stimuli that have meaning in some context for its receiver. When
information is entered into and stored in a computer, it is generally referred to as data. After
processing (such as formatting and printing), output data can again be perceived as
information.
4. Database Management System (DBMS) is the software that interacts with end users,
applications, and the database itself to capture and analyze the data. The DBMS software
additionally encompasses the core facilities provided to administer the database. The sum
total of the database, the DBMS and the associated applications can be referred to as a
"database system".
6. Relational Database Management System (RDBMS). RDBMS is the basis for SQL, and
for all modern database systems like MS SQL Server, IBM DB2, Oracle, MySQL, and
Microsoft Access.
Assignment- 2
Introduction to SQL
SQL FEATURES
· Client/server architecture
SQL LANGUAGE
SQL was one of the first commercial languages for Edgar F. Codd's relational model, as
described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data
Banks. Despite not adhering to the relational model as described by Codd’s it became the most
widely used database language.
Assignment- 3
CREATE statement
);
DROP statements
A DROP statement in SQL removes an object from a relational database management system
(RDBMS). The types of objects that can be dropped depends on which RDBMS is being
used, but most support the dropping of tables, users, and databases. Some systems (such as
Postgre SQL) allow DROP and other DDL commands to occur inside of a transaction and
thus be rolled back.
For example, the command to drop a table named employees would be:
ALTER statements
SELECT statement
A SELECT statement retrieves zero or more rows from one or more database tables or
database views. In most applications, SELECT is the most commonly used Data
Manipulation Language (DML) command.
INSERT statement
An SQL INSERT statement adds one or more records to any single table in a relational
database.
The number of columns and values must be the same. If a column is not specified, the default
value for the column is used.
INSERT INTO table (column1 [, column2, column3 ... ]) VALUES (value1 [, value2, value3
... ])
UPDATE statement
An SQL UPDATE statement changes the data of one or more records in a table. Either all the
rows can be updated, or a subset may be chosen using a condition.
DELETE statement
In the database structured query language (SQL), the DELETE statement removes one or
more records from a table. A subset may be defined for deletion using a condition, otherwise
all records are removed.
The DELETE statement follows the syntax: DELETE FROM table_name [WHERE
condition];
Assignment- 4
The GROUP BY statement is used in conjunction with the aggregate functions to group the
result-set by one or more columns.
Or
The SQL GROUP BY clause can be used in an SQL SELECT statement to collect data across
multiple records and group the results by one or more columns.
Having Clause is used in SQL with the GROUP BY statement because the WHERE keyword
could not be used with aggregate functions.
Let us we have to Group By the students according to Brach from table student having total
marks greater than 150.
Assignment- 5
Write steps to open MS Access. Write steps to create database. What are the various
elements/objects of a database? What are the various ways to create tables in a database?
Steps to open MS- Access:
i. Table
A table is the primary unit of physical storage for data in a database. When a user accesses
the database, a table is usually referenced for the desired data. Multiple tables might comprise
a database, therefore a relationship might exist between tables. Because tables store data, a
table requires physical storage on the host computer for the database.
Types of table:
• Join tables are tables used to create a relationship between two tables that would
otherwise be unrelated.
• Validation tables, often referred to as code tables, are used to validate data entered
into other database tables.
Tables are used to store the data that the user needs to access. Tables might also have
constraints attached to them, which control the data allowed to be entered into the table. An
entity from the business model is eventually converted into a database table.
ii. Columns
iii. Rows
A row of data is the collection of all the columns in a table associated with a single
occurrence. Simply speaking, a row of data is a single record in a table. For example, if there
are 25,000 book titles with which a bookstore deals, there will be 25,000 records, or rows of
data, in the book titles table once the table is populated. The number of rows within the table
will obviously change as books' titles are added and removed. See Figure 3 for an illustration
of a row of data in a table.
A data type determines the type of data that can be stored in a database column.
Although many data types are available, three of the most commonly used data types are
• Text
• Alphanumeric/MEMO
• Numeric
Alphanumeric data types are used to store characters, numbers, special characters, or nearly
any combination. If a numeric value is stored in an alphanumeric field, the value is treated as
a character, not a number. In other words, you should not attempt to perform arithmetic
functions on numeric values stored in alphanumeric fields. Design techniques such as this
will be discussed in more detail throughout the book. Numeric data types are used to store
only numeric values. Date and time data types are used to store date and time values, which
widely vary depending on the relational database management system (RDBMS) being used.
I. DESIGN VIEW
Assignment- 6
What are the steps to create a table in design view and datasheet view?
DESIGN VIEW
DATASHEET VIEW
SQL Functions.
Arithmetic & Logical Function include Sum, Multiplication, Division, Round, AND, OR &
NOT. ->Sum: - The SUM () function returns the total sum of a numeric column. SYNTAX--
SELECT SUM(column_name) FROM table_name WHERE condition;
AND :-The AND operator displays result if both the first condition and the second condition
are true.
FROM table
WHERE condition_1 AND condition_2 AND condition_n When multiple conditions are
combined using the AND operator, all rows which meet all of the given conditions will be
returned. Now it’s time to apply the AND operator to our gym scenario. Say we wanted to
find all members that are under the age of 50 and live in Los Angeles
SELECT *
FROM members
Example- SELECT & FROM EMP WHERE Salary = 20,000 AND Empname = ‘AJAY’
OR: - The OR operator displays result if either the first condition or the second condition is
true.
SELECT *
FROM members
NOT: - The NOT operator displays result when given predicate is not satisfied.
FROM table
WHERE NOT condition When multiple conditions are combined using the NOT operator, all
rows which do not meet the given conditions will be returned.
We can use this operator with our gym example in a number of useful ways. What if we
wanted to find all of our members that were outside of Los Angeles? Using the NOT
operator, we can simply write:
SELECT *
FROM members
Query Example=
Or
Example- 2
we want to fetch the data for members that fit very specific criteria. We want members who
are:
1. BETWEEN: - The BETWEEN operator selects a range of data between two values. The
BETWEEN operator selects values within a given range. The values can be numbers, text, or
dates. The BETWEEN operator is inclusive: begin and end values are included. BETWEEN
Syntax SELECT column_name(s) FROM table_name WHERE column_name BETWEEN
value1 AND value2; EXAMPLE-- SELECT * FROM Products WHERE Price BETWEEN
10 AND 20;
1. NOT BETWEEN:- The NOT BETWEEN operator selects a range of data not between two
values. 2. SELECT * FROM Products WHERE Price NOT BETWEEN 10 AND 20;
3. LIKE:- The LIKE operator is used to search for a specified pattern in a column.
It will return the name of employee whose name starts with letter A from EMP table
IN:- The IN operator allows you to specify multiple values in a WHERE clause. The IN
operator allows you to specify multiple values in a WHERE clause. The IN operator is a
shorthand for multiple OR conditions. IN Syntax SELECT column_name(s) FROM
table_name WHERE column_name IN (value1, value2, ...); or: SELECT column_name(s)
FROM table_name WHERE column_name IN (SELECT STATEMENT);
4. NOT IN:- It used to search opposite to the WHERE clause value. SELECT * FROM
Customers WHERE Country NOT IN ('Germany', 'France', 'UK');
Query Example
Or
Or
Or
Assignment- 9
SQL (Structured Query Language) provides a variety of string functions that allow
manipulation and processing of character data. These functions enable users to perform tasks
such as string concatenation, substring extraction, case conversion, and more.
Objectives:
Trim leading and trailing spaces using the LTRIM and RTRIM functions.
1. CONCAT Function:
2. SUBSTRING Function:
The UPPER function converts a string to uppercase, while the LOWER function converts it
to lowercase.
4. LEN Function:
The LTRIM function removes leading spaces, and RTRIM removes trailing spaces from a
string.
SELECT LTRIM(employee_code) AS trimmed_code FROM employees;
Conclusion:
String functions in SQL provide powerful tools for manipulating character data in databases.
Understanding and using these functions efficiently can enhance the capabilities of SQL
queries and make data processing more flexible.
Assignment- 10
Display the name and marks of all those students who have scored marks b/w 75&90
Syntax:
SELECT name,marks FROM student WHERE marks>'75' AND marks<'90';
Output:
Arrange the marks of the students in descending order
Syntax:
SELECT name, marks FROM student ORDER BY marks;
Output:
Syntax:
Output:
Assignment- 11
Step3: Go to qury wizard, select ‘Simple query wizard’ and click next.
Assignment- 12
Create the following table CUSTOMER having the columns , data types
Customer id, customer name, designation, city, country, salary and phone no.
Insert the data into table customer and apply the queries
1. Display customer detail having designation sales representative
2. Retrive customer who is living in Canada
3. Show details of the customer whose name is Victoria
4. Show details of the customer who lives in Sweden
5. Show details of the customer who is owner
6. Display the records of the customer who is living in Canada and designation is
HR
7. Display customer who are either living in Canada or Sweden
8. Sort the salary in ascending order
Step1: Create customer table.
Output:
Oytput:
Display the records of the customer who is living in Canada and designation is HR
Syntax:
Output:
Output:
Assignment- 13
1. Write an SQL query to calculate the total purchase amount of all orders. (Return
total
purchase amount)
2. Write an SQL query to calculate the average purchase amount of all orders. (Return
average purchase amount.)
3. From the following table, write an SQL query to compute the sum of the allotment
amount
5. Write a SQL query to determine the highest purchase amount made by each
salesperson on
6. Write an SQL query to find the highest order (purchase) amount by each customer
on a
particular order date. Filter the result by the highest order (purchase) amount above
2000.00. (Return customer ID, order date, and maximum purchase amount.)
FROM orders;
FROM orders;
FROM department;
FROM customers;
-- 5. Determine the highest purchase amount made by each salesperson on '2012-08-17'.
FROM orders
GROUP BY salesperson_id;
-- 6. Find the highest order (purchase) amount by each customer on a particular order date.
-- Filter the result by the highest order (purchase) amount above 2000.00.
FROM orders
Assignment- 14
1. Find the employee ids of the employees having the same salary.
QUERY1: Find the employee ids of the employees having same salary.
QUERY2: Find the details of the employee working in the same dept.
Output:
QUERY2: Find the details of the employee working in the same dept.
Syntax:
Output:
QUERY3: Find employee id, emp-name of the employee having same dob.
Syntax:
Output:
Assignment- 15
Create a company database with the following table EMP_DETAILS with the fields as:
EMP_ID
EMP_NAME
EMP_DESIGNATION
DEPT_ID
DEPT_NAME
DEPT_LOCATION
P_ID
P_NAME
OUTPUT
➢ DEPT_DETAILS
OUTPUT
➢ PROJECTS
OUTPUT
Step 3: Select the tables between which the relation has to be shown. Select the table and
click ‘Add’.
Step 4: Click on ‘Edit Relationship’ in ‘Design’. A dialogue box will open. Click on ‘Create
New..’. Another dialogue box will open.
Step 6:Select ‘Left Column Name’ and ‘Right Column Name’ and click ‘OK’. The changes
will be made in ‘Edit Relationship’ dialogue box.
(M:1 Relation): Enter the same Attribute in “EMP_DETAIL” i.e., EMP_ID. On the other
side, enter more than one Attribute in “DEP_DETAIL”. Click on ‘OK’
OUTPUT (M:1 Relation)
Assignment- 16
Fields:
1. EMPLOYEE
• F_NAME
• L_NAME
• E_ID
• DOB
• ADDRESS
• SALARY
2. DEPARTMENT
• D_NO
• D_NAME
• MGR_NO
• MGR-DOJ
Create the forms for the employee as well as the dept table in tabular form and write
the steps to create the forms. Also provide the suitable title toboth the forms and insert
the page no’s to it.
EMPLOYEE VIEW
DEPARTMENT VIEW
STEPS TO CREATE
FORM ARE-
STEP 1-
STEP 2-
STEP 3-
STEP 4-
STEP 5-
STEP 6-
Assignment- 17
• R_no
• Name
• Course name
• Attendance
• Dob
• Add
Course will have values either economics or dbms. Enter 5 records. Create a form for
the above table in design view. Add text box and the following buttons to it:
Go to first record
Go to last record
Go to previous record
Go to next record
Step 2:Now In Create Tab Click On “More Forms” Then “Form Wizard”
Step 3:After That In Form Wizard Select All The Available Fields And Click On Next
Step 4: In The Next Step We Will Select The Layout Of The Form As Tabular
Step 5:After That We Are Required To Select Style Of Our Form
Step 6:Next We Are Required To Give A Title To Our Form In This Case We Will
Give It The Title “STUDENT_DETAILS1”
Step 9:To Add Text BOX We Will Select The Option TextBox And Add The Text Box
Where it Is Required By Clicking On The Location
Step 10: To Add Buttons We Have To Select The Option Buttons And Specify The
Location Where We Want The Button To Be Located by Clicking On The Location
after that a Command Button Wizard Will Appear From Where We Will Select What
Actions We Want The Button To Perform, What Type Of Picutre We Want On The
Button and Lastly We Can Name The Button If We Want To And Then We Will Click
On Finish To Insert Our Button
Step 11:To Add Label Click On The Option “Label “ Then Click Where You Want To
ADD The Label And The ADD The Label
Ø UNIQUE
A UNIQUE key integrity constraint requires that every value in a column or set of columns
(key) be unique-that is, no two rows of a table have duplicate values in a specified column or
set of columns.Unique Key constraint is same as primary key i.e. it does not accept duplicate
values, except the following differences. There can be only one Primary key per table.
Whereas, you can have as many Unique Keys per table as you want. Primary key does not
accept NULL values whereas; unique key columns can be left blank.
By default all columns in a table can contain null values. If you want to ensure that a column
must always have a value, i.e. it should not be left blank, then define a NOT NULL constraint
on it.
The NOT NULL constraint enforces a field to always contain a value. This means that you
cannot insert a new record, or update a record without adding a value to this field.
E.g. The column to that we apply NOT NULL constraints the value cannot be null if the
value entered is null the error will shown as shown in example below of Table “College”.
Ø Check Constraint
Check constraint is used to validate values entered into a column. CHECK constraints enforce
domain integrity by limiting the values that are accepted by a column.
CHECK constraints determine the valid values from a logical expression that is not based on
data in another column. For example, it is possible to limit the range of values for a salary
column by creating a CHECK constraint that allows only data that ranges from 15,000 through
500, 00. This prevents salaries from being entered beyond the normal salary range.
You can create a CHECK constraint with any logical (Boolean) expression that returns TRUE
or FALSE based on the logical operators.
E.g. If the CHECK Predicate is not satisfies the error will be shown as shown in example of
table “College”.