Professional Documents
Culture Documents
ON
“SQL COMMANDS AND ER DIAGRAMS”
SUBMITTED
IN PARTIAL FULFILMENT FOR THE REQUIREMENT OF
MASTER OF BUSINESS ADMINISTRATION
(2021-2023)
I KAREENA LUTHRA hereby state that this report has been submitted to
Management Education & Research Institute in partial fulfilment of the
requirement for Masters of Business Administration on the topic “SQL
COMMANDS AND ER DIAGRAMS.”
I have followed all the guidelines provided by the University in writing the report.
And I assert that the work contained in this report is original and has been done by
me under the supervision of my Mentor Ms. Lakshmi Kumari.
The success and outcome of this report required a lot of guidance and assistance
from many people and I am extremely privileged to get this all along the completion.
My sincere thanks and humble regards to Management Education and Research
Institute, Affiliated to Guru Gobind Singh Indraprastha University, New Delhi for
imparting us very valuable professional training in MBA.
My gratitude and sincere regards to Ms. Lakshmi Kumari my project guide, for
guiding me throughout the project.
I am very thankful to her as she has been a constant source of advice, motivation, and
inspiration.
I am thankful to my family and friends for constantly motivating me to complete the
report and providing me an environment which enhanced my knowledge.
NO.
EXPERIMENT-1
1. PART A: CREATION OF TABLE EMPLOYEE 8
EXPERIMENT-2
EXPERIMENT-3
EXPERIMENT-4
EXPERIMENT-5
EXPERIMENT-1
I. Select the names of all employees whose names start from ‘A’.
J. Select the average salary of an employee.
O. Display the length of the hobby field. Also give its alias name as “Length
of the hobby field”.
P. Count the total number of employees in each department with their
average salary.
In an RDBMS, tables reference one another through common fields and to ensure
validity references, referential integrity is enforced. Referential integrity is a system
of rules that a DBMS uses to ensure that relationships between records in related
tables are valid, and that users don’t accidentally delete or change related data.
Referential integrity is ensured through FOREIGN KEY constraint.
Where two tables are related by a common column (or set of columns), then the
related columns in the ‘parent table’ (or primary table) should be either declared
a PRIMARY KEY or UNIQUE KEY and the related columns in the ‘child table’ (or
related table) should have FOREIGN KEY constraint.
All the dept numbers i.e., deptno in the employee table are derived from
DEPARTMENT table as, DEPARTMENT is the “PARENT TABLE” whereas
EMPLOYEE is the “CHILD TABLE”. Simultaneously, dept no in the
Department table is known as “primary key” & as “foreign key” in the
Employee table.
This type of relationship between two tables and their attributes (fields) is called a
referential integrity constraint. Referential integrity constraints can be implemented
with the CREATE OR ALTER TABLE statements.
T. Delete all the records and remove both the tables.
EXPERIMENT-2
AIM: A publishing company produces scientific books on various subjects. The books
are written by authors who specialize in one subject. The company employs editors
who, not necessarily being specialists in a particular area, each take sole
responsibility for editing one or more publications.
A publication covers essentially one of the specialist subjects and is normally written
by a single author. When writing a particular book, each author works with on editor,
but may submit another work for publication to be supervised by other editors. To
improve their competitiveness, the company tries to employ a variety of authors,
more than one author being a specialist in a particular subject.
concerns edited by
Subject Publication
is specialized in
Editor
is written by
Author
Author-Editor
works with employs
EXPERIMENT-3
A separate register is to be held to store the information of the tests undertaken and
the results of a prescribed treatment. A number of tests may be conducted for each
patient. Each patient is assigned to one leading consultant but may be examined by
another doctor, if required. Doctors are specialists in some branch of medicine and
may be leading consultants for a number of patients, not necessarily from the same
ward.
specialised in
Ward Specialty
Tests
gives
is admitted to
specialised in
Test-Results Treatment
follows devises
gets
is diagnosed diagnoses
Patient Diagnosis Doctor
recommends
assigned to
0
GP Consultant
EXPERIMENT-4
INNER JOIN
The INNER JOIN keyword selects records that have matching values in both tables.
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
SELECT column_name(s)
FROM table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;
RIGHT OUTER JOIN/ RIGHT JOIN
The RIGHT JOIN keyword returns all records from the right table (table2), and the
matching records from the left table (table1). The result is 0 records from the left
side, if there is no match.
SELECT column_name(s)
FROM table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;
EXPERIMENT-5
VIEWS
A view is nothing more than a SQL statement that is stored in the database with an
associated name. A view is a composition of a table in the form of a
predefined SQL query.
A view can contain all rows of a table or select rows from a table. A view can be
created from one or many tables which depends on the written SQL query to create a
view.
TRIGGER
A trigger is a stored procedure in database which automatically invokes
whenever a special event in the database occurs. For example, a trigger can
be invoked when a row is inserted into a specified table or when certain table
columns are being updated.
Each procedure in SQL Server always contains a name, parameter lists, and
Transact-SQL statements. The SQL Database Server stores the stored procedures as
named objects.
EXEC procedure_name;
Or
EXECUTE procedure_name;
-----------------------