ISM Practical File No Page Numbers
ISM Practical File No Page Numbers
Question 1: Introduction to SQL. Explain what are different types of data types in
SQL.
SQL (Structured Query Language) is a database sublanguage for querying and modifying relational databases.
It was developed by IBM
Institutes) in 1986.
The Structured Query Language (SQL) is a language of databases. All modern relational databases, including
Access, FileMaker pro, Microsoft SQL Server and Oracle use SQL as their basic building block. All of the
graphical user interfaces that provide data entry and manipulation functionality are nothing more than SQL
translators. They take the actions you perform graphically and convert them to SQL commands understood by
the database. Using SQL, you can insert records, update records, and delete records. You can also create new
database objects such as databases and tables. And you can drop (delete) them.
SQL offers two main advantages over older read write APIs such as ISAM or VSAM. Firstly, it introduced
the concept of accessing many records with one single command. Secondly, it eliminates the need to
specify how to reach a record, e.g. with or without an index.
Originally based upon relational algebra and tuple relational calculus, SQL consists of many types of
statements, which may be informally classed as sub languages, commonly: a data query
language (DQL), a data definition language (DDL), a data control language (DCL), and a data manipulation
language (DML). The scope of SQL includes data query, data manipulation (insert, update and delete), data
definition (schema creation and modification), and data access control. Although SQL is essentially
a declarative language (4GL), it includes also procedural elements.
SQL was one of the first commercial languages to utilize Edgar F.Codd relational model. The model was
described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks". Despite
not entirely adhering to the relational model as described by Codd, it became the most widely used database
language.
History
Lab practical file Information system management
SQL was initially developed at IBM by Donald D. Chamberlin and Raymond F. Boyce after learning about
the relational model from Ted Codd in the early 1970s. This version, initially called SEQUEL (Structured
English Query Language), was designed to manipulate and retrieve data stored in IBM's original quasi-
relational database management system, System R, which a group at IBM San Jose Research Laboratory had
developed during the 1970s.
Chamberlin and Boyce's first attempt of a relational database language was Square, but it was difficult to use
due to subscript notation. After moving to the San Jose Research Laboratory in 1973, they began work on
SEQUEL. The acronym SEQUEL was later changed to SQL because "SEQUEL" was a trademark of
the UK-based Hawker Siddeley Dynamics Engineering Limited company. After testing SQL at customer test
sites to determine the usefulness and practicality of the system, IBM began developing commercial products
based on their System R prototype including System/38, SQL/DS, and DB2, which were commercially
available in 1979, 1981, and 1983, respectively.
In the late 1970s, Relational Software, Inc. (now Oracle Corporation) saw the potential of the concepts
described by Codd, Chamberlin, and Boyce, and developed their own SQL-based RDMS with aspirations of
selling it to the U.S. Navy, Central Intelligence Agency, and other U.S. government agencies. In June 1979,
Relational Software, Inc. introduced the first commercially available implementation of SQL, Oracle V2
(Version2) for VAX computers.
By 1986, ANSI and ISO standard groups officially adopted the standard "Database Language SQL"
language definition. New versions of the standard were published in 1989, 1992, 1996, 1999, 2003, 2006,
2008, 2011] and, most recently, 2016.
Design
SQL deviates in several ways from its theoretical foundation, the relational model and its tuple calculus. In
that model, a table is a set of tuples, while in SQL, tables and query results are lists of rows: the same row
may occur multiple times, and the order of rows can be employed in queries (e.g. in the LIMIT
clause).Critics argue that SQL should be replaced with a language that returns strictly to the original
foundation: for example, see The Third Manifesto. However, no known proof exists that such uniqueness
cannot be added to SQL itself, or at least a variation of SQL. In other words, it's quite possible that SQL can
be "fixed" or at least improved in this regard such that the industry may not have to switch to a completely
different query language to obtain uniqueness. Debate on this remains open.
Lab practical file Information system management
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.
Lab practical file Information system management
Not all data types are supported by every relational database vendor. For example, Oracle database
database schema and writing sql queries, make sure to check if the data types are supported or not.
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
here.
Every relational database vendor has its
need to remember the limit. Idea is to have the knowledge of what data type to be used in a specific
scenario.
Lab practical file Information system management
Example:
CREATE TABLE Student
(Reg_no varchar2(10),
Lab practical file Information system management
Name char(30),
DOB date,
Address varchar2(50));
Example:
DROP TABLE Student;
It will destroy the table and all data which will be recorded in it.
Example:
TRUNCATE TABLE Student;
Example:
RENAME <Student> TO <Stu>
The old name table was Student now new name is the Stu.
Example:
ALTER TABLE Student ADD (Age number(2), Marks number(3));
The Student table is already existing and then we added two more columns Age and Marks respectively, by
the use of above command.
Dropping a Column from the Table
Syntax:
Example:
Example:
ALTER TABLE Student MODIFY (Name Varchar2(40));
The Name column already exist in Student table, it was char and size 30, now it is modified by Varchar2 and
size 40.
Restriction on the ALTER TABLE
Using the ALTER TABLE clause the following tasks cannot be performed.
Change the name of the table
Change the name of the column
Decrease the size of a column if table data exists
Lab practical file Information system management
The Insert Command: SQL INSERT statement allows to insert single or multiple records into the tale.
Syntax
INSERT INTO table
(column-1,column- -n)
(value-1, value- -n);
Syntax
Example
DELETE QUERY is used to delete selected rows, or all rows from the table.
Lab practical file Information system management
Syntax
Example
The following example delete the record where EID equals to 10 from the Employee table, DELETE from
Employee WHERE EID=10;
Lab practical file Information system management
Question 4: Create a table named Customer (C_id, C_name, Address, city, pin code,
Country). Insert at least 10 values. Display the table.
Insert 10 Records.
insert into employee values(6, 'Nitin', 'hr', 'noida', 70000, '2/212 sector 16');
insert into employee values(7, 'Niranjan', 'factory head', 'Netaji subhash place', 80000,
insert into employee values(8, 'Abhishek', 'branch head', 'Kohat', 120000, 2/223);
insert into employee values(9, 'Vivek', 'finance manager', 'Shalimar garden', 100000, 2/24
insert into employee values(10, 'Abhay', 'factory head', 'shastri nagar', 110000, 2/248);
Question 7: Create the following table and perform SQL commands. Student (Roll_no,
name, age, course, marks).
1. List all those students who are greater than 18 years of age and have opted for MBA
course.
2.
3. Find out total number of records in table.
4. Find out the name, course, marks and sort in the order of marks.
5. Display name and course of student.
6. Find the Student with Max marks.
7. List the name of students ORDER BY Roll_no in Descending order.
8. Find out the Average of all the Marks. Display it as Average_Marks.
1. List all those students who are greater than 18 years of age and have opted for MBA
course.
2. List name o
4. Find out the name, course, marks and sort in the order of marks.
(e) Find the name of suppliers who supplies quantity of the item P1 more than 50
Answer
Table 2
create table parts(p_no varchar(20) primary key, p_name varchar(20), color varchar(10), weight int,
city varchar(30));
insert into parts values('p1', 'mouse', 'white', 100, 'delhi');
Lab practical file Information system management
Table 3
create table sp(s_no int primary key, p_no varchar(10), quantity int);
2.
5. Find the name of suppliers who supplies quantity of the item P1 more than 50
select s_name from supplier, sp where supplier.s_no=sp.s_no and sp.p_no='p1' and sp.quantity>50;
Lab practical file Information system management
An entity relationship diagram (ERD), also known as an entity relationship model, is a graphical representation
of an information system that depicts the relationships among people, objects, places, concepts or events within
that system. An ERD is a data modelling technique that can help define business processes and be used as the
foundation for a relational database.
1. Entities, which are objects or concepts that can have data stored about them.
2. Attributes, which are properties or characteristics of entities. An ERD attribute can be denoted as a primary
key, which identifies a unique attribute, or a foreign key, which can be assigned to multiple attributes.
An entity relationship diagram showing relationships between sales reps, customers and product orders.
For example, an ERD representing the information system for a company's sales department might start with
graphical representations of entities such as the sales representative, the customer, the customer's address, the
customer's order, the product and the warehouse. Then lines or other symbols can be used to represent the
relationship between entities, and text can be used to label the relationships.
A cardinality notation can then define the attributes of the relationship between the entities. Cardinalities can
denote that an entity is optional (for example, a sales rep could have no customers or could have many) or
mandatory (for example, there must be at least one product listed in an order.)
1. A one-to-one relationship (1:1). For example, if each customer in a database is associated with one
mailing address.
2. A one-to-many relationship (1: M). For example, a single customer might place an order for multiple
products. The customer is associated with multiple entities, but all those entities have a single
connection back to the same customer.
Lab practical file Information system management
3. A many-to-many relationship (M: N). For example, at a company where all call center agents work
with multiple customers, each agent is associated with multiple customers, and multiple customers
might also be associated with multiple agents.
A. Entity: - Any real-world object can be represented as an entity about which data can be stored in a
database. All the real world objects like a book, an organization, a product, a car, a person are the examples of
an entity. Any living or non-living objects can be represented by an entity. An entity is symbolically
represented by a rectangle enclosing its name.
Strong entity: A strong entity has a primary key attribute which uniquely identifies each entity.
Symbol of strong entity is same as an entity.
Weak entity: A weak entity does not have a primary key attribute and depends on other entity via
a foreign key attribute.
B. Attribute: - Each entity has a set of properties. These properties of each entity are termed as attributes.
For example, a car entity would be described by attributes such as price, registration number, model number,
color etc. Attributes are indicated by ovals in an e-r diagram.
A primary key attribute is depicted by an underline in the e-r diagram. An attribute can be characterized into
following types:
first name and last name which further form attributes. Grouping of these related attributes forms a
Lab practical file Information system management
Composite Attribute
Single valued attribute: - If an attribute of a particular entity represents single value for each
instance, then it is called a single-valued attribute. For example, Ramesh, Kamal and Suraj are the
For example,
Relationship
a). Degree of relationship: - It signifies the number of entities involved in a relationship. Degree of a
relationship can be classified into following types:
Unary relationship: - If only single entity is involved in a relationship then it is a unary relationship.
For example, An employee(manager) supervises another employee.
Unary relationship
Binary relationships: - when two entities are associated to form a relation, then it is known as a
binary relationship. For example, A person works in a company. Most of the times we use only binary
relationship in an e-r diagram. The teacher-student example shown above signifies a binary
relationship.
Lab practical file Information system management
Other types of relationships are ternary and quaternary. As the name signifies, a ternary relationship is
associated with three entities and a quaternary relationship is associated with four entities.
One to One
One to Many
Many to One
Many to Many
Entity: A definable thins such as person, abject, concept or event that can have data stored about it
think of entities as noun.
In this ERD of organization we have three Entities: - Department, Project, Employee.
Attributes: A property or characteristic of an entity. Often shown as an oval.
Relationship: - Relationships are typically shown as diamonds on the connecting lines. In this ERD of
organization we have four relationships: - works for, supervise, control.
PRIMARY KEY: - The field that is unique for all the record occurrences.it denotes as Underline. In this
ERD we have D_no in as primary key in Department, P_no in Project and Email in Employee.
Lab practical file Information system management
Entity: A definable thins such as person, abject, concept or event that can have data stored about it think
of entities as noun.
In this ERD of organization we have four Entities: - Bank, Card facility, Account, Customer.
TRANSACTION, Accounts.
Attributes: A property or characteristic of an entity. Often shown as an oval.
Relationship: - Relationships are typically shown as diamonds on the connecting lines. In this ERD of
organization we have four relationships:-Offers, Has, Has.
PRIMARY KEY: - The field that is unique for all the record occurrences.it denotes as Underline. In this
ERD we have bank_id in as primary key in Bank, Acc_No in Account, C_id in Customer, Card_No. in Card
facilities.
Lab practical file Information system management
Entity: A definable thins such as person, Object, concept or event that can have data stored about it
think of entities as noun.
In this ERD we have five Entities: - Patient, Medical records, Hospital, Doctor,
Attributes: A property or characteristic of an entity. Often shown as an oval.
In this ERD: -
Patient: - P. Name, P.Id, P. Address, P.Diagnosis
Hospital: - Hos.Id, Hos.Name, Hos.No.
Medical records: - R.No, Room. Charge, Doc.Charge
Doctor:-Doc_id, Doc_Name, Salary, Qualification
Relationship: - Relationships are typically shown as diamonds on the connecting lines. In this ERD of
organization we have four relationships: -Has, admitted in, has
PRIMARY KEY: - The field that is unique for all the record occurrences.it denotes as Underline. In this
ERD we have P-id in patient, Hos-id in Hospital, R.No in Medical record, Doc-id in Doctor.
Lab practical file Information system management
Entity: A definable thins such as person, Object, concept or event that can have data stored about it
think of entities as noun.
In this ERD we have five Entities: - Student, University, College, Course, Faculty
Attributes: A property or characteristic of an entity. Often shown as an oval.
In this ERD:-
Student: - Stu_Id, Stu_Name, DOB, Phone_no
University: - Uni_name, Uni_id, Location, Fees
College: - Name, Location, Clg_id
Course: -Course_Id, Name, Duration
Faculty: -Salary, Fac_name, Fac_id, Qualification
Relationship: - Relationships are typically shown as diamonds on the connecting lines. In this ERD of
organization we have four relationship: -Has, Study in, Enrols in, Teaches by
PRIMARY KEY: - The field that is unique for all the record occurrences.it denotes as Underline. In this
ERD we have Stu_id In Student, Uni_id in University, Clg_id in College, Course_id in Course, Fac_name in
Faculty.
Lab practical file Information system management