Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
85 views29 pages

SQL Lab Practical Guide

The document is a lab practical file submitted by a student for their Information System Management course. It contains 10 questions covering topics like an introduction to SQL, different data types in SQL, SQL commands, creating tables, ER diagrams, and more. The file includes the student's responses to the questions in detail providing information on the key concepts.

Uploaded by

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

SQL Lab Practical Guide

The document is a lab practical file submitted by a student for their Information System Management course. It contains 10 questions covering topics like an introduction to SQL, different data types in SQL, SQL commands, creating tables, ER diagrams, and more. The file includes the student's responses to the questions in detail providing information on the key concepts.

Uploaded by

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

Lab Practical File Information System Management

GURU GOBIND SINGH


INDRAPRASTHA
UNIVERSITY
NEW DELHI

Practical Lab File


ON
Information System Management Lab
(BCOM - 307)
Submitted in partial fulfillment of the requirement
for the award of degree of B.com (H)
Session: 2019-2022

SUBMITTED AT:
DELHI SCHOOL OF PROFESSIONAL STUDIES & RESEARCH
ROHINI, NEW DELHI-85
[AFFILIATED TO GGSIPU-NEW DELHI]

Submitted By: Submitted To:


Aayushi Roy
MS. Anshika Negi
04612588819
(Assistant Professor)
Bcom 5A
Lab Practical Information Management

INDEX
S.No. CONTENT PgNo. T.SIGN

1 Introduction to SQL. i-iii

2 Explain different types of data types in iii-vi


SQL.

3 EXPLAIN SQL DDL COMMANDS. vi-viii

4 EXPLAIN SQL DML COMMANDS. ix-xi

5 Create a table named Customer. xii-xiii

6 Create and perform SQL commands. xiii-xv

7 Create Suppliers, Parts, SP Table. xv-xviii

8 What do you understand by ER xix-xxv


Model.

9 ER Diagram of Library management xxv-xxvi


system.

10 ER Diagram of a University. xxvi-xxvii


Lab Practical Information Management

Questions 1: Introduction to SQL.


SQL –Introduction.
SQL is a language to operate databases; it includes database creation, deletion, fetching
rows, modifying rows, etc. SQL is an ANSI (American National Standards Institute)
standard language, but there are many different versions of the SQL language.

What is SQL?
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.


Why SQL?
SQL is widely popular because it offers the following advantages −
Allows users to access data in the relational database management
systems. Allows users to describe the data.
Allows users to define the data in a database and manipulate that data.
Allows to embed within other languages using SQL modules, libraries & pre-compilers.
Allows users to create and drop databases and tables.
Allows users to create view, stored procedure, functions in a
database. Allows users to set permissions on tables, procedures and
views.

SQL Process

When you are executing an SQL command for any RDBMS, the system determines the
best way to carry out your request and SQL engine figures out how to interpret the task.
There are various components included in this process.
1
Lab Practical Information Management

These components are −

 Query Dispatcher
 Optimization Engines
 Classic Query Engine
 SQL Query Engine, etc.
A classic query engine handles all the non-SQL queries, but a SQL query engine won't
handle logical files.
Following is a simple diagram showing the SQL Architecture −

A Brief History of SQL


1970 − Dr. Edgar F. "Ted" Codd of IBM is known as the father of relational databases. He
described a relational model for databases.
1974 − Structured Query Language appeared.
1978 − IBM worked to develop Codd's ideas and released a product named System/R.
1986 − IBM developed the first prototype of relational database and standardized by ANSI.
The first relational database was released by Relational Software which later came to be
known as Oracle

Advantages of SQL:
* High Speed:

2
Lab Practical Information Management

SQL Queries can be used to retrieve large amounts


of records from a database quicklyand efficiently.
* Well Defined Standards Exist:
SQL databases use long-established standard,

which is being adopted by ANSI & ISO. Non-


SQL databases do not adhere to any clear
standard.
* No Coding Required:

Using standard SQL it is easier to manage


database systems without having to write
substantial amount of code.

Disadvantages of SQL:
* Difficulty in Interfacing:
Interfacing an SQL database is more complex
than adding a few lines of code.
* More Features Implemented in Proprietary way:

Although SQL databases conform to ANSI & ISO


standards, some databases go for proprietary
extensions to standard SQL to ensure vendor lock-
in

Question 2: Explain what are the different types of data types in SQL
MySQL uses many different data types broken into three categories −

 Numeric
 Date and Time
 String Types.

3
Lab Practical Information Management

Numeric Data Types

MySQL uses all the standard ANSI SQL numeric data types, so if you're coming to
MySQL from a different database system, these definitions will look familiar to you.
The following list shows the common numeric data types and their descriptions −
 INT − A normal-sized integer that can be signed or unsigned. If signed, the
allowable range is from -2147483648 to 2147483647. If unsigned, the allowable
range is from 0 to 4294967295. You can specify a width of up to 11 digits.
 TINYINT − A very small integer that can be signed or unsigned. If signed, the
allowable range is from -128 to 127. If unsigned, the allowable range is from 0 to
255. You can specify a width of up to 4 digits.
 SMALLINT − A small integer that can be signed or unsigned. If signed, the
allowable range is from -32768 to 32767. If unsigned, the allowable range is from
0 to 65535. You can specify a width of up to 5 digits.
 MEDIUMINT − A medium-sized integer that can be signed or unsigned. If signed,
the allowable range is from -8388608 to 8388607. If unsigned, the allowable range
is from 0 to 16777215. You can specify a width of upto 9 digits.
 BIGINT − A large integer that can be signed or unsigned. If signed, the allowable
range is from -9223372036854775808 to 9223372036854775807. If unsigned, the
allowable range is from 0 to 18446744073709551615. You can specify a width of
up to 20 digits.
 FLOAT(M,D) − A floating-point number that cannot be unsigned. You can define
the display length (M) and the number of decimals (D). This is not required and
will default to 10,2, where 2 is the number of decimals and 10 is the total number
of digits (including decimals). Decimal precision can go to 24 places for a FLOAT.

4
Lab Practical Information Management

 DOUBLE(M,D) − A double precision floating-point number that cannot be


unsigned. You can define the display length (M) and the number of decimals (D).
This is not required and will default to 16,4, where 4 is the number of decimals.
Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for
DOUBLE.
 DECIMAL(M,D) − An unpacked floating-point number that cannot be unsigned.
In the unpacked decimals, each decimal corresponds to one byte. Defining the
display length (M) and the number of decimals (D) is required. NUMERIC is a
synonym for DECIMAL.

Date and Time Types

The MySQL date and time datatypes are as follows −


 DATE − A date in YYYY-MM-DD format, between 1000-01-01 and 9999-12-31.
For example, December 30th, 1973 would be stored as 1973-12-30.
 DATETIME − A date and time combination in YYYY-MM-DD HH:MM:SS
format, between 1000-01-01 00:00:00 and 9999-12-31 23:59:59. For example, 3:30
in the afternoon on December 30th, 1973 would be stored as 1973-12-30 15:30:00.
 TIMESTAMP − A timestamp between midnight, January 1st, 1970 and sometime
in 2037. This looks like the previous DATETIME format, only without the
hyphens between numbers; 3:30 in the afternoon on December 30th, 1973 would be
stored as 19731230153000 ( YYYYMMDDHHMMSS ).

 TIME − Stores the time in a HH:MM:SS format.


 YEAR(M) − Stores a year in a 2-digit or a 4-digit format. If the length is specified
as 2 (for example YEAR(2)), YEAR can be between 1970 to 2069 (70 to 69). If the
length is specified as 4, then YEAR can be 1901 to 2155. The default length is 4.

String Types

Although the numeric and date types are fun, most data you'll store will be in a string
format. This list describes the common string datatypes in MySQL.
 CHAR(M) − A fixed-length string between 1 and 255 characters in length (for
example CHAR(5)), right-padded with spaces to the specified length when stored.
Defining a length is not required, but the default is 1.
 VARCHAR(M) − A variable-length string between 1 and 255 characters in length.
For example, VARCHAR(25). You must define a length when creating a
VARCHAR field.
 BLOB or TEXT − A field with a maximum length of 65535 characters. BLOBsare
"Binary Large Objects" and are used to store large amounts of binary data, such as
images or other types of files. Fields defined as TEXT also hold large amounts of
data. The difference between the two is that the sorts and comparisons on the stored
data are case sensitive on BLOBs and are not case sensitive in TEXT fields. You
do not specify a length with BLOB or TEXT.

5
Lab Practical Information Management

 TINYBLOB or TINYTEXT − A BLOB or TEXT column with a maximum length


of 255 characters. You do not specify a length with TINYBLOB or TINYTEXT.
 MEDIUMBLOB or MEDIUMTEXT − A BLOB or TEXT column with a
maximum length of 16777215 characters. You do not specify a length with
MEDIUMBLOB or MEDIUMTEXT.
 LONGBLOB or LONGTEXT − A BLOB or TEXT column with a maximum
length of 4294967295 characters. You do not specify a length with LONGBLOB
or LONGTEXT.
 ENUM − An enumeration, which is a fancy term for list. When defining an
ENUM, you are creating a list of items from which the value must be selected (or it
can be NULL). For example, if you wanted your field to contain "A" or "B" or "C",
you would define your ENUM as ENUM ('A', 'B', 'C') and only those values (or
NULL) could ever populate that field.

Question 3: EXPLAIN SQL DDL COMMANDS . With Syntax and


Examples.
DDL(Data Definition Language) : DDL or Data Definition Language actually
consists of the SQL commands that can be used to define the database schema. It simply
deals with descriptions of the database schema and is used to create and modify the
structure of database objects in the database.

SQL-DDL Commands

The DDL commands in SQL are used to create database schema and to define the type and
structure of the data that will be stored in a database. SQL DDL commands are further
divided into the following major categories:

 CREATE
 ALTER
 DROP
 TRUNCATE

CREATE

The CREATE query is used to create a database or objects such as tables, views, stored
procedures, etc.

 Creating a database

The following example demonstrates how the CREATE query can be used to create a
database in MS SQL Server:

CREATE DATABASE Library

The script above creates a database named “Library” in MS SQL Server.

6
Lab Practical Information Management

 Creating a table

The CREATE query is also used to add tables in an existing database as shown in the
following script:
USE Library
CREATE TABLE Books
(
Id INT PRIMARY KEY IDENTITY(1,1),
Name VARCHAR (50) NOT NULL,
Price INT
)

The above script creates a table named “Books” in the “Library” database that we created
earlier.
The “Books” table contains three columns: Id, Name, and Price. The Id column is the
primary key column and it cannot be NULL. A column with a PRIMARY KEY constraint
must contain unique values. However, since we have set the IDENTITY property for the Id
column, every time a new record is added in the Books table, the value of the Id column
will be incremented by 1, starting from 1. You need to specify the values for the Name
column as well as it cannot have NULL. Finally, the Price column can have NULL values.
To view all the tables in the Library, execute the following QL DDL script:
USE Library
SELECT * FROM INFORMATION_SCHEMA.TABLES

OUTPUT:

ALTER
By The use of ALTER TABLE Command we can modify our exiting table.
 Adding New
Columns ALTER
Syntax: TABLE <table_name>

ADD (<NewColumnName>

Example: ALTER TABLE Student ADD (Age number(2), Marks

The Student table is already exist and then we added two more columns Age and Marks
respectively, by the use of above command.
 Dropping a Column from the Table

7
Lab Practical Information Management

Syntax:
ALTER TABLE <table_name> DROP COLUMN <column_name>
Example:
ALTER TABLE Student DROP COLUMN Age;

This command will drop particular column.


 Modifying
ExistingTable Syntax:
ALTER TABLE <table_name> MODIFY

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 DROP
Syntax: DROP TABLE <table_name>

Example: DROP TABLE Student;

The TRUNCATE Command


Syntax: TRUNCATE TABLE <Table_name>

Example: TRUNCATE TABLE Student;

Questions 4: EXPLAIN SQL DML COMMANDS . With syntax and


example.

8
Lab Practical Information Management

SQL-DML Commands
Data Manipulation Language (DML) statements or commands are used for managing data
within tables. Some commands of DML are:
Some commands of DML are:
SELECT – retrieve data from the a database
INSERT – insert data into a table
UPDATE – updates existing data within a table
DELETE – deletes all records from a table, the space for the records remain
MERGE – UPSERT operation (insert or update)
SELECT
 Viewing Data in the Table (Select Command)
Once data has been inserted into a table, the next most logical operation would be to view
what has been inserted. The SELECT SQL verb is used to achieve this.
All Rows and All Columns

Syntax: SELECT * FROM Table_name;

Example: Select * from Student; It will show all the

SELECT First_name, DOB FROM STUDENT WHERE Reg_no = 'S101'; Cover it


by single inverted comma if its datatype is varchar or char.
This Command will show one row. because you have given condition for only one row
and particular records. If condition which has given in WHERE Clause is true then
records will be fetched otherwise it will show no records selected.
Eliminating Duplicates:
A table could hold duplicate rows. In such a case, you can eliminate duplicates.

Syntax: SELECT DISTINCT col, col, .., FROM table_name;

Example: SELECT DISTINCT * FROM Student;


OR
SELECT DISTINCT first_name, city, pincode FROM Student;

9
Lab Practical Information Management

It scans through entire rows, and eliminates rows that have exactly the same contents in
each column.
 Sorting DATA:
The Rows retrieved from the table will be sorted in either Ascending or Descending order
depending on the condition specified in select statement, the Keyword has used ORDER
BY.

SELECT * FROM Student


ORDER BY First_Name;

it will in show records as alphabetical order from A to Z ascending order. If you want
Descending order means Z to A then used DESC Keyword at last.

Example : SELECT first_name, city,pincode FROM Student


ORDER BY First_name DESC;
INSERT
The insert statement is used to add new row to a

Syntax: INSERT INTO <table name> VALUES (<value 1>, ... <value
n>);
Example:

INSERT INTO STUDENT VALUES (1001,‘Ram’);

The inserted values must match the table structure exactly in the number of attributes and
the data type of each attribute. Character type values are always enclosed in single quotes;
number values are never in quotes; date values are often (but not always) in the format
‘yyyy- mm-dd’ (for example, ‘2006-11- 30’).

UPDATE :
The update statement is used to change values that are already in a table.
Example:
Syntax:
UPDATE
UPDATE STUDENT SET
<table name> Name
SET = ‘Amar’
<attribute> WHERE StudID=1001;
= <expression> WHERE <condition>;

10
Lab Practical Information Management

The update expression can be a constant, any computed value, or even the result of a
SELECT statement that returns a single row and a single column.

DELETE :
The delete statement deletes row(s) from a table.

Example:
Syntax:
STUDENT
DELETE FROM <table WHERE
name> StudID=1001;
WHERE <condition>;

If the WHERE clause is omitted, then every row of the table is deleted that matches with
the specified condition.

Question 5: Create table named customer (c_id, c_name, address, city, pincode ,
country) .Insert atleast 10 values .Display the table.

11
Lab Practical Information Management

12
Lab Practical Information Management

Question 6: Create the following table and perform SQL commands. Student (Roll_no, name,
age, course, marks).

13
Lab Practical Information Management

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

2. List name of student whose name end with ‘i’.

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.

14
Lab Practical Information Management

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

Question 7: Create the Following Tables. Insert atleast 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:

a. Find the supplier for city = ‘Delhi’


b. Find suppliers whose name start with ‘AB’
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

15
Lab Practical Information Management

Table 1

16
Lab Practical Information Management

Table 2

Table 3

17
Lab Practical Information Management

The supplier for city = ‘Delhi’ :

The suppliers whose name starts with ‘AB’ :

All suppliers whose status is 10, 20 or 30 :

Total number of city of all suppliers :

The name of suppliers who supplies quantity of the item P1 more than 50 :

18
Lab Practical Information Management

Questions 8: What do you understand by ER Modelling ? Explain all the


symbol of ER model with examples .
ER - MODELLING
Entity Relationship Modeling (ER Modeling) is a graphical approach to database design. It uses
Entity/Relationship to represent real world objects.

An Entity is a thing or object in real world that is distinguishable from surrounding environment.
For example each employee of an organization is a separate entity. Following are some of major
characteristics of entities.

An entity has a set of properties.

Entity properties can have values.

The building blocks of an ERD are entities, relationships and attributes. Entities have entity types,
which are known as instances of the corresponding entities. Each entity type can exist independently
of another; for example, the entity "vehicle" can have the entity types "car" and "bus." Relationship
is the property that links the entity types together. For example, the entity type husband is related to
the entity type wife by a relationship known as "is-married-to." Attributes are properties that belong
to the entity types as well as to the relationships.

There are a number of ER diagramming tools available on the market. The most common ones are
MySQL Workben
Components of the ER Diagram

This model is based on three basic concepts:

Entities

Attributes

Relationships

Example

For example, in a University database, we might have entities for Students, Courses, and
Lecturers. Students entity can have attributes like Rollno, Name, and DeptID. They might have
relationships with Courses and Lecturers.ch and Open model Sphere.

19
Lab Practical Information Management

WHAT IS ENTITY?
A real-world thing either living or non-living that is easily recognizable and nonrecognizable. It is
anything in the enterprise that is to be represented in our database. It may be a physical thing or
simply a fact about the enterprise or an event that happens in the real world.

An entity can be place, person, object, event or a concept, which stores data in the database. The
characteristics of entities are must have an attribute, and a unique key. Every entity is made up of
some 'attributes' which represent that entity.
Examples of entities:

Person: Employee, Student, Patient

Place: Store, Building

Object: Machine, product, and Car

Event: Sale, Registration, Renewal

Concept: Account, Course

Notation of an Entity

Entity set
An entity set is a group of similar kind of entities. It may contain entities with attribute sharing
similar values. Entities are represented by their properties, which also called attributes. All attributes
have their separate values. For example, a student entity may have a name, age, class, as attributes.
Example of Entities:

A university may have some departments. All these departments employ various lecturers and offer
several programs.

20
Lab Practical Information Management

Some courses make up each program. Students register in a particular program and enroll in various
courses. A lecturer from the specific department takes each course, and each lecturer teaches a
various group of students.

Relationship
Relationship is nothing but an association among two or more entities. E.g., Tom works in the
Chemistry department.

Entities take part in relationships. We can often identify relationships with verbs or verb

phrases. For example:

You are attending this lecture

I am giving the lecture

Just loke entities, we can classify relationships according to relationship-types:

A student attends a lecture

A lecturer is giving a lecture. Weak Entities

A weak entity is a type of entity which doesn't have its key attribute. It can be identified uniquely by
considering the primary key of another entity. For that, weak entity sets need to have participation.

In above example, "Trans No" is a discriminator within a group of transactions in an ATM.

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

21
Lab Practical Information Management

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:

ER Diagrams Symbols, and notations

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.

Components of an E-R diagram


An E-R diagram constitutes of following Components

o Strong entity: A strong entity has a primary key attribute which uniquely
identifies each entity.
Symbol of strong entity is same as an entity

o Weak entity: A weak entity does not have a primary key attribute and depends
on other entity via a foreign key attribute.

22
Lab Practical Information Management

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 further form attributes. For example, ‘name’ attribute of an entity “person”
can be broken down into first name and last name which further form attributes. Grouping of
these related attributes forms a composite attribute. ‘name is the composite attribute in this
example.

 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 instances of entity ‘student’ and each
of themis issued a separate roll number. A single oval is used to 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,
23
Lab Practical Information Management

Multi Valued Attribute


 Derived attribute: A derived attribute calculates its value from another attribute.
For example, ‘age’ is a derived attribute if it calculates its value from ‘current date’ &
‘birth date’ attributes. A derived 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 arelationship.
For example,
o An employee assigned a project.
o Teacher teaches a student.
o Author writes a book
A diamond is used to symbolically represent a relationship in the e-r diagram.

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:
o 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.

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

24
Lab Practical Information 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;
o One to One (1:1) – “Student allotted a project” signifies a one-to-one
relationship because only one instance of an entity is related with exactly
one instance of another entity type.

o One to Many (1:M) – “A department recruits faculty” is a one-to-many


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

o Many to One (M:1) – “Many houses are owned by a person” is a many-


to- one relationship because a person can own many houses but a particular
house is owned only a person.

o Many to Many (M: N) – “Author writes books” is a many-to-many


relationship because an author can write many books and a book can be
written by many authors.

Question 10: Draw Entity Relationship diagram of a Library 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 Four Entities: - Books, Readers, Staff, Authentication System

25
Lab Practical Information Management

Attributes : A property or characteristic of an entity. Often shown as an oval


In this ERD : -

i. Books :- Author, SR no., Publisher, Price, Category, Title, ISBN


ii. Readers :- Name, M-Name, L-Name, Class, Phone no., Roll no., ID
iii. Staff :- Name, ID
iv. Authentication System :- Username, Password
Relationship: - Relationships are typically shown as diamonds on the connecting lines. In
this ERD of organization we have six relationship :- Login, maintain, Issue, Reserve,
Return, Keep tracks

Question 10: Draw Entity relationship diagram of 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

26
Lab Practical Information Management

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.

27

You might also like