0% found this document useful (0 votes)
6 views42 pages

ISM Practical File No Page Numbers

The document provides an overview of SQL, including its history, data types, and commands such as DDL and DML. It explains the structure and syntax for creating and manipulating databases and tables, along with examples for various SQL operations. Additionally, it outlines the constraints and requirements for specific tables like Customer and Employee.

Uploaded by

Chetna Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views42 pages

ISM Practical File No Page Numbers

The document provides an overview of SQL, including its history, data types, and commands such as DDL and DML. It explains the structure and syntax for creating and manipulating databases and tables, along with examples for various SQL operations. Additionally, it outlines the constraints and requirements for specific tables like Customer and Employee.

Uploaded by

Chetna Jain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Lab practical file Information system management

Question 1: Introduction to SQL. Explain what are different types of data types in
SQL.

SQL ( Structured Query Language) is a domain-specific language used in programming and


designed for managing data held in a relational database management system (RDBMS), or for stream
processing in a relational data stream management system (RDSMS). It is particularly useful in
handling structured data, i.e. data incorporating relations among entities and variables.

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

What Can SQL do?


SQL can execute queries against a database.
SQL can retrieve data from a database.
SQL can insert records in a database.
SQL can update records in a database.
SQL can delete records from a database.
SQL can create new databases.
SQL can create new tables in a database.
SQL can create stored procedures in a database.
SQL can create views in a database.
SQL can set permissions on tables, procedures, and views.

Different data type in sql


SQL Data Types define the type of value that can be stored in a table column. For example, if we want a
column to store only integer values, then we can define its data type as int.

SQL Data Types

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.
Lab practical file Information system management

SQL Data Types important points

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

The following table lists the general data types in SQL: -


CHARACTER(n)- Character string. Fixed-length n
VARCHAR(n) or CHARACTER VARYING(n)- Character string. Variable length. Maximum
length n
BINARY(n)- Binary string. Fixed-length n
BOOLEAN- Stores TRUE or FALSE values
VARBINARY(n) or BINARY VARYING(n)- Binary string. Variable length. Maximum length n
INTEGER(p)- Integer numerical (no decimal). Precision p
SMALLINT- Integer numerical (no decimal). Precision 5
BIGINT- Integer numerical (no decimal). Precision 19
Lab practical file Information system management

Question 2: Explain SQL DDL Commands. With Syntax and Examples.


The Data Definition Language (DDL) is used to create and destroy databases and databases objects. These
SQL statements define the structure of a database, including rows, columns, tables, indexes, and databases
specifics such as file locations.
CREATE To create objects in the database.
ALTER Alters the structure of the database.

DROP Delete objects from the databases.


TRUNCATE is used to remove all records from a table, including all spaces allocated for the
records are removed.
COMMENT is used to add comments to the data dictionary.
RENAME is used to rename an object existing in the database.
The create table command: -
The create table command defines each column of the table uniquely. Each column has minimum of three
attributes.
Name
Data type
Size (column width).
Each table column definition is a single clause in the create table syntax. Each table column definition is
separated from the other by a comma. Finally, the SQL statement is terminated with a semicolon.
The Structure of Create Table Command
Table name is Student
Column name Data type Size
Reg_no varchar2 10
Name Char 30
DOB Date
Address varchar2 50

Example:
CREATE TABLE Student

(Reg_no varchar2(10),
Lab practical file Information system management

Name char(30),

DOB date,

Address varchar2(50));

The DROP Command: -


Syntax:
DROP TABLE <table_name>

Example:
DROP TABLE Student;

It will destroy the table and all data which will be recorded in it.

The TRUNCATE Command: -


Syntax:
TRUNCATE TABLE <Table_name>

Example:
TRUNCATE TABLE Student;

The RENAME Command: -


Syntax:
RENAME <OldTableName> TO <NewTableName>

Example:
RENAME <Student> TO <Stu>

The old name table was Student now new name is the Stu.

The ALTER Table Command: -


By The use of ALTER TABLE Command, we can modify our exiting table.

Adding New Columns


Syntax:

ALTER TABLE <table_name>


Lab practical file Information system management

ADD (<NewColumnName> <Data_Type>(<size>),......n)

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:

ALTER TABLE <table_name> DROP COLUMN <column_name>

Example:

ALTER TABLE Student DROP COLUMN Age

This command will drop particular column

Modifying Existing Table


Syntax:
ALTER TABLE <table_name> MODIFY (<column_name> <NewDataType>(<NewSize>))

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

Question 3: Explain SQL DML commands with Syntax and Examples.


The SQL commands that deals with the manipulation of data present in database belong to DML or Data
Manipulation Language and this includes most of the SQL statements.
Examples of DML:
SELECT is used to retrieve data from a database.
INSERT is used to insert data into a table.
UPDATE is used to update existing data within a table.
DELETE is used to delete records from a database table.

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);

The UPDATE Command: -

UPDATE QUERY is used to update existing records in the table.

Syntax

Example

Employee table. UPDATE Employee SET

The DELETE Command

DELETE QUERY is used to delete selected rows, or all rows from the table.
Lab practical file Information system management

Syntax

DELETE from table WHERE condition;

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.

create database db1;


use db1;
Create table customer (customer_id int, customer_name varchar(20), address varchar(50), city
varchar(20), pin code int, country varchar (20));
insert into customer value(01, 'pradip', '2/22 shastri park', 'New delhi', 110212, 'India');
insert into customer value(02, 'ishan', '2/23 rohini', 'New delhi', 110213, 'India');
insert into customer value(03, 'gaurav', '2/24 rohini sec 10', 'New delhi', 110214, 'India');
insert into customer value(04, 'nikhil', '2/25 welcome', 'New delhi', 110215, 'India');
insert into customer value(05, 'sagar', '2/26 tila mor', 'ghaziabad', 110216, 'India');
insert into customer value(06, 'pranav', '2/27 dilshad garden', 'New delhi', 110216, 'India');
insert into customer value(07, 'naman', '2/28 welcome', 'New delhi', 110217, 'India');
insert into customer value(08, 'himanshu', '2/29 dwarka', 'New delhi', 110218, 'India');
insert into customer value(09, 'vishal', '2/30 rohini sec 24', 'New delhi', 110219, 'India');
insert into customer value(10, 'faiz', '2/31 kalkaji', 'New delhi', 110220, 'India');
select * from customer;
Lab practical file Information system management

Question 5: Create table named Employee containing columns (emp_id, emp_name,


emp_desig, DOB, emp_sal, emp_dept). Insert atleast 10 values.

Constraints applied on Employee table:

1. Emp_id should be primary key


2. Emp_sal should not contain any Null Value
3. Emp_desig should be Unique

create database emp1;


use emp1;
create table employee(emp_id int primary key, emp_name varchar(20), emp_desig varchar(30)
unique, DOB date, emp_sal int not null, emp_dept varchar(50));
insert into employee values(01, 'AB', 'marketing manager', '1990/01/10', 50000, 'marketing');
insert into employee values(02, 'BA', 'HR manager', '1991/02/11', 60000, 'HR');
insert into employee values(03, 'CD', 'finance manager', '1992/03/12', 70000, 'finance');
insert into employee values(04, 'DE', 'production manager', '1993/04/13', 80000, 'production');
insert into employee values(05, 'EF', 'investment manager', '1994/05/14', 90000, 'investment');
insert into employee values(06, 'FG', 'sales manager', '1995/06/15', 100000, 'sales');
insert into employee values(07, 'GH', 'purchase manager', '1996/07/16', 110000, 'purchase');
insert into employee values(08, 'HI', 'Research manager', '1997/08/17', 120000, 'Research');
insert into employee values(09, 'IJ', 'Promotion manager', '1998/09/18', 130000, 'promotion');
insert into employee values(10, 'JK', 'Operations manager', '1999/10/19', 140000, 'operational');
Lab practical file Information system management

select * from employee;


Lab practical file Information system management

Question 6: Create Employee table: -

EID, ENAME, DESG, BRANCH, SALARY, ADDRESS.

Insert 10 Records.

*salary Column should not contain any Null value

*Salary should be between 5000 to 350000

*ENAME should be Unique

Perform various SQL commands

1. Add column in above table date of joining, Experience.


2. Display the Table
3. Complete the Table Definition
4. Delete the Column DESG
5. Find out details of employee whose salary is above 25000.
6. Find out details of employee order by salary.
7. Calculate total no. of records in employee table.
8. List Employees whose salary is between 10000 and 30000.

use database emp;


use emp;
create table employee(eid int, ename varchar(20) unique, desg varchar(30), branch varchar(50),
salary int not null check (salary<350000 and salary>5000), address varchar(50));
insert into employee values(1, 'Randhir', 'assistant manager', 'indirapuram', 40000, 2/210
insert into employee values(2, 'Pankaj', 'hr manager', 'mohan nagar', 40000, '2/211 near w
insert into employee values(3, 'Rajesh', 'worker', 'dilshad garden', 20000, '2/212 Pocket
insert into employee values(4, 'Anirudh', 'hr', 'rohini', 50000, '2/212 Sector 5');
insert into employee values(5, 'Raj', 'manager', 'GTB nagar', 60000, '2/213 hudson lane');
Lab practical file Information system management

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);

select * from employee;


Lab practical file Information system management

1. Add column in above table date of joining, Experience.

alter table employee add column experience date;

1. Display the Table


Lab practical file Information system management

2. Complete the Table Definition

update employee set experience= '1990/12/12';

3. Delete the Column DESG

alter table employee drop desg;


Lab practical file Information system management

4. Find out details of employee whose salary is above 25000.

select * from employee where salary>25000;

5. Find out details of employee order by salary.

select * from employee order by salary;


Lab practical file Information system management

6. Calculate total no. of records in employee table.

select count(eid) from employee;

7. List Employees whose salary is between 10000 and 30000.

select * from employee where salary between 10000 and 30000;


Lab practical file Information system management

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.

create database st1;


use st1;
create table student(roll_no int, name varchar(20), age int, course varchar(10), marks int);
insert into student values(1 'pradip', 20, 'mba', 90);
insert into student values(2, 'ishan', 19, 'bba', 80);
insert into student values(3, 'gaurav', 20, 'mba', 85);
insert into student values(4, 'nikhil', 21, 'bcom', 75);
insert into student values(5, 'aditi', 18, 'bba', 60);
select * from student;
Lab practical file Information system management

1. List all those students who are greater than 18 years of age and have opted for MBA

course.

select * from student where age>18 and course= 'mba';

2. List name o

select * from student where name like 'i%';

3. Find out total number of records in table.


Lab practical file Information system management

select count(roll_no) from student;

4. Find out the name, course, marks and sort in the order of marks.

select name, course, marks from student order by marks;

5. Display name and course of student.

select name, course from student;


Lab practical file Information system management

6. Find the Student with Max marks.

select max(marks), name from student;

7. List the name of students ORDER BY Roll_no in Descending order.

select name from student order by roll_no desc;

8. Find out the Average of all the Marks. Display it as Average_Marks

select avg(marks) from student;


Lab practical file Information system management
Lab practical file Information system management

Question8: Create the Following Tables. Insert at least 10 records in each.

Table 1: Supplier (S_No, Sname, Status, City)

Table 2: Parts (P_No, Pname, Color, Weight, City)

Table 3: SP (S_No, P_No, Quantity)

Answer the following queries in SQL:

(b) Find suppliers whose

(c) Find all suppliers whose status is 10, 20 or 30

(d) Find total number of city of all suppliers

(e) Find the name of suppliers who supplies quantity of the item P1 more than 50

Answer

create database dat;


use dat;
create table supplier(s_no int primary key, s_name varchar(20), status int, city varchar(30));

insert into supplier values(10, 'aman', 20, 'delhi');


insert into supplier values(20, 'bhavna', 30, 'aligarh');
insert into supplier values(30, 'sheetal', 60, 'aligarh');
insert into supplier values(40, 'Abhishek', 30, 'mumbai');
insert into supplier values(50, 'pradeep', 20, 'mumbai');
insert into supplier values(60, 'sagar', 50, 'delhi');
insert into supplier values(70, 'ishan', 30, 'goa');
insert into supplier values(80, 'Gaurav', 70, 'Mathura');
insert into supplier values(90, 'Nikhil', 40, 'Ambala');
Lab practical file Information system management

insert into supplier values(100, 'uday', 50, 'Ambala');

select * from supplier;

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

insert into parts values('p2', 'keyboard', 'white', 500, 'delhi');


insert into parts values('p3', 'monitor', 'black', 1000, 'ambala');
insert into parts values('p4', 'speaker', 'black', 400, 'mumbai');
insert into parts values('p5', 'speaker', 'white', 500, 'mouse');
insert into parts values('p6', 'webcam', 'brown', 200, 'mathura');
insert into parts values('p7', 'printer', 'white', 400, 'delhi');
insert into parts values('p8', 'cpu', 'black', 900, 'delhi');
insert into parts values('p9', 'ups', 'blue', 700, 'mumbai');
insert into parts values('p10', 'cpu', 'black', 400, 'mumbai');

select * from parts;


Lab practical file Information system management

Table 3

create table sp(s_no int primary key, p_no varchar(10), quantity int);

insert into sp values(10, 'p1', 30);


insert into sp values(20, 'p3', 70);
insert into sp values(30, 'p1', 80);
insert into sp values(40, 'p8', 10);
insert into sp values(50, 'p6', 90);
insert into sp values(60, 'p1', 70);
insert into sp values(70, 'p5', 20);
insert into sp values(80, 'p1', 80);
insert into sp values(90, 'p7', 10);
insert into sp values(100, 'p1', 90);

select * from sp;


Lab practical file Information system management

Select s_name from supplier where city='delhi';

2.

select * from supplier where s_name like 'ab%';

3.Find total number of city of all suppliers


Select count(city) from supplier;
Lab practical file Information system management

4. Find all suppliers whose status is 10, 20 or 30


Select s_name from supplier where status in (10,20,30);

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

Question9: What do you understand by ER Modelling? Explain all the symbols of ER


Model with examples.

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.

There are three basic components of an entity relationship diagram:

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.

3. The relationships between and among those entities.

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.)

The three main cardinalities are:

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.

ER Diagrams Symbols, and notations

Er Diagram Symbols and Notations

Components of an E-R diagram

An E-R diagram constitutes of following Components

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.

Entities can be characterized into two types:


Lab practical file Information system management

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:

Simple attribute: - An attribute is classified as a simple attribute if it cannot be partitioned into


smaller components. For example, age and sex of a person. A simple attribute is represented by an
oval.
Composite attribute: - A composite attribute can be subdivided into smaller components which

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

represent this attribute.


Multi valued attribute: An attribute which can hold more than one value, it is then termed as
multi-valued attribute. For example, phone number of a person. Symbol of multi-valued attribute is
shown below,

Multi Valued Attribute

Derived attribute: A derived attribute calculates its value fro

attribute is represented by a dashed oval.

C. Relationships: - A relationship is defined as bond or attachment between 2 or more entities. Normally,


a verb in

a sentence signifies a relationship.

For example,

An employee assigned a project.


Teacher teaches a student.
Lab practical file Information system management

Author writes a book.

A diamond is used to symbolically represent a relationship in the e-r diagram.

Relationship

Various terms related to relationships

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.

b.) Connectivity of a relationship: - Connectivity of a relationship describes, how many instances of


one entity type are linked to how many instances of another entity type. Various categories of connectivity of
a relationship are;

One to One (1:1) -to-one relationship because only


one instance of an entity is related with exactly one instance of another entity type.

One to One

One to Many (1:M) -to-many relationship because a


department can recruit more than one faculty, but a faculty member is related to only one department.

One to Many

Many to One (M:1) -to-one relationship because


a person can own many houses but a particular house is owned only a person.
Lab practical file Information system management

Many to One

Many to Many (M: N) -to-many relationship because an author


can write many books and a book can be written by many authors.

Many to Many

Many to Many (M: N) -to-many relationship because an author


can write many books and a book can be written by many authors.
Lab practical file Information system management

Question10: Draw Entity Relationship diagram of an Organization.

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.

In this ERD of organization: -

Department has: - Name, D_no, Location


Project has: - P_Name, P_Duration, P_No.
Employee: -Name, DOB, Gender, Phone_No. Email.

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

Question11: Draw Entity Relationship diagram of a Banking System.

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.

In this ERD of organization: -

BANK: - B_id, Name, Address


Account: - Acc_no, Acc_type, balance.
Customer: - Name, C_Id, Phone.no., Address.
Card facilities: - Card_no., Credit_card, Debit_card, Rvpay

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

Question12: Draw Entity Relationship diagram of a Hospital Management System.

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

Question13: Draw Entity Relationship diagram of a University.

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

You might also like