SlideShare a Scribd company logo
1 of 52
]
PROJECT REPORT
ON
“database management of policy schema”
AT
Maruti Suzuki India Limited
Gurgaon (Haryana)
In Partial Fulfillment for the Award of the degree of
BACHELOR OF TECHNOLOGY
(Session 2011)
Submitted By: Under the Guidance of:
Nimish Nagpal Mr. Sachin Aggarwal
B. Tech Project Mentor
Roll No: C-2615 Maruti Suzuki India Ltd
MARUTI SUZUKI INDIA LIMITED
1
PREFACE
Software has become the key element in the evolution of computer based
systems and products. Over the past four decades, software has evolved
from the specialized problem solving and information analysis tool to an
industry itself. The software development process involves the scales and
experience of the people involved.
The six week period after fourth semester of B-Tech is a training period as a
part of curriculum; this provides valuable practical experience to the students
and an individual treasure of experience, and offers an exposure to the real
time management in an organization. It is the period during which the
student is introduced and familiarized to the industrial environment. With the
advancement in computer technology and increased automation, the software
industry has become all the more important. The introduction of computers
and electronics in the field of processing has made it essential that the input
be much more accurate and controllers much faster in response. The state of
art used in all the process-controlled industry spares us from tension of
managing the fast process manually, thus ensuring improved operating
efficiency and full protection.
Industrial training is the major part of theoretical studies as it covers all that
remains uncovered in the classroom i.e. without it, the studies remains
ineffective and incomplete. The objective of training is to raise the
performance of the studies in one or more of its aspects. This may be
achieved by providing new knowledge and information relevant to the
project, by teaching new trends by imbuing an individual with new attitude,
motives, co-ordinates, co-operation and other personality developing
characteristics. Often these technologies are utilized with segments of the
work force regardless of the existing performance level, to operate efficiently.
Since gaining theoretical knowledge is just not sufficient for sure
success in life, especially in an ever growing industry like this,
practical training plays an important role in building the future of an
individual. During my training period, I had the opportunity to gain
the practical experience at MARUTI SUZUKI INDIA LIMITED,
GURGAON. I seek this instance in a very satisfactory manner &
believe that it will be very beneficial for me.
MARUTI SUZUKI INDIA LIMITED
2
CANDIDATE’S DECLARATION
I hereby declare that the work that is presented by me for Maruti Suzuki India
Ltd. in partial fulfillment of the requirements for the award of the degree of B-Tech.
in Information Technology, submitted to Gurgaon Institute of Technology &
Management , Gurgaon (Haryana), is an authentic record of work carried out
during the period June, 2011 to July, 2011 at MSIL, Gurgaon.
No part of this report has been submitted to any other university or institution for
any other degree or reward.
Nimish Nagpal
B-Tech
Univ. Roll No: 09-IT-544
Computer Science & Engineering
Gurgaon Institute of Technology & Management,
Gurgaon (Haryana),
MARUTI SUZUKI INDIA LIMITED
3
CERTIFICATE
This is to certify that Mr. Nimish Nagpal S/O Sh. Jawarhar Lal Nagpal student of MCA
has undergone Practical internship training at Maruti Suzuki India Limited (MSIL) under
my supervision. He has worked on “MIN Schema” during his training.
Mr. Sachin Aggarwal
(Project Manager)
MARUTI SUZUKI INDIA LIMITED
4
ACKNOWLEDGMENT
Industrial training is an indispensable part of B-Tech curriculum. It
provides the students with an opportunity to gain experience on the
practical applications of their knowledge. My training at MARUTI SUZUKI
INDIA LTD., GURGAON has been very fruitful. I am sure that the hands
on experience I have gained here will go a long way towards making me a
competent engineer.
I would like to convey my sincere gratitude to Mr. Gautam (Manager,
IPS), Mr. Sachin Aggarwal (my mentor),
my project guide who provided me with timely and proper guidance
whenever required. This provided me experience in not only the technical
and practical aspects of industry but also in human relations, team work
and provided great insights into the actual working of an industry. Without
their efforts, this training would not have been such a great learning
experience as it has been.
I take this opportunity to also thank all the staff of Maruti Suzuki India
Ltd. who offered unconditional support and encouragement throughout
the course of my training. I hereby also declare that the contents in this
report are true to the best of my knowledge.
NIMISH NAGPAL
(Trainee)
MARUTI SUZUKI INDIA LIMITED
5
Table of Contents
1. Company Profile
1.1 Background of the Indian Auto Industry
1.2 Background of SMC
1.3 Suzuki & Maruti World-class Manufacturing Facilities at Manesar
1.4 Introduction to Maruti Suzuki India Limited
1.5 The hierarchy diagram of MSIL
1.6 IT Division
2. Training
2.1 Introduction
2.2 Classroom Training
3. Database of Policy_Schema
3.1 Type of Architecture
3.1.1 Introduction
3.1.2 Client-Server / N-Tier System
3.2 SQL Editor- PL/SQL Developer
3.2.1 Starting in PL/SQL Developer:
3.2.2Creating Table
3.2.3Inserting Data
3.2.4Updating Data
3.2.5Grouping Data
3.2.6 Deleting Data
3.2.7Ordering Data
3.2.8Union
3.2.9Creating Indexes
3.2.10 Table Aliases
3.2.11Auto Increment
3.2.12Constraint
 Primary Key
 Foreign Key
3.3 DATABASE OF POLICY SCHEMAS
3.3.1 Introduction
3.3.2 SQL coding
3.4 Stored Procedures
MARUTI SUZUKI INDIA LIMITED
6
3.5 Triggers
3.6. CYCLIC CASCADING in a TRIGGER
Conclusion
References
MARUTI SUZUKI INDIA LIMITED
7
Chapter1
ORGANISATIONAL PROFILE
1.1 Background of the Indian Auto Industry
1.2 Background of SMC
1.3 Suzuki & Maruti World-class Manufacturing Facilities at Maneser
1.4 Introduction to Maruti Suzuki India Limited
1.5 The hierarchy diagram of MSIL
1.6 The IT Division
MARUTI SUZUKI INDIA LIMITED
8
Introduction to MSIL, Gurgaon
Maruti Udyog Ltd., an automobile industry was established in 1982. It was a
joint venture between Government of India (74%) and Suzuki Motor
Corporation (26%). The company came to India with two objectives: first to
make a small, fuel efficient and environment friendly car. That’s how Maruti
800 was the first car to be launched by the company.
After that, SMC collaborated with MUL in 2001 and today, it is known as
Maruti Suzuki India Ltd (MSIL).Therefore, Maruti Suzuki Today is:
• Suzuki’s largest manufacturing facility outside Japan.
• Maruti’s contribution in Suzuki group
– Volumes ~ 30%
– Profit ~ 34%
• Suzuki Board member, one of the top 6 in the group is the MD & CEO of
Maruti Suzuki
• First in Customer Satisfaction
– For eleven times in a row (JD Power, 2000-2011).
• MSIL, the country’s largest car manufacturer rolled out its 1Crore (ten
million) car in March, 2011.
First car manufacturer in India to achieve the landmark.
MARUTI SUZUKI INDIA LIMITED
9
Company Profile
“Stimulate the value chain for business excellence
by providing innovative information systems
using appropriate IT”
1.1 BACKGROUND OF THE INDIAN AUTO INDUSTRY
Although the Indian car industry was established in the late forties, there was
little growth or technical progress, as passenger cars were given very low
priority in the scheme of Centralized Economic Planning. In the 1980s, the car
industry was undergoing technological stagnation and was characterized by low
production volumes, high cost and low productivity. The consumer had very
little choice and the market was selling just around 30,000 cars per year.
There was a clear need to provide a cost effective, reliable and quality car to
the customers. Maruti Udyog Limited was incorporated in such a scenario as a
fully owned Government Company on February 24, 1981 with a resolve to
bring about expansion and technological modernization, of the automobile
sector. Thus MUL, when started was entrusted with the task of achieving the
following policy objectives:
 Modernization of Indian Automobile Industry.
 Production of Vehicles in large volumes, which was necessary for
economic growth.
 Production of Fuel-efficient vehicles to conserve scarce resources.
 Choice of product and collaborator.
To achieve the above objectives, one of the foremost tasks before Maruti
Udyog Limited was to determine the most suitable product mix and to select
the most suitable foreign partner who would be willing to accept MUL’s
MARUTI SUZUKI INDIA LIMITED
10
requirements in terms of product mix, technology transfer, and equality
participation and had the required technological expertise and experience in
producing high quality, reliable and fuel efficient vehicles.
After extensive discussion with several major European and Japanese car
manufacturers, MUL chose Suzuki Motor Corporation (SMC) that further
increased its equity holding to 50% in the year 1992, converting Maruti Udyog
Ltd., into a Non-Government Company with a total Equity base of Rs. 1322.92
million.
1.2 BACKGROUNDOF SMC
SUZUKI was founded in 1909 as Suzuki Loom Manufacturing Company. It
started manufacturing motorcycles in 1952 and has become a world leader in
the manufacture of two-wheelers .SUZUKI started producing cars from
1955.Today it is Japan’s largest manufacturers of small , fuel-efficient cars.
At present the company’s name is SUZUKI MOTOR CORPORATION.
1.3 SUZUKI AND MARUTI’S WORLD-CLASS MANUFACTURING FACILITIES AT MANESAR
On February 06,2007 Mr. Bhupinder Singh Huda, Chief Minister of Haryana,
inaugurated three world-class manufacturing facilities set up by SMC and
Maruti Udyog Limited.
The facilities inaugurated were as follows:
 MUL’s fourth car Assembly plant.
 A diesel engine and transmission plant, set up under a joint
venture of SMC and MUL called Suzuki Power train India Limited (SPIL)
 SMC’s two-wheeler plant in Gurgaon, Suzuki Motorcycle India Private
Limited (SMIPL).
1.4 INTRODUCTION TO MARUTI SUZUKI INDIA LIMITED
 A License and a Joint Venture Agreement was signed with Suzuki Motor
Company of Japan, in OCT. 1982
 Market leader with over 54% Share in Domestic Car Market Exporting
cars to over 70 countries around the world including most advance
Western European Markets.
 Maruti has revolutionized the Indian Automobile and Component
Industry and has set standards in quality of products and service.
MARUTI INSTALLED CAPACITY
MARUTI SUZUKI INDIA LIMITED
11
 PLANT 1 200,000 units
 PLANT 2 150,000 units
 PLANT 3 150,000 units
 PLANT 4 100,000 units
COMPANY MISSION
 A leader in the Indian Automobile Industry.
 Creating Customer Delight and Shareholders wealth.
 A pride of India!
LEADERSHIP
 By Market share and brand equity
 By operational practices
 By people strategy
CUSTOMER DELIGHT
 Values for money
 Quality
 Service
SHARE HOLDERS WEALTH
 High Profitability & Image
A PRIDE OF INDIA
 As a corporate citizen
 Products
 People
 Practices
 Customers
VALUES
 Customer Obsession
 Fast, Flexible, First Mover
 Innovation and creativity
 Networking and partnership
 Openness and learning
MARUTI SUZUKI INDIA LIMITED
12
QUALITY POLICY
To increase consumer satisfaction through continuous improvement of
products and services, this is achieved by following PDCA functions and
levels of Maruti Organizations.
Quality Policy
“CONSUMER SATISFACTION THROUGH QUALITY OF OUR PRODUCTS AND
SERVICES ACHIEVED BY CONSISTENT ADHERENCE TO PROCEDURES AND
SYSTEMS.”
Quality Tools
 5 S
 4 M
 3 M
 3 G
 3 K
PLAN
DO
CHECKACT
QUALITY
POLICY
MARUTI SUZUKI INDIA LIMITED
13
What is 5S?
SEIRI – PROPER SELECTION
SEITION – ARRANGEMENT
SEISO – CLEANING
SEIKETSO – CLEANLINESS
SHITSUKE– DISCIPLINE
What is 4M?
The factory is essentially a mix of man, materials, machines and methods.
These should move continuously and effectively to produce a quality product
at low cost. The most essential work in quality control is to thoroughly
investigate regarding the problems concerning quality, decide suitable
counter measures and carry out improvements accordingly.
 MAN
 MACHINE
 MATERIAL
 METHODS
What is 3M?
In Japanese Language 3M is:
MURI – INCONVENIENCE
MUDA – WASTAGE
MURA – INCONSISTENCY
What is 3G?
In Japanese Language 3G is:
GENCHI – ACTUAL PLACE
GENBUTSU – ACTUAL THING
GENJITSU – ACTUALLY
What is 3K?
In Japanese Language 3K is:
KIMERAARETA KOTO GA: – What has been decided
MARUTI SUZUKI INDIA LIMITED
14
KIHON DIRI: – As per the standard
KICHIN TO MAMORU: – Must be followed
MARUTI SUZUKI INDIA LIMITED
15
The hierarchy diagram of MSIL
WORKER
TRAINEE
ASSISTANT SUPERVISOR
SUPERVISOR
EXECUTIVE
SENIOR EXECUTIVE
DEPUTY MANAGER
MANAGER
DEPARTMENT MANAGER
D V M
PART TIME DIRECTOR
DIRECTOR
JOINT MANAGING DIRECTOR
MANAGING DIRECTOR
CHAIRMAN
MARUTI SUZUKI INDIA LIMITED
16
1.7 INFORMATION TECHNOLOGY DIVISION
Information Technology Division (ITD) in Maruti was set up to keep
pace with the changing environment i.e. emerging trends in IT and their
impact on manufacturing industries. Today in Maruti all business functions
are IT driven, which help in attaining better productivity and high quality
levels besides providing better work environment. In fact any process
reengineering or new process conceptualization happens with the help of IT.
Most of the applications are in–house developed using Oracle & MS
Technologies. Also, Maruti has implemented Oracle e–business suites in the
areas of finance and HR.
The IT Division comprises of following departments:
ITD
APPLICATION GROUPS OPERATIONS
AG 1 AG 2 AG 3 IOS OSS IPS
ITS
ISM
MARUTI SUZUKI INDIA LIMITED
17
APPLICATION GROUP I (AG-I)
This department is responsible for all
 ERP Financial Accounting System
 Material
 Personnel Inventory System.
 Vendor Extranet
 This department is responsible for all computerization activities related
to materials system (or supply) and Scrap.
APPLICATION GROUP II (AG-II)
This department is responsible for all activities related to
 Sales
 Warranty claims
 Service Division activities
 Dealer Extranet
 RO Extranet
APPLICATION GROUP III (AG-III)
This department is responsible for all computerization activities related to
 Sales Support and Quality Gate
 Spare Parts Division activities
 Vehicle Tracking System (VTS)
IT OPERATION AND SERVICES (IOS)
This is very important department of IT Division .This unit does all the IT
 Infrastructure planning
 Procurement and maintenance
 It takes care of all the hardware, network, data centre management
and facility management.
INFORMATION TECHNOLOGY STRATEGY (ITS)
This department evaluates new Information Technology initiatives and
checks its Feasibility before it is being implemented.
MARUTI SUZUKI INDIA LIMITED
18
IT Partners and Support Services (IPS)
This department is mainly engaged in
 Dealer Management System (DMS)
 Customer Relation Ship Management (CRM)
Operating Support Services (OSS)
This department is responsible for
 ERP HR
 ERP Payroll
IT SERVICES MANESAR (ISM)
This department manages all the IT infrastructure at Manesar plant.
IT MISSION
“Stimulate the value chain for business excellence by providing
innovative Information systems using appropriate IT.”
Maruti IT mission emphasizes the need for innovation and appropriate IT
systems to drive business excellence. Appropriate IT system refers to
making optimum and not excessive use of technology. And most
importantly, IT has to permeate the entire value chain including its vendors
and dealers.
MARUTI SUZUKI INDIA LIMITED
19
Chapter 2
TRAINING
2.1 Introduction
2.2 Classroom Training
MARUTI SUZUKI INDIA LIMITED
20
2.1 INTRODUCTION
In this chapter, I intend to give a brief overview of the training undertaken at
MSIL. During the course of my training, for the first month, we trainees were
put through a very well organized professional training program with flair of
classroom training focused on the business processes.
The objective behind this training was to give us an inside on the day to day
business operations at MSIL and how IT division enhances the productivity
and smooth-lines these operations.
The methodology followed at MSIL is to develop a chapter for self learning;
the training sessions were very participative, we were encouraged to come
forward with or ideas which would help in enhancing the system.
2.2 CLASSROOM TRAINING
As the first day I had a verbal discussion with my Mentor. We had a formal
introduction, with some basic understanding related about the system
database ITD handles. He put some light on few topics, such as:
 Client-server Architecture
 Database Exception Handling
 Oracle
 Frontend & Backend Applications
MARUTI SUZUKI INDIA LIMITED
21
Oracle 9i
ORACLE provides the following features:
 Large database and space management control
It supports the largest of databases, potentially hundreds of gigabytes in
size. To make efficient use of expensive hardware devices, it allows full
control of space usage.
 Many concurrent database users
It supports large number of concurrent users executing a variety of database
applications operating on the same data. It minimizes data contention and
guarantees data concurrence.
 High transaction processing performance
It maintains a high degree of system performance.
 Industry accepted standards
It adheres to industry–accepted standard for the data access language,
operating system, and user interface and network communication protocols.
 Manageable security
It provides fail–safe security features to limit and monitor data access to
protect against unauthorized database access and use.
 Database enforced integrity
It enforces data integrity. So the costs of coding and managing checks in
many database applications are eliminated
 Client/Server (distributed processing) environments
It allows processing to be split between the database server and client
application programs. All responsibilities of shared data management can be
processed by the computer running the database management system while
the workstations running the database application concentrate on the
interpretation and display of data.
 Portability
Application developed for ORACLE can be ported to any operating system
with little or no modification.
 Connectable
ORACLE software allows different types of computers and operating system
to share information across networks.
MARUTI SUZUKI INDIA LIMITED
22
Chapter 3
3.1 Type of Architecture
3.1.1 Introduction
3.1.2 Client-Server / N-Tier System
3.2 SQL Editor- PL/SQL Developer
3.2.1 Starting in PL/SQL Developer:
3.2.2Creating Table
3.2.3Inserting Data
3.2.4Updating Data
3.2.5Grouping Data
3.2.6 Deleting Data
3.2.7Ordering Data
3.2.8Union
3.2.9Creating Indexes
3.2.10 Table Aliases
3.2.11Auto Increment
3.2.12Constraint
 Primary Key
 Foreign Key
3.3 DATABASE OF POLICY SCHEMAS
3.3.1 Introduction
3.3.2 SQL coding
3.4 Stored Procedures
3.5 Triggers
3.6. CYCLIC CASCADING in a TRIGGER
MARUTI SUZUKI INDIA LIMITED
23
3.1.1 Introduction
Architecture is plan for
 N-tier Architecture/ Client-Server
 There tier Architecture
3.1.2Client-Server / N-Tier Systems
N-Tier architectures are hot. Well, maybe not as hot as a few years ago,
but still it is very important you know about them. All web applications are N-
Tier architectures. You have an application server, a large number of clients,
and a database. An N-Tier architecture is really a Client-Server architecture
combined with the Layered architecture. The reason why I combine Client-
Server and N-Tier here is because they are very much related.
A Client-Server system is one in which the server performs some kind of
service that is used by many clients. The clients take the lead in the
communication. The basic Client-Server architecture has 2 tiers (Client and
Server). I will basically explain the 3-tier architecture here, which is an
extension to the 2-tier architecture.
The first, or presentation tier, a.k.a. the client or front-end, deals with
the interaction with the user. Usually, there can be any number of clients
which can all access the server at the same time. Currently the clients are
mostly thin clients, which means they do not contain a lot of application code
(in contrast to fat clients). Clients process user input, send requests to the
server, and show the results of these requests to the user. A common client
is made up of a number of dynamic HTML pages that one can access with a
web browser.
The second, or application tier, a.k.a. the server, or the back-end, or
middleware, processes the requests of all clients. It is the actual web
application that performs all functionality specific to the web application.
However, it does not store the persistent data itself. Whenever it needs data
of any importance, it contacts the database server.
The third, or database tier contains the database management system
that manages all persistent data.
MARUTI SUZUKI INDIA LIMITED
24
It is clear that there are multiple clients. That's what client-server
computing is all about. However, in the second and third tier there can also
be multiple instances of the same application. If this is the case, it is because
of scalability, load-balancing and redundancy. Which means the system is
important, so let's add extra equipment that does the same thing. This
makes the server a very powerful system, but also introduces
synchronisation problems.
Examples
 Web-applications. Where the first tier is the application-tier, the second
tier is the application tier and the third tier is the database tier.
Where does it come from?
At the advance of multitasking operating systems in the nineteen-sixties,
it became possible to access a single computer (the server) from different
terminals (clients). The distance between the clients and the server became
bigger and the number of clients increased. At the time the application and
database tiers were still integrated. It is called client-server computing.
With the booming of the Internet and e-commerce in the nineteen-nineties,
the architecture became important, and much time and money was invested
in it. As other good architectures have shown, it is a good idea to separate
the application code from the data. This principle was applied to the client-
server architecture. Companies created application servers to ease the
creation of web applications.
An N-tier architecture (with N more than 3) is really 3 tier architectures in
which the middle tier is split up into new tiers. The application tier is broken
down into separate parts. What these parts are differs from system to
system. The following picture shows it:
MARUTI SUZUKI INDIA LIMITED
25
When should you use it?
You don't usually need to build your own application and database server.
Most application developers either build the application specific front-end
code, or the application specific back-end code. This code is then embedded
in an existing application server and uses an existing database management
server.
How does it work?
The architecture is so generic it is hard to say anything concrete about it.
Communication between the different tiers often takes place via a network.
Communication within a tier also is done over a (local) network. Clients don't
communicate directly to each other. Clients communicate to the application
server directly or to a broker that balances requests between separate server
machines. The database layer usually contains only one database.
MARUTI SUZUKI INDIA LIMITED
26
3.2 SQL Editor- PL/SQLDeveloper
What is PL/SQL?
PL/SQL stands for Procedural Language extension of SQL.
PL/SQL is a combination of SQL along with the procedural features of
programming languages. It was developed by Oracle Corporation in the early
90’s to enhance the capabilities of SQL.
The PL/SQL Engine:
Oracle uses a PL/SQL engine to processes the PL/SQL statements. A PL/SQL
code can be stored in the client system (client-side) or in the database
(server-side).
A Simple PL/SQL Block:
Each PL/SQL program consists of SQL and PL/SQL statements which from a
PL/SQL block.
A PL/SQL Block consists of three sections:
 The Declaration section (optional).
 The Execution section (mandatory).
 The Exception (or Error) Handling section (optional).
Declaration Section:
The Declaration section of a PL/SQL Block starts with the reserved keyword
DECLARE. This section is optional and is used to declare any placeholders like
variables, constants, records and cursors, which are used to manipulate data
in the execution section. Placeholders may be any of Variables, Constants and
Records, which stores data temporarily. Cursors are also declared in this
section.
Execution Section:
The Execution section of a PL/SQL Block starts with the reserved keyword
BEGIN and ends with END. This is a mandatory section and is the section
where the program logic is written to perform any task. The programmatic
constructs like loops, conditional statement and SQL statements form the
part of execution section.
MARUTI SUZUKI INDIA LIMITED
27
Exception Section:
The Exception section of a PL/SQL Block starts with the reserved keyword
EXCEPTION. This section is optional. Any errors in the program can be
handled in this section, so that the PL/SQL Blocks terminates gracefully. If
the PL/SQL Block contains exceptions that cannot be handled, the Block
terminates abruptly with errors.
3.2.1Starting in PL/SQL Developer:
 Login-id, Database Name and Password provided by the department
are to be entered first.
 If the parameters match the in-built records, access is permitted.
 SQL window is opened wherein the queries for creation, updation,
insertion, deletion etc. for new table is performed.
 Press (shift + home) key combination to select a particular query.
 Press F8 to execute.
 The created table gets embedded in the database which will be later
needed for the system designing as the QUERY SOURCE.
The sample queries performed for creating a mock table in the initial stages
of my training are shown as below:
Creating Table:
The CREATE TABLE statement is used to create a table in a database.
Syntax
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
)
CREATE INDEX index_name
ON table_name (column_name)
While creating a table few things are necessary such as datatype, commas, n etc.
These tables are created in main database of the system.
InsertingData:
The INSERT INTO statement is used to insert a new row in a table.
MARUTI SUZUKI INDIA LIMITED
28
Syntax
It is possible to write the INSERT INTO statement in two forms.
The first form doesn't specify the column names where the data will be inserted, only
their values:
INSERT INTO table_name
VALUES (value1, value2, value3,...
The second form specifies both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3,...)
VALUES (value1, value2, value3,...)
While inserting into a table previously created should follow the sequence of the
columns in the table.
To insert a alpha-numeric value we put single-quotes( ‘ ‘) whereas not for numeric
value.
Updating Data:
The UPDATE statement is used to update existing records in a table.
Syntax
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies
which record or records that should be updated. If you omit the WHERE clause, all
records will be updated!
DeletingData:
The DELETE statement is used to delete rows in a table.
Syntax
DELETE FROM table_name
WHERE some_column=some_value
Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies
which record or records that should be deleted. If you omit the WHERE clause, all
records will be deleted!
MARUTI SUZUKI INDIA LIMITED
29
GroupingData:
Aggregate functions often need an added GROUP BY statement.
The GROUP BY statement is used in conjunction with the aggregate functions to group
the result-set by one or more columns.
Syntax
SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operatorvalue
GROUP BY column_name
OrderingData:
The ORDER BY keyword is used to sort the result-set by a specified column.
The ORDER BY keyword sort the records in ascending order by default.
If you want to sort the records in a descending order, you can use the DESC keyword.
Syntax
SELECT column_name(s)
FROM table_name
ORDER BY column_name(s) ASC|DESC
Union:
Syntax
SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
Note: The UNION operator selects only distinct values by default. To allow duplicate values,
use UNION ALL.
UNION ALL Syntax
SELECT column_name(s) FROM table_name1
MARUTI SUZUKI INDIA LIMITED
30
UNION ALL
SELECT column_name(s) FROM table_name2
The column names in the result-set of a UNION are always equal to the column names in the
first SELECT statement in the UNION.
Creating Indexes:
An index can be created in a table to find data more quickly and efficiently.
The users cannot see the indexes, they are just used to speed up searches/queries.
Note: Updating a table with indexes takes more time than updating a table without
(because the indexes also need an update). So you should only create indexes on columns
(and tables) that will be frequently searched against.
Syntax
CREATE INDEX index_name
ON table_name (column_name)
UNIQUE INDEX Syntax
CREATEUNIQUE INDEXindex_name
ON table_name (column_name)
Note: The syntax for creating indexes varies amongst different databases. Therefore: Check
the syntax for creating indexes in your database.
Table Aliases:
You can give a table or a column another name by using an alias. This can be a good thing to
do if you have very long or complex table names or column names.
An alias name could be anything, but usually it is short.
Syntax
SELECT column_name(s)
FROM table_name
AS alias_name
MARUTI SUZUKI INDIA LIMITED
31
Syntax for Columns
SELECT column_name AS alias_name
FROM table_name
Alias Example
We have a table called "Persons" and another table called "Product_Orders". We will give the
table aliases of "p" and "po" respectively.
Now we want to list all the orders that "Ola Hansen" is responsible for.
We use the following SELECT statement:
SELECT po.OrderID, p.LastName, p.FirstName
FROM Persons AS p,
Product_Orders AS po
WHERE p.LastName='Hansen' AND p.FirstName='Ola'
Auto Increment:
Very often we would like the value of the primary key field to be created automatically every
time a new record is inserted.
We would like to create an auto-increment field in a table.
Syntax
The following SQL statement defines the "P_Id" column to be an auto-increment primary key
field in the "Persons" table:
CREATE TABLE Persons
(
P_Id int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (P_Id)
)
By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each
new record.
To let the AUTO_INCREMENT sequence start with another value, use the following SQL
statement:
MARUTI SUZUKI INDIA LIMITED
32
ALTER TABLE Persons AUTO_INCREMENT=100
To insert a new record into the "Persons" table, we will not have to specify a value for the
"P_Id" column (a unique value will be added automatically):
INSERT INTO Persons (FirstName,LastName)
VALUES ('Lars','Monsen')
The SQL statement above would insert a new record into the "Persons" table. The "P_Id" column would
be assigned a unique value. The "FirstName" column would be set to "Lars" and the "LastName" column
would be set to "Monsen"
Constraint
 Primary Key
 Foreign Key
 PrimaryKey
The PRIMARY KEY constraint uniquely identifies each record in a database table.
Primary keys must contain unique values.
A primary key column cannot contain NULL values.
Each table should have a primary key, and each table can have only ONE primary key.
SQL PRIMARY KEY Constraint on CREATE TABLE
The following SQL creates a PRIMARY KEY on the "P_Id" column when the "Persons" table is
created:
MySQL:
CREATE TABLE Persons
(
P_Id int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City varchar(255),
PRIMARY KEY (P_Id)
)
 Foreign Key
MARUTI SUZUKI INDIA LIMITED
33
A FOREIGN KEY in one table points to a PRIMARY KEY in another table.
Let's illustrate the foreign key with an example. Look at the following two tables:
The "Persons" table:
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
The "Orders" table:
O_Id OrderNo P_Id
1 77895 3
2 44678 3
3 22456 2
4 24562 1
Note that the "P_Id" column in the "Orders" table points to the "P_Id" column in the "Persons" table.
The "P_Id" column in the "Persons" table is the PRIMARY KEY in the "Persons" table.
The "P_Id" column in the "Orders" table is a FOREIGN KEY in the "Orders" table.
The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables.
The FOREIGN KEY constraint also prevents that invalid data form being inserted into the foreign key
column, because it has to be one of the values contained in the table it points to.
SQL FOREIGN KEY Constraint on CREATE TABLE
The following SQL creates a FOREIGN KEY on the "P_Id" column when the "Orders" table is created:
MySQL:
CREATE TABLE Orders
(
O_Id int NOT NULL,
OrderNo int NOT NULL,
P_Id int,
PRIMARY KEY (O_Id),
FOREIGN KEY (P_Id) REFERENCES Persons(P_Id) )
To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple
columns, use the following SQL
MARUTI SUZUKI INDIA LIMITED
34
Joins
Join is a KEYWORD used to query data from different tables on the basis of some
relation between tables.
Joins are of following types:
 Inner Join
 Left Join
 Right Join
Inner join:
The INNER JOIN keyword return rows when there is at least one match in both
tables.
Syntax
SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name
The INNER JOIN keyword return rows when there is at least one match in both
tables. If there are rows in "Persons" that do not have matches in "Orders", those
rows will NOT be listed.
Left Join
The LEFT JOIN keyword returns all rows from the left table (table_name1), even if
there are no matches in the right table (table_name2).
Syntax
SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
PS: In some databases LEFT JOIN is called LEFT OUTER JOIN.
The LEFT JOIN keyword returns all the rows from the left table, even if there are no matches in
the right table.
Right Join
The RIGHT JOIN keyword returns all the rows from the right table (table_name2),
even if there are no matches in the left table (table_name1).
Syntax
SELECT column_name(s)
MARUTI SUZUKI INDIA LIMITED
35
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
PS: In some databases RIGHT JOIN is called RIGHT OUTER JOIN.
The RIGHT JOIN keyword returns all the rows from the right table , even if there are
no matches in the left table.
MARUTI SUZUKI INDIA LIMITED
36
3.3 DATABASE OF POLICY SCHEMAS
INTRODUCTION:
MSIL, form different policy for customers benefit in transacting the
commodity. The company frame various policies for different type of
customer such as for Maruti employee, or for vendors, or for dealers, or Govt.
employee, etc.
These policies maintain a lots of details related.
Such details are maintained in tables
We have a table “POLICY"
CURRENT_POLICY_NO number(10)
OLD_POLICY_TRXN_NO number(10)
POLICY_TRXN_NO number(10)
ISSUE_DATE date
RISK_INCEPTION_DATE date
RISK_EXPIRY_DATE date
POLICY_SELECTION varchar2(10)
SERVICE_TAX_AMOUNT number(10)
OUTLET_CODE number(10)
IS_EXPIRED number(10)
IS_TOTAL_DAMAGE number(10)
EXPIRED_BY number(10)
EXPIRED_DATE number(10)
IS_CANCELLED varchar2(10)
IS_PROOF_AVAILABLE varchar2(10)
CERTIFICATE varchar2(10)
UNDERTAKING varchar2(10)
UPDATED_BY varchar2(10)
UPDATED_DATE varchar2(10)
CREATED_BY varchar2(10)
CREATED_DATE varchar2(10)
BLOCKED_REMARKS varchar2(10)
IS_BLOCKED varchar2(10)
CANCELLED_REMARKS varchar2(10)
CANCELLED_BY varchar2(10)
CANCELLED_DATE varchar2(10)
EXTERNALACCINCLUDED varchar2(10)
INS_FEEDBACK_SUBMITTED varchar2(10)
INS_FEEDBACK_SUBMITTED_DATEvarchar2(10)
MARUTI SUZUKI INDIA LIMITED
37
Table “policy_vehicle” maintains the records of a vehicle which is
manufactured, sale, chassis no., engine detail, color type, etc
POLICY_TRXN_NO number(10)
CURRENT_POLICY_NO number(10)
ENGINE_NO number(10)
CHASSIS_NO number(10)
SUB_MODEL_NO number(10)
VEHICLE_REGN_NO number(10)
VEHICLE_REGN_DATE date
VEHICLE_TYPE varchar2(20)
SEATING_CAPACITY varchar2(20)
VEHICLE_EXSHOWROOM_PRICE varchar2(20)
VEHICLE_SALE_DATE date
YEAR_OF_MANUFACTURE varchar2(20)
BRANCH_NAME varchar2(20)
CREATED_BY varchar2(20)
CREATED_DATE date
UPDATED_BY varchar2(20)
UPDATED_DATE date
COLOR_TYPE varchar2(20)
SP_DISPATCH_DATE date
Table “Policy_client_Details” maintains the record of the client who is
purchasing a vehicle from Maruti.
POLICY_TRXN_NO number(10)
CURRENT_POLICY_NO number(10)
TITLE varchar2(20)
Name varchar2(20)
GENDER varchar2(20)
DOB date
ADDRESS varchar2(20)
CITY_ID varchar2(20)
PIN varchar2(20)
PHONE_NO number(10)
MOBILE number(10)
EMAIL_ID varchar2(20)
CREATED_BY varchar2(20)
CREATED_DATE date
CORPORATE_NAME varchar2(20)
ADDRESS varchar2(20)
MARUTI SUZUKI INDIA LIMITED
38
Table “City_ID”
CITY_ID varchar2(20),
STATE_ID varchar2(20),
NAME varchar2(20),
PRIVATE_CAR_ZONE varchar2(20),
COMM_TO6_CAR_ZONE varchar2(20),
COMM_ABOVE6_CAR_ZONE varchar2(20),
ZONE_ID varchar2(20),
FOR_CODE varchar2(20),
INS_OFFICE_ID varchar2(20),
REGION_ID varchar2(20),
CREATED_BY varchar2(20),
Table “OutletMaster”
OUTLET_CODE varchar2(20)
PARTY_CODE varchar2(20)
OUTLET_NAME varchar2(20)
TYPE varchar2(20)
ADDRESS varchar2(20)
PINCODE varchar2(20)
CITY_ID varchar2(20)
DISTRICT varchar2(20)
C_PERSON varchar2(20)
SIGNATORY varchar2(20)
PHONE number(10)
MOBILE number(10)
FAX number(10)
EMAIL varchar2(20)
CREATED_BY varchar2(20)
CREATED_DATE date
ASSIGN_TO_OUTLET varchar2(20)
MARUTI SUZUKI INDIA LIMITED
39
We have to create a table to show data from these above tables. These tables
are inter-related with some relation.
Table “Report-Detail”
REGION_ID varchar2(20)
CURRENT_POLICY_NOnumber(10)
ISSUE_DATE date
Outlet Name varchar2(20)
CUSTOMER_NAMEvarchar2(20)
Cust_city varchar2(20)
SUB_MODEL varchar2(20)
ENGINE_NO number(10)
CHASSIS_NO number(10)
In these tables columns has there own datatype. Datatypes are those functions
which defines the type of input to be stored by the user.
Different Datatypes are:
1. Varchar2() : it accepts alpha-numeric characters.
2. Date : it accepts only dates in specific style like DD/MM/YY (default)
3. Datetime : it accepts date & time in specific style like DD/MM/YY HH:MM:SS
4. Numbers() : it accepts only numbers.
We even have to take out the count:
POLICY COUNT DETAILS
POLICY_ISSUED
25190
POLICY_RECONCILED
22182
POLICY_INCEPTED
23968
POLICY_CANCELLED
1279
POLICY_VB64VERIFIED
19372
POLICY_CDADJUSTED
NULL
POLICY_BREAKINAPPROVED
1025
POLICY_BREAKINREJECTED
247
MARUTI SUZUKI INDIA LIMITED
40
SQL Coding:
CREATE TABLE policy
(
CURRENT_POLICY_NO number(10),
OLD_POLICY_TRXN_NO number(10),
POLICY_TRXN_NO number(10),
ISSUE_DATE date,
RISK_INCEPTION_DATE date,
RISK_EXPIRY_DATE date,
POLICY_SELECTION varchar2(10),
SERVICE_TAX_AMOUNT number(10),
OUTLET_CODE number(10),
IS_EXPIRED number(10),
IS_TOTAL_DAMAGE number(10),
EXPIRED_BY number(10),
EXPIRED_DATE number(10),
IS_CANCELLED varchar2(10),
IS_PROOF_AVAILABLE varchar2(10),
CERTIFICATE varchar2(10),
UNDERTAKING varchar2(10),
UPDATED_BY varchar2(10),
UPDATED_DATE varchar2(10),
CREATED_BY varchar2(10),
CREATED_DATE varchar2(10),
BLOCKED_REMARKS varchar2(10),
IS_BLOCKED varchar2(10)
CANCELLED_REMARKS varchar2(10),
CANCELLED_BY varchar2(10),
CANCELLED_DATE varchar2(10),
EXTERNALACCINCLUDED varchar2(10),
INS_FEEDBACK_SUBMITTED varchar2(10),
INS_FEEDBACK_SUBMITTED_DATE varchar2(10),
primary key (CURRENT_POLICY_NO)
)
CREATE TABLE policy_vehicle
(
POLICY_TRXN_NO number(10),
CURRENT_POLICY_NO number(10),
ENGINE_NO number(10),
CHASSIS_NO number(10),
SUB_MODEL_NO number(10),
VEHICLE_REGN_NO number(10),
VEHICLE_REGN_DATE date,
VEHICLE_TYPE varchar2(20),
SEATING_CAPACITY varchar2(20),
VEHICLE_EXSHOWROOM_PRICE varchar2(20),
VEHICLE_SALE_DATE date,
YEAR_OF_MANUFACTURE varchar2(20),
BRANCH_NAME varchar2(20),
CREATED_BY varchar2(20),
CREATED_DATE date,
MARUTI SUZUKI INDIA LIMITED
41
UPDATED_BY varchar2(20),
UPDATED_DATE date,
COLOR_TYPE varchar2(20),
SP_DISPATCH_DATE date,
primary key (CURRENT_POLICY_NO)
)
CREATE TABLE policy_client_detail1
(
POLICY_TRXN_NO number(10)
CURRENT_POLICY_NO number(10),
TITLE varchar2(20),
Name varchar2(20),
GENDER varchar2(20),
DOB date,
ADDRESS varchar2(20),
CITY_ID varchar2(20),
PIN varchar2(20),
PHONE_NO number(10),
MOBILE number(10),
EMAIL_ID varchar2(20),
CREATED_BY varchar2(20),
CREATED_DATE date,
CORPORATE_NAME varchar2(20),
ADDRESS varchar2(20),
primary key (CURRENT_POLICY_NO)
)
CREATE TABLE citymaster
(
CITY_ID varchar2(20),
STATE_ID varchar2(20),
NAME varchar2(20),
PRIVATE_CAR_ZONE varchar2(20),
COMM_TO6_CAR_ZONE varchar2(20),
COMM_ABOVE6_CAR_ZONE varchar2(20),
ZONE_ID varchar2(20),
FOR_CODE varchar2(20),
INS_OFFICE_ID varchar2(20),
REGION_ID varchar2(20),
CREATED_BY varchar2(20),
CREATED_DATE date
)
CREATE TABLE outletmaster
(
OUTLET_CODE varchar2(20),
PARTY_CODE varchar2(20),
OUTLET_NAME varchar2(20),
TYPE varchar2(20),
ADDRESS varchar2(20),
PINCODE varchar2(20),
CITY_ID varchar2(20),
DISTRICT varchar2(20),
C_PERSON varchar2(20),
MARUTI SUZUKI INDIA LIMITED
42
SIGNATORY varchar2(20),
PHONE number(10),
MOBILE number(10),
FAX number(10),
EMAIL varchar2(20),
CREATED_BY varchar2(20),
CREATED_DATE date,
ASSIGN_TO_OUTLET varchar2(20)
)
SELECT c.REGION_ID, p.CURRENT_POLICY_NO, p.ISSUE_DATE, o.Outlet_Name,
pcd.CUSTOMER_NAME, o.CITY_ID, pv.SUB_MODEL_NO, pv.ENGINE_NO, pv.CHASSIS_NO,
pv.Vehicle_Sale_Date
FROM policy1 p
LEFT JOIN policy_vehicle pv on p .CURRENT_POLICY_NO = pv.CURRENT_POLICY_NO
LEFT JOIN policy_client_detail1 pcd on p.CURRENT_POLICY_NO= pcd.CURRENT_POLICY_NO
LEFT JOIN outletmaster o on p.OUTLET_CODE = o.OUTLET_CODE
LEFT JOIN citymaster c on o.CITY_ID=c.CITY_I
SELECT count(*) FROM policy p WHERE p.ISSUE_DATE>='1-jan-2011' AND p.ISSUE_DATE<='21-jan-2011'
SELECT count(*) FROM policy_client_detail pcd WHERE pcd.CREATED_DATE>='1-jan-2011' AND
pcd.CREATED_DATE<='21-jan-2011'
SELECT count(*) FROM policy p WHERE p.RISK_INCEPTION_DATE>='1-jan-2011' AND
p.RISK_INCEPTION_DATE<='21-jan-2011'
SELECT count(*) FROM policy p WHERE p.CANCELLED_DATE>='1-jan-2011' AND
p.CANCELLED_DATE<='21-jan-2011'
MARUTI SUZUKI INDIA LIMITED
43
3.4 Stored Procedures
What is a Stored Procedure?
A stored procedure or in simple a proc is a named PL/SQL block which performs one
or more specific task. This is similar to a procedure in other programming languages. A
procedure has a header and a body. The header consists of the name of the procedure
and the parameters or variables passed to the procedure. The body consists or
declaration section, execution section and exception section similar to a general PL/SQL
Block. A procedure is similar to an anonymous PL/SQL Block but it is named for
repeated usage.
We can pass parameters to procedures in three ways.
1) IN-parameters
2) OUT-parameters
3) IN OUT-parameters
A procedure may or may not return any value.
General Syntax to create a procedure is:
CREATE [OR REPLACE] PROCEDURE proc_name [list of parameters]
IS
Declaration section
BEGIN
Execution section
EXCEPTION
Exception section
END;
IS - marks the beginning of the body of the procedure and is similar to DECLARE in
anonymous PL/SQL Blocks. The code between IS and BEGIN forms the Declaration
section.
The syntax within the brackets [ ] indicate they are optional. By using CREATE OR
REPLACE together the procedure is created if no other procedure with the same name
exists or the existing procedure is replaced with the current code.
The below example creates a procedure ‘employer_details’ which gives the details of the
employee.
1> CREATE OR REPLACE PROCEDURE employer_details
2> IS
3> CURSOR emp_cur IS
4> SELECT first_name, last_name, salary FROM emp_tbl;
5> emp_rec emp_cur%rowtype;
6> BEGIN
7> FOR emp_rec in sales_cur
8> LOOP
9> dbms_output.put_line(emp_cur.first_name || ' ' ||emp_cur.last_name
10> || ' ' ||emp_cur.salary);
11> END LOOP;
MARUTI SUZUKI INDIA LIMITED
44
12>END;
13> /
How to execute a Stored Procedure?
There are two ways to execute a procedure.
1) From the SQL prompt.
EXECUTE [or EXEC] procedure_name;
2) Within another procedure – simply use the procedure name.
procedure_name;
NOTE: In the examples given above, we are using backward slash ‘/’ at the end of the
program. This indicates the oracle engine that the PL/SQL program has ended and it can
begin processing the statements.
MARUTI SUZUKI INDIA LIMITED
45
3.5 Trigger
A trigger is a pl/sql block structure which is fired when a DML statements like Insert,
Delete, Update is executed on a database table. A trigger is triggered automatically when
an associated DML statement is executed.
Syntax of Triggers
The Syntax for creating a trigger is:
CREATE [OR REPLACE ] TRIGGER trigger_name
{BEFORE | AFTER | INSTEAD OF }
{INSERT [OR] | UPDATE [OR] | DELETE}
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n]
[FOR EACH ROW]
WHEN (condition)
BEGIN
--- sql statements
END;
 CREATE [OR REPLACE ] TRIGGER trigger_name - This clause creates a trigger with the given name or
overwrites an existing trigger with the same name.
 {BEFORE | AFTER | INSTEAD OF } - This clause indicates at what time should the trigger get fired. i.e for
example: before or after updating a table. INSTEAD OF is used to create a trigger on a view. before and
after cannot be used to create a trigger on a view.
 {INSERT [OR] | UPDATE [OR] | DELETE} - This clause determines the triggering event. More than one
triggering events can be used togetherseparated by OR keyword. The trigger gets fired at all the specified
triggering event.
 [OF col_name] - This clause is used with update triggers. This clause is used when you want to trigger an
event only when a specific column is updated.
 CREATE [OR REPLACE ] TRIGGER trigger_name - This clause creates a trigger with the given name or
overwrites an existing trigger with the same name.
 [ON table_name] - This clause identifies the name of the table or view to which the trigger is associated.
 [REFERENCING OLD AS o NEW AS n] - This clause is used to reference the old and new values of the data
being changed.By default, you reference the values as :old.column_name or :new.column_name. The
reference names can also be changed from old (or new) to any otheruser-defined name. You cannot
reference old values when inserting a record, or new values when deleting a record, because they do not
exist.
 [FOR EACH ROW] - This clause is used to determine whether a trigger must fire when each row gets
affected ( i.e. a Row Level Trigger) or just once when the entire sql statement is executed(i.e.statement level
Trigger).
 WHEN (condition) -This clause is valid only for row level triggers. The trigger is fired only for rows that
satisfy the condition specified.
For Example: The price of a product changes constantly. It is important to maintain the
history of the prices of the products.
MARUTI SUZUKI INDIA LIMITED
46
We can create a trigger to update the 'product_price_history' table when the price of the
product is updated in the 'product' table.
1) Create the 'product' table and 'product_price_history' table
CREATE TABLE product_price_history
(product_id number(5),
product_name varchar2(32),
supplier_name varchar2(32),
unit_price number(7,2) );
CREATE TABLE product
(product_id number(5),
product_name varchar2(32),
supplier_name varchar2(32),
unit_price number(7,2) );
2) Create the price_history_trigger and execute it.
CREATE or REPLACE TRIGGER price_history_trigger
BEFORE UPDATE OF unit_price
ON product
FOR EACH ROW
BEGIN
INSERT INTO product_price_history
VALUES
(:old.product_id,
:old.product_name,
:old.supplier_name,
:old.unit_price);
END;
/
3) Lets update the price of a product.
UPDATE PRODUCT SET unit_price = 800 WHERE product_id = 100
Once the above update query is executed, the trigger fires and updates the
'product_price_history' table.
4)If you ROLLBACK the transaction before committing to the database, the data inserted
to the table is also rolled back.
Types of PL/SQL Triggers
There are two types of triggers based on the which level it is triggered.
1) Row level trigger - An event is triggered for each row upated, inserted or deleted.
2) Statement level trigger - An event is triggered for each sql statement executed.
PL/SQL Trigger Execution Hierarchy
The following hierarchy is followed when a trigger is fired.
1) BEFORE statement trigger fires first.
2) Next BEFORE row level trigger fires, once for each row affected.
3) Then AFTER row level trigger fires once for each affected row. This events will
alternates between BEFORE and AFTER row level triggers.
4) Finally the AFTER statement level trigger fires.
MARUTI SUZUKI INDIA LIMITED
47
For Example: Let's create a table 'product_check' which we can use to store messages
when triggers are fired.
CREATE TABLE product
(Message varchar2(50),
Current_Date number(32)
);
Let's create a BEFORE and AFTER statement and row level triggers for the product
table.
1) BEFORE UPDATE, Statement Level: This trigger will insert a record into the table
'product_check' before a sql update statement is executed, at the statement level.
CREATE or REPLACE TRIGGER Before_Update_Stat_product
BEFORE
UPDATE ON product
Begin
INSERT INTO product_check
Values('Before update, statement level',sysdate);
END;
/
2) BEFORE UPDATE, Row Level: This trigger will insert a record into the table
'product_check' before each row is updated.
CREATE or REPLACE TRIGGER Before_Upddate_Row_product
BEFORE
UPDATE ON product
FOR EACH ROW
BEGIN
INSERT INTO product_check
Values('Before update row level',sysdate);
END;
/
3) AFTER UPDATE, Statement Level: This trigger will insert a record into the table
'product_check' after a sql update statement is executed, at the statement level.
CREATE or REPLACE TRIGGER After_Update_Stat_product
AFTER
UPDATE ON product
BEGIN
INSERT INTO product_check
Values('After update, statement level', sysdate);
End;
/
4) AFTER UPDATE, Row Level: This trigger will insert a record into the table
'product_check' after each row is updated.
CREATE or REPLACE TRIGGER After_Update_Row_product
AFTER
insert On product
FOR EACH ROW
BEGIN
INSERT INTO product_check
Values('After update, Row level',sysdate);
END;
MARUTI SUZUKI INDIA LIMITED
48
/
Now lets execute a update statement on table product.
UPDATE PRODUCT SET unit_price = 800
WHERE product_id in (100,101);
Lets check the data in 'product_check' table to see the order in which the trigger is fired.
SELECT * FROM product_check;
MARUTI SUZUKI INDIA LIMITED
49
3.6 CYCLIC CASCADING in a TRIGGER
This is an undesirable situation where more than one trigger enter into an infinite loop.
while creating a trigger we should ensure the such a situtation does not exist.
The below example shows how Trigger's can enter into cyclic cascading.
Let's consider we have two tables 'abc' and 'xyz'. Two triggers are created.
1) The INSERT Trigger, triggerA on table 'abc' issues an UPDATE on table 'xyz'.
2) The UPDATE Trigger, triggerB on table 'xyz' issues an INSERT on table 'abc'.
In such a situation, when there is a row inserted in table 'abc', triggerA fires and will
update table 'xyz'.
When the table 'xyz' is updated, triggerB fires and will insert a row in table 'abc'.
This cyclic situation continues and will enter into a infinite loop, which will crash the
database.
MARUTI SUZUKI INDIA LIMITED
50
CONCLUSION
The project aimed at maintenance of policy details. The company ensures
new policy for the retailers as well as for customer. Record of these policies
are maintained in the database. Functionality of these policies is to provide
extra benefits to customer and thus taking care of their satisfaction.
The purpose of this document was to create an application that would allow
to fetch the data from different tables in a database and provide it to the user
as required. The objective was to ensure the availability of the procedures
which reduces the execution time, thus are stored as pre-compiled functions.
This target has been fruitfully achieved and successfully implemented.
The hands-on experience that I attained at MSIL not only enhanced my
technical skills, but also gave me an enriching experience of the company
environment. I had the pleasing opportunity to interact with the elite staff
and the other employees of the company, and to learn the inner working of
the organization.
I had learnt how one should present oneself, how one must behave with their
seniors and colleagues; also that there is no greater success policy than hard
work, and that punctuality is must. It was truly a wonderful experience to be
able to work with the intellectual class.
In concise, it was not only an industrial training, but an experience of a
lifetime…
Merits Of the Project
 Ensuring in time & adequate procurement.
 Analyzing the total count of issued vehicle.
 Helping in maintaining records.
LimitationsOf the Project
 New data cannot be inserted in the system. Only the existing data in
the in-built database can be implemented.
MARUTI SUZUKI INDIA LIMITED
51
BIBLIOGRAPHY
 SQL, PL/SQL: The Programming Language Of Oracle, 2nd Revised
Edition;
Ivan Bayross; BPB Publications; 1999.
 Oracle developer 2000 by Ivan Bayross.
 Database System
S. K. Singh.
 www.google.com
 www.marutisuzuki.com
 Maruti manuals

More Related Content

What's hot

Summer internship project report
Summer internship project reportSummer internship project report
Summer internship project reportManish Singh
 
A project report on yamaha superbikes for yamaha motor india pvt.ltd.
A project report on yamaha superbikes for yamaha motor india pvt.ltd.A project report on yamaha superbikes for yamaha motor india pvt.ltd.
A project report on yamaha superbikes for yamaha motor india pvt.ltd.Projects Kart
 
Bajaj project final
Bajaj project finalBajaj project final
Bajaj project finalShiv Kumar
 
Management research project Maruti Suzuki
Management research project Maruti SuzukiManagement research project Maruti Suzuki
Management research project Maruti SuzukiPramod Patil
 
Mahindra & mahindra project repot by (makshud khan)
Mahindra & mahindra project repot  by (makshud khan)Mahindra & mahindra project repot  by (makshud khan)
Mahindra & mahindra project repot by (makshud khan)Makshud Khan
 
A project report on Competitor analysis of_tata_motors
A project report on Competitor analysis of_tata_motorsA project report on Competitor analysis of_tata_motors
A project report on Competitor analysis of_tata_motorsMba projects free
 
SIP REPORT OF CRM ON MARUTI SUZUKI
SIP REPORT OF CRM ON MARUTI SUZUKI SIP REPORT OF CRM ON MARUTI SUZUKI
SIP REPORT OF CRM ON MARUTI SUZUKI Santosh Oza
 
Mahindra and mahindra ltd
Mahindra and mahindra ltdMahindra and mahindra ltd
Mahindra and mahindra ltdPrateek Gahlot
 
maruti suzuki overview
maruti suzuki overviewmaruti suzuki overview
maruti suzuki overviewNaga G
 
Tata Motors Business model A-Z
Tata Motors Business model A-ZTata Motors Business model A-Z
Tata Motors Business model A-ZAshish Nainan
 
maruti suzuki power point presentation
maruti suzuki power point presentationmaruti suzuki power point presentation
maruti suzuki power point presentationRakesh Kumar
 
Internship Report At Wheels India Ltd
Internship Report At Wheels India LtdInternship Report At Wheels India Ltd
Internship Report At Wheels India LtdPushkar Chaturvedi
 
Maruti suzuki ppt sobhan
Maruti suzuki ppt  sobhanMaruti suzuki ppt  sobhan
Maruti suzuki ppt sobhanDeepak19nov
 
A study on consumer buying behaviour at the time to purchase hero honda bike
A  study  on consumer buying behaviour at the time to purchase hero honda bikeA  study  on consumer buying behaviour at the time to purchase hero honda bike
A study on consumer buying behaviour at the time to purchase hero honda bikeProjects Kart
 
Company analysis of tata motors
Company analysis  of  tata motorsCompany analysis  of  tata motors
Company analysis of tata motorsKumar Saurabh
 
Final project on Yamaha Motors
Final project on Yamaha MotorsFinal project on Yamaha Motors
Final project on Yamaha MotorsRahul Jain
 

What's hot (20)

Summer internship project report
Summer internship project reportSummer internship project report
Summer internship project report
 
A project report on yamaha superbikes for yamaha motor india pvt.ltd.
A project report on yamaha superbikes for yamaha motor india pvt.ltd.A project report on yamaha superbikes for yamaha motor india pvt.ltd.
A project report on yamaha superbikes for yamaha motor india pvt.ltd.
 
Bajaj project final
Bajaj project finalBajaj project final
Bajaj project final
 
Management research project Maruti Suzuki
Management research project Maruti SuzukiManagement research project Maruti Suzuki
Management research project Maruti Suzuki
 
Maruti Strategy
Maruti StrategyMaruti Strategy
Maruti Strategy
 
Mahindra & mahindra project repot by (makshud khan)
Mahindra & mahindra project repot  by (makshud khan)Mahindra & mahindra project repot  by (makshud khan)
Mahindra & mahindra project repot by (makshud khan)
 
Ultra tech
Ultra techUltra tech
Ultra tech
 
yahama- a project report
yahama- a project reportyahama- a project report
yahama- a project report
 
A project report on Competitor analysis of_tata_motors
A project report on Competitor analysis of_tata_motorsA project report on Competitor analysis of_tata_motors
A project report on Competitor analysis of_tata_motors
 
SIP REPORT OF CRM ON MARUTI SUZUKI
SIP REPORT OF CRM ON MARUTI SUZUKI SIP REPORT OF CRM ON MARUTI SUZUKI
SIP REPORT OF CRM ON MARUTI SUZUKI
 
Mahindra and mahindra ltd
Mahindra and mahindra ltdMahindra and mahindra ltd
Mahindra and mahindra ltd
 
maruti suzuki overview
maruti suzuki overviewmaruti suzuki overview
maruti suzuki overview
 
Tata Motors Business model A-Z
Tata Motors Business model A-ZTata Motors Business model A-Z
Tata Motors Business model A-Z
 
maruti suzuki power point presentation
maruti suzuki power point presentationmaruti suzuki power point presentation
maruti suzuki power point presentation
 
Internship Report At Wheels India Ltd
Internship Report At Wheels India LtdInternship Report At Wheels India Ltd
Internship Report At Wheels India Ltd
 
Project Report on AMUL
Project Report on AMULProject Report on AMUL
Project Report on AMUL
 
Maruti suzuki ppt sobhan
Maruti suzuki ppt  sobhanMaruti suzuki ppt  sobhan
Maruti suzuki ppt sobhan
 
A study on consumer buying behaviour at the time to purchase hero honda bike
A  study  on consumer buying behaviour at the time to purchase hero honda bikeA  study  on consumer buying behaviour at the time to purchase hero honda bike
A study on consumer buying behaviour at the time to purchase hero honda bike
 
Company analysis of tata motors
Company analysis  of  tata motorsCompany analysis  of  tata motors
Company analysis of tata motors
 
Final project on Yamaha Motors
Final project on Yamaha MotorsFinal project on Yamaha Motors
Final project on Yamaha Motors
 

Viewers also liked

analysis of financial statements toyota
analysis of financial statements toyotaanalysis of financial statements toyota
analysis of financial statements toyotafizza tanvir
 
Country Analysis India With Special Reference To The Automobile Sector
Country Analysis  India With Special Reference To The Automobile SectorCountry Analysis  India With Special Reference To The Automobile Sector
Country Analysis India With Special Reference To The Automobile Sectoragarwalkhagesh
 
Presentazione Toyota (Definitiva, Post Revisione)
Presentazione Toyota (Definitiva, Post Revisione)Presentazione Toyota (Definitiva, Post Revisione)
Presentazione Toyota (Definitiva, Post Revisione)Economia dell'Innovazione
 
Maruti suzuki ppt Mithun
Maruti suzuki ppt Mithun Maruti suzuki ppt Mithun
Maruti suzuki ppt Mithun satish kumar
 
Maruti Suzuki Labour Unrest at Manesar Plant
Maruti Suzuki Labour Unrest at Manesar PlantMaruti Suzuki Labour Unrest at Manesar Plant
Maruti Suzuki Labour Unrest at Manesar PlantShubham Mongia
 
Financial analysis of the Toyota Company
Financial analysis of the Toyota CompanyFinancial analysis of the Toyota Company
Financial analysis of the Toyota CompanyLevi Haegebaert
 
Toyota: Analysis of Vision Statement, Corporate Level Strategies & SWOT
Toyota: Analysis of Vision Statement, Corporate Level Strategies & SWOTToyota: Analysis of Vision Statement, Corporate Level Strategies & SWOT
Toyota: Analysis of Vision Statement, Corporate Level Strategies & SWOTRohan Negi
 
Maruti suzuki csr activity
Maruti suzuki csr activityMaruti suzuki csr activity
Maruti suzuki csr activityTushar Kharate
 
Financial ratio analysis for honda motor company
Financial ratio analysis for honda motor companyFinancial ratio analysis for honda motor company
Financial ratio analysis for honda motor companyHITESH BHARTI
 
Toyota and csr ppt
Toyota and csr pptToyota and csr ppt
Toyota and csr pptAqsa Awan
 
Management Information Systems in Maruti Suzuki
Management Information Systems in Maruti SuzukiManagement Information Systems in Maruti Suzuki
Management Information Systems in Maruti SuzukiMohammad Mohtashim
 

Viewers also liked (20)

analysis of financial statements toyota
analysis of financial statements toyotaanalysis of financial statements toyota
analysis of financial statements toyota
 
Country Analysis India With Special Reference To The Automobile Sector
Country Analysis  India With Special Reference To The Automobile SectorCountry Analysis  India With Special Reference To The Automobile Sector
Country Analysis India With Special Reference To The Automobile Sector
 
Presentazione Toyota (Definitiva, Post Revisione)
Presentazione Toyota (Definitiva, Post Revisione)Presentazione Toyota (Definitiva, Post Revisione)
Presentazione Toyota (Definitiva, Post Revisione)
 
Caso honda
Caso hondaCaso honda
Caso honda
 
Maruti suzuki ppt Mithun
Maruti suzuki ppt Mithun Maruti suzuki ppt Mithun
Maruti suzuki ppt Mithun
 
Caso honda
Caso hondaCaso honda
Caso honda
 
Maruti Suzuki Labour Unrest at Manesar Plant
Maruti Suzuki Labour Unrest at Manesar PlantMaruti Suzuki Labour Unrest at Manesar Plant
Maruti Suzuki Labour Unrest at Manesar Plant
 
Toyota
Toyota Toyota
Toyota
 
Honda analysis 2011 - 2012
Honda analysis 2011 - 2012Honda analysis 2011 - 2012
Honda analysis 2011 - 2012
 
Financial analysis of the Toyota Company
Financial analysis of the Toyota CompanyFinancial analysis of the Toyota Company
Financial analysis of the Toyota Company
 
Maruti suzuki
Maruti suzukiMaruti suzuki
Maruti suzuki
 
Toyota: Analysis of Vision Statement, Corporate Level Strategies & SWOT
Toyota: Analysis of Vision Statement, Corporate Level Strategies & SWOTToyota: Analysis of Vision Statement, Corporate Level Strategies & SWOT
Toyota: Analysis of Vision Statement, Corporate Level Strategies & SWOT
 
Maruti suzuki csr activity
Maruti suzuki csr activityMaruti suzuki csr activity
Maruti suzuki csr activity
 
Financial ratio analysis for honda motor company
Financial ratio analysis for honda motor companyFinancial ratio analysis for honda motor company
Financial ratio analysis for honda motor company
 
Toyota and csr ppt
Toyota and csr pptToyota and csr ppt
Toyota and csr ppt
 
Fiscal Policy
Fiscal PolicyFiscal Policy
Fiscal Policy
 
Hrm maruti suzuki
Hrm maruti suzukiHrm maruti suzuki
Hrm maruti suzuki
 
Automobile Sector
Automobile SectorAutomobile Sector
Automobile Sector
 
Management Information Systems in Maruti Suzuki
Management Information Systems in Maruti SuzukiManagement Information Systems in Maruti Suzuki
Management Information Systems in Maruti Suzuki
 
Cars ppt.
Cars ppt.Cars ppt.
Cars ppt.
 

Similar to Maruti project

maruti summer training 2012
maruti summer training 2012maruti summer training 2012
maruti summer training 2012Kalyan Potukuchi
 
401207027_Tata Motors
401207027_Tata Motors401207027_Tata Motors
401207027_Tata MotorsSushant Gupta
 
45312185 maruti-suzuki-project-report
45312185 maruti-suzuki-project-report45312185 maruti-suzuki-project-report
45312185 maruti-suzuki-project-reportAADARSH ABHISHEK
 
project-report-on-tata-motors.pdf
project-report-on-tata-motors.pdfproject-report-on-tata-motors.pdf
project-report-on-tata-motors.pdfVivin13
 
Maruti suzuki . true value 2015
Maruti suzuki . true value 2015Maruti suzuki . true value 2015
Maruti suzuki . true value 2015Tanvir Singh
 
Fdocuments.in maruti suzuki-hr-practices
Fdocuments.in maruti suzuki-hr-practicesFdocuments.in maruti suzuki-hr-practices
Fdocuments.in maruti suzuki-hr-practicesArvindsumitlakra
 
Sustainability Report of Maruti Suzuki
Sustainability Report of Maruti Suzuki Sustainability Report of Maruti Suzuki
Sustainability Report of Maruti Suzuki DEVASHISH KASHYAP
 
Service quality and consumer satisfaction for maruti service center
Service quality and consumer satisfaction for maruti service centerService quality and consumer satisfaction for maruti service center
Service quality and consumer satisfaction for maruti service centergauravrao01
 
Nexa project priyesh gaurav
Nexa project priyesh gauravNexa project priyesh gaurav
Nexa project priyesh gauravPriyeshGaurav
 
Marketing strategy suzuki
Marketing strategy suzukiMarketing strategy suzuki
Marketing strategy suzukiAmit Pasi
 
Summer training report
Summer training reportSummer training report
Summer training reportachuakshaya2
 
A PROJECT REPORT ON “THE LEADERSHIP STORY OF MARUTI SUZUKI”
A PROJECT REPORT ON “THE LEADERSHIP STORY OF  MARUTI SUZUKI”A PROJECT REPORT ON “THE LEADERSHIP STORY OF  MARUTI SUZUKI”
A PROJECT REPORT ON “THE LEADERSHIP STORY OF MARUTI SUZUKI”jitendrasangle
 
127597835 35034034-maruti-suzuki-swift-project
127597835 35034034-maruti-suzuki-swift-project127597835 35034034-maruti-suzuki-swift-project
127597835 35034034-maruti-suzuki-swift-projectPrashant Sethi Jsr
 

Similar to Maruti project (20)

Employee benefits
Employee benefitsEmployee benefits
Employee benefits
 
maruti summer training 2012
maruti summer training 2012maruti summer training 2012
maruti summer training 2012
 
401207027_Tata Motors
401207027_Tata Motors401207027_Tata Motors
401207027_Tata Motors
 
Maruti Suzuki ppt
Maruti Suzuki pptMaruti Suzuki ppt
Maruti Suzuki ppt
 
45312185 maruti-suzuki-project-report
45312185 maruti-suzuki-project-report45312185 maruti-suzuki-project-report
45312185 maruti-suzuki-project-report
 
project-report-on-tata-motors.pdf
project-report-on-tata-motors.pdfproject-report-on-tata-motors.pdf
project-report-on-tata-motors.pdf
 
Maruti suzuki . true value 2015
Maruti suzuki . true value 2015Maruti suzuki . true value 2015
Maruti suzuki . true value 2015
 
Fdocuments.in maruti suzuki-hr-practices
Fdocuments.in maruti suzuki-hr-practicesFdocuments.in maruti suzuki-hr-practices
Fdocuments.in maruti suzuki-hr-practices
 
Sustainability Report of Maruti Suzuki
Sustainability Report of Maruti Suzuki Sustainability Report of Maruti Suzuki
Sustainability Report of Maruti Suzuki
 
Service quality and consumer satisfaction for maruti service center
Service quality and consumer satisfaction for maruti service centerService quality and consumer satisfaction for maruti service center
Service quality and consumer satisfaction for maruti service center
 
Report
ReportReport
Report
 
T & d at mul
T & d at mulT & d at mul
T & d at mul
 
Nexa project priyesh gaurav
Nexa project priyesh gauravNexa project priyesh gaurav
Nexa project priyesh gaurav
 
Marketing strategy suzuki
Marketing strategy suzukiMarketing strategy suzuki
Marketing strategy suzuki
 
Summer training report
Summer training reportSummer training report
Summer training report
 
ASYRAF
ASYRAFASYRAF
ASYRAF
 
Utthana banner skill development
Utthana banner skill developmentUtthana banner skill development
Utthana banner skill development
 
OEE Improvement
OEE ImprovementOEE Improvement
OEE Improvement
 
A PROJECT REPORT ON “THE LEADERSHIP STORY OF MARUTI SUZUKI”
A PROJECT REPORT ON “THE LEADERSHIP STORY OF  MARUTI SUZUKI”A PROJECT REPORT ON “THE LEADERSHIP STORY OF  MARUTI SUZUKI”
A PROJECT REPORT ON “THE LEADERSHIP STORY OF MARUTI SUZUKI”
 
127597835 35034034-maruti-suzuki-swift-project
127597835 35034034-maruti-suzuki-swift-project127597835 35034034-maruti-suzuki-swift-project
127597835 35034034-maruti-suzuki-swift-project
 

Maruti project

  • 1. ] PROJECT REPORT ON “database management of policy schema” AT Maruti Suzuki India Limited Gurgaon (Haryana) In Partial Fulfillment for the Award of the degree of BACHELOR OF TECHNOLOGY (Session 2011) Submitted By: Under the Guidance of: Nimish Nagpal Mr. Sachin Aggarwal B. Tech Project Mentor Roll No: C-2615 Maruti Suzuki India Ltd
  • 2. MARUTI SUZUKI INDIA LIMITED 1 PREFACE Software has become the key element in the evolution of computer based systems and products. Over the past four decades, software has evolved from the specialized problem solving and information analysis tool to an industry itself. The software development process involves the scales and experience of the people involved. The six week period after fourth semester of B-Tech is a training period as a part of curriculum; this provides valuable practical experience to the students and an individual treasure of experience, and offers an exposure to the real time management in an organization. It is the period during which the student is introduced and familiarized to the industrial environment. With the advancement in computer technology and increased automation, the software industry has become all the more important. The introduction of computers and electronics in the field of processing has made it essential that the input be much more accurate and controllers much faster in response. The state of art used in all the process-controlled industry spares us from tension of managing the fast process manually, thus ensuring improved operating efficiency and full protection. Industrial training is the major part of theoretical studies as it covers all that remains uncovered in the classroom i.e. without it, the studies remains ineffective and incomplete. The objective of training is to raise the performance of the studies in one or more of its aspects. This may be achieved by providing new knowledge and information relevant to the project, by teaching new trends by imbuing an individual with new attitude, motives, co-ordinates, co-operation and other personality developing characteristics. Often these technologies are utilized with segments of the work force regardless of the existing performance level, to operate efficiently. Since gaining theoretical knowledge is just not sufficient for sure success in life, especially in an ever growing industry like this, practical training plays an important role in building the future of an individual. During my training period, I had the opportunity to gain the practical experience at MARUTI SUZUKI INDIA LIMITED, GURGAON. I seek this instance in a very satisfactory manner & believe that it will be very beneficial for me.
  • 3. MARUTI SUZUKI INDIA LIMITED 2 CANDIDATE’S DECLARATION I hereby declare that the work that is presented by me for Maruti Suzuki India Ltd. in partial fulfillment of the requirements for the award of the degree of B-Tech. in Information Technology, submitted to Gurgaon Institute of Technology & Management , Gurgaon (Haryana), is an authentic record of work carried out during the period June, 2011 to July, 2011 at MSIL, Gurgaon. No part of this report has been submitted to any other university or institution for any other degree or reward. Nimish Nagpal B-Tech Univ. Roll No: 09-IT-544 Computer Science & Engineering Gurgaon Institute of Technology & Management, Gurgaon (Haryana),
  • 4. MARUTI SUZUKI INDIA LIMITED 3 CERTIFICATE This is to certify that Mr. Nimish Nagpal S/O Sh. Jawarhar Lal Nagpal student of MCA has undergone Practical internship training at Maruti Suzuki India Limited (MSIL) under my supervision. He has worked on “MIN Schema” during his training. Mr. Sachin Aggarwal (Project Manager)
  • 5. MARUTI SUZUKI INDIA LIMITED 4 ACKNOWLEDGMENT Industrial training is an indispensable part of B-Tech curriculum. It provides the students with an opportunity to gain experience on the practical applications of their knowledge. My training at MARUTI SUZUKI INDIA LTD., GURGAON has been very fruitful. I am sure that the hands on experience I have gained here will go a long way towards making me a competent engineer. I would like to convey my sincere gratitude to Mr. Gautam (Manager, IPS), Mr. Sachin Aggarwal (my mentor), my project guide who provided me with timely and proper guidance whenever required. This provided me experience in not only the technical and practical aspects of industry but also in human relations, team work and provided great insights into the actual working of an industry. Without their efforts, this training would not have been such a great learning experience as it has been. I take this opportunity to also thank all the staff of Maruti Suzuki India Ltd. who offered unconditional support and encouragement throughout the course of my training. I hereby also declare that the contents in this report are true to the best of my knowledge. NIMISH NAGPAL (Trainee)
  • 6. MARUTI SUZUKI INDIA LIMITED 5 Table of Contents 1. Company Profile 1.1 Background of the Indian Auto Industry 1.2 Background of SMC 1.3 Suzuki & Maruti World-class Manufacturing Facilities at Manesar 1.4 Introduction to Maruti Suzuki India Limited 1.5 The hierarchy diagram of MSIL 1.6 IT Division 2. Training 2.1 Introduction 2.2 Classroom Training 3. Database of Policy_Schema 3.1 Type of Architecture 3.1.1 Introduction 3.1.2 Client-Server / N-Tier System 3.2 SQL Editor- PL/SQL Developer 3.2.1 Starting in PL/SQL Developer: 3.2.2Creating Table 3.2.3Inserting Data 3.2.4Updating Data 3.2.5Grouping Data 3.2.6 Deleting Data 3.2.7Ordering Data 3.2.8Union 3.2.9Creating Indexes 3.2.10 Table Aliases 3.2.11Auto Increment 3.2.12Constraint  Primary Key  Foreign Key 3.3 DATABASE OF POLICY SCHEMAS 3.3.1 Introduction 3.3.2 SQL coding 3.4 Stored Procedures
  • 7. MARUTI SUZUKI INDIA LIMITED 6 3.5 Triggers 3.6. CYCLIC CASCADING in a TRIGGER Conclusion References
  • 8. MARUTI SUZUKI INDIA LIMITED 7 Chapter1 ORGANISATIONAL PROFILE 1.1 Background of the Indian Auto Industry 1.2 Background of SMC 1.3 Suzuki & Maruti World-class Manufacturing Facilities at Maneser 1.4 Introduction to Maruti Suzuki India Limited 1.5 The hierarchy diagram of MSIL 1.6 The IT Division
  • 9. MARUTI SUZUKI INDIA LIMITED 8 Introduction to MSIL, Gurgaon Maruti Udyog Ltd., an automobile industry was established in 1982. It was a joint venture between Government of India (74%) and Suzuki Motor Corporation (26%). The company came to India with two objectives: first to make a small, fuel efficient and environment friendly car. That’s how Maruti 800 was the first car to be launched by the company. After that, SMC collaborated with MUL in 2001 and today, it is known as Maruti Suzuki India Ltd (MSIL).Therefore, Maruti Suzuki Today is: • Suzuki’s largest manufacturing facility outside Japan. • Maruti’s contribution in Suzuki group – Volumes ~ 30% – Profit ~ 34% • Suzuki Board member, one of the top 6 in the group is the MD & CEO of Maruti Suzuki • First in Customer Satisfaction – For eleven times in a row (JD Power, 2000-2011). • MSIL, the country’s largest car manufacturer rolled out its 1Crore (ten million) car in March, 2011. First car manufacturer in India to achieve the landmark.
  • 10. MARUTI SUZUKI INDIA LIMITED 9 Company Profile “Stimulate the value chain for business excellence by providing innovative information systems using appropriate IT” 1.1 BACKGROUND OF THE INDIAN AUTO INDUSTRY Although the Indian car industry was established in the late forties, there was little growth or technical progress, as passenger cars were given very low priority in the scheme of Centralized Economic Planning. In the 1980s, the car industry was undergoing technological stagnation and was characterized by low production volumes, high cost and low productivity. The consumer had very little choice and the market was selling just around 30,000 cars per year. There was a clear need to provide a cost effective, reliable and quality car to the customers. Maruti Udyog Limited was incorporated in such a scenario as a fully owned Government Company on February 24, 1981 with a resolve to bring about expansion and technological modernization, of the automobile sector. Thus MUL, when started was entrusted with the task of achieving the following policy objectives:  Modernization of Indian Automobile Industry.  Production of Vehicles in large volumes, which was necessary for economic growth.  Production of Fuel-efficient vehicles to conserve scarce resources.  Choice of product and collaborator. To achieve the above objectives, one of the foremost tasks before Maruti Udyog Limited was to determine the most suitable product mix and to select the most suitable foreign partner who would be willing to accept MUL’s
  • 11. MARUTI SUZUKI INDIA LIMITED 10 requirements in terms of product mix, technology transfer, and equality participation and had the required technological expertise and experience in producing high quality, reliable and fuel efficient vehicles. After extensive discussion with several major European and Japanese car manufacturers, MUL chose Suzuki Motor Corporation (SMC) that further increased its equity holding to 50% in the year 1992, converting Maruti Udyog Ltd., into a Non-Government Company with a total Equity base of Rs. 1322.92 million. 1.2 BACKGROUNDOF SMC SUZUKI was founded in 1909 as Suzuki Loom Manufacturing Company. It started manufacturing motorcycles in 1952 and has become a world leader in the manufacture of two-wheelers .SUZUKI started producing cars from 1955.Today it is Japan’s largest manufacturers of small , fuel-efficient cars. At present the company’s name is SUZUKI MOTOR CORPORATION. 1.3 SUZUKI AND MARUTI’S WORLD-CLASS MANUFACTURING FACILITIES AT MANESAR On February 06,2007 Mr. Bhupinder Singh Huda, Chief Minister of Haryana, inaugurated three world-class manufacturing facilities set up by SMC and Maruti Udyog Limited. The facilities inaugurated were as follows:  MUL’s fourth car Assembly plant.  A diesel engine and transmission plant, set up under a joint venture of SMC and MUL called Suzuki Power train India Limited (SPIL)  SMC’s two-wheeler plant in Gurgaon, Suzuki Motorcycle India Private Limited (SMIPL). 1.4 INTRODUCTION TO MARUTI SUZUKI INDIA LIMITED  A License and a Joint Venture Agreement was signed with Suzuki Motor Company of Japan, in OCT. 1982  Market leader with over 54% Share in Domestic Car Market Exporting cars to over 70 countries around the world including most advance Western European Markets.  Maruti has revolutionized the Indian Automobile and Component Industry and has set standards in quality of products and service. MARUTI INSTALLED CAPACITY
  • 12. MARUTI SUZUKI INDIA LIMITED 11  PLANT 1 200,000 units  PLANT 2 150,000 units  PLANT 3 150,000 units  PLANT 4 100,000 units COMPANY MISSION  A leader in the Indian Automobile Industry.  Creating Customer Delight and Shareholders wealth.  A pride of India! LEADERSHIP  By Market share and brand equity  By operational practices  By people strategy CUSTOMER DELIGHT  Values for money  Quality  Service SHARE HOLDERS WEALTH  High Profitability & Image A PRIDE OF INDIA  As a corporate citizen  Products  People  Practices  Customers VALUES  Customer Obsession  Fast, Flexible, First Mover  Innovation and creativity  Networking and partnership  Openness and learning
  • 13. MARUTI SUZUKI INDIA LIMITED 12 QUALITY POLICY To increase consumer satisfaction through continuous improvement of products and services, this is achieved by following PDCA functions and levels of Maruti Organizations. Quality Policy “CONSUMER SATISFACTION THROUGH QUALITY OF OUR PRODUCTS AND SERVICES ACHIEVED BY CONSISTENT ADHERENCE TO PROCEDURES AND SYSTEMS.” Quality Tools  5 S  4 M  3 M  3 G  3 K PLAN DO CHECKACT QUALITY POLICY
  • 14. MARUTI SUZUKI INDIA LIMITED 13 What is 5S? SEIRI – PROPER SELECTION SEITION – ARRANGEMENT SEISO – CLEANING SEIKETSO – CLEANLINESS SHITSUKE– DISCIPLINE What is 4M? The factory is essentially a mix of man, materials, machines and methods. These should move continuously and effectively to produce a quality product at low cost. The most essential work in quality control is to thoroughly investigate regarding the problems concerning quality, decide suitable counter measures and carry out improvements accordingly.  MAN  MACHINE  MATERIAL  METHODS What is 3M? In Japanese Language 3M is: MURI – INCONVENIENCE MUDA – WASTAGE MURA – INCONSISTENCY What is 3G? In Japanese Language 3G is: GENCHI – ACTUAL PLACE GENBUTSU – ACTUAL THING GENJITSU – ACTUALLY What is 3K? In Japanese Language 3K is: KIMERAARETA KOTO GA: – What has been decided
  • 15. MARUTI SUZUKI INDIA LIMITED 14 KIHON DIRI: – As per the standard KICHIN TO MAMORU: – Must be followed
  • 16. MARUTI SUZUKI INDIA LIMITED 15 The hierarchy diagram of MSIL WORKER TRAINEE ASSISTANT SUPERVISOR SUPERVISOR EXECUTIVE SENIOR EXECUTIVE DEPUTY MANAGER MANAGER DEPARTMENT MANAGER D V M PART TIME DIRECTOR DIRECTOR JOINT MANAGING DIRECTOR MANAGING DIRECTOR CHAIRMAN
  • 17. MARUTI SUZUKI INDIA LIMITED 16 1.7 INFORMATION TECHNOLOGY DIVISION Information Technology Division (ITD) in Maruti was set up to keep pace with the changing environment i.e. emerging trends in IT and their impact on manufacturing industries. Today in Maruti all business functions are IT driven, which help in attaining better productivity and high quality levels besides providing better work environment. In fact any process reengineering or new process conceptualization happens with the help of IT. Most of the applications are in–house developed using Oracle & MS Technologies. Also, Maruti has implemented Oracle e–business suites in the areas of finance and HR. The IT Division comprises of following departments: ITD APPLICATION GROUPS OPERATIONS AG 1 AG 2 AG 3 IOS OSS IPS ITS ISM
  • 18. MARUTI SUZUKI INDIA LIMITED 17 APPLICATION GROUP I (AG-I) This department is responsible for all  ERP Financial Accounting System  Material  Personnel Inventory System.  Vendor Extranet  This department is responsible for all computerization activities related to materials system (or supply) and Scrap. APPLICATION GROUP II (AG-II) This department is responsible for all activities related to  Sales  Warranty claims  Service Division activities  Dealer Extranet  RO Extranet APPLICATION GROUP III (AG-III) This department is responsible for all computerization activities related to  Sales Support and Quality Gate  Spare Parts Division activities  Vehicle Tracking System (VTS) IT OPERATION AND SERVICES (IOS) This is very important department of IT Division .This unit does all the IT  Infrastructure planning  Procurement and maintenance  It takes care of all the hardware, network, data centre management and facility management. INFORMATION TECHNOLOGY STRATEGY (ITS) This department evaluates new Information Technology initiatives and checks its Feasibility before it is being implemented.
  • 19. MARUTI SUZUKI INDIA LIMITED 18 IT Partners and Support Services (IPS) This department is mainly engaged in  Dealer Management System (DMS)  Customer Relation Ship Management (CRM) Operating Support Services (OSS) This department is responsible for  ERP HR  ERP Payroll IT SERVICES MANESAR (ISM) This department manages all the IT infrastructure at Manesar plant. IT MISSION “Stimulate the value chain for business excellence by providing innovative Information systems using appropriate IT.” Maruti IT mission emphasizes the need for innovation and appropriate IT systems to drive business excellence. Appropriate IT system refers to making optimum and not excessive use of technology. And most importantly, IT has to permeate the entire value chain including its vendors and dealers.
  • 20. MARUTI SUZUKI INDIA LIMITED 19 Chapter 2 TRAINING 2.1 Introduction 2.2 Classroom Training
  • 21. MARUTI SUZUKI INDIA LIMITED 20 2.1 INTRODUCTION In this chapter, I intend to give a brief overview of the training undertaken at MSIL. During the course of my training, for the first month, we trainees were put through a very well organized professional training program with flair of classroom training focused on the business processes. The objective behind this training was to give us an inside on the day to day business operations at MSIL and how IT division enhances the productivity and smooth-lines these operations. The methodology followed at MSIL is to develop a chapter for self learning; the training sessions were very participative, we were encouraged to come forward with or ideas which would help in enhancing the system. 2.2 CLASSROOM TRAINING As the first day I had a verbal discussion with my Mentor. We had a formal introduction, with some basic understanding related about the system database ITD handles. He put some light on few topics, such as:  Client-server Architecture  Database Exception Handling  Oracle  Frontend & Backend Applications
  • 22. MARUTI SUZUKI INDIA LIMITED 21 Oracle 9i ORACLE provides the following features:  Large database and space management control It supports the largest of databases, potentially hundreds of gigabytes in size. To make efficient use of expensive hardware devices, it allows full control of space usage.  Many concurrent database users It supports large number of concurrent users executing a variety of database applications operating on the same data. It minimizes data contention and guarantees data concurrence.  High transaction processing performance It maintains a high degree of system performance.  Industry accepted standards It adheres to industry–accepted standard for the data access language, operating system, and user interface and network communication protocols.  Manageable security It provides fail–safe security features to limit and monitor data access to protect against unauthorized database access and use.  Database enforced integrity It enforces data integrity. So the costs of coding and managing checks in many database applications are eliminated  Client/Server (distributed processing) environments It allows processing to be split between the database server and client application programs. All responsibilities of shared data management can be processed by the computer running the database management system while the workstations running the database application concentrate on the interpretation and display of data.  Portability Application developed for ORACLE can be ported to any operating system with little or no modification.  Connectable ORACLE software allows different types of computers and operating system to share information across networks.
  • 23. MARUTI SUZUKI INDIA LIMITED 22 Chapter 3 3.1 Type of Architecture 3.1.1 Introduction 3.1.2 Client-Server / N-Tier System 3.2 SQL Editor- PL/SQL Developer 3.2.1 Starting in PL/SQL Developer: 3.2.2Creating Table 3.2.3Inserting Data 3.2.4Updating Data 3.2.5Grouping Data 3.2.6 Deleting Data 3.2.7Ordering Data 3.2.8Union 3.2.9Creating Indexes 3.2.10 Table Aliases 3.2.11Auto Increment 3.2.12Constraint  Primary Key  Foreign Key 3.3 DATABASE OF POLICY SCHEMAS 3.3.1 Introduction 3.3.2 SQL coding 3.4 Stored Procedures 3.5 Triggers 3.6. CYCLIC CASCADING in a TRIGGER
  • 24. MARUTI SUZUKI INDIA LIMITED 23 3.1.1 Introduction Architecture is plan for  N-tier Architecture/ Client-Server  There tier Architecture 3.1.2Client-Server / N-Tier Systems N-Tier architectures are hot. Well, maybe not as hot as a few years ago, but still it is very important you know about them. All web applications are N- Tier architectures. You have an application server, a large number of clients, and a database. An N-Tier architecture is really a Client-Server architecture combined with the Layered architecture. The reason why I combine Client- Server and N-Tier here is because they are very much related. A Client-Server system is one in which the server performs some kind of service that is used by many clients. The clients take the lead in the communication. The basic Client-Server architecture has 2 tiers (Client and Server). I will basically explain the 3-tier architecture here, which is an extension to the 2-tier architecture. The first, or presentation tier, a.k.a. the client or front-end, deals with the interaction with the user. Usually, there can be any number of clients which can all access the server at the same time. Currently the clients are mostly thin clients, which means they do not contain a lot of application code (in contrast to fat clients). Clients process user input, send requests to the server, and show the results of these requests to the user. A common client is made up of a number of dynamic HTML pages that one can access with a web browser. The second, or application tier, a.k.a. the server, or the back-end, or middleware, processes the requests of all clients. It is the actual web application that performs all functionality specific to the web application. However, it does not store the persistent data itself. Whenever it needs data of any importance, it contacts the database server. The third, or database tier contains the database management system that manages all persistent data.
  • 25. MARUTI SUZUKI INDIA LIMITED 24 It is clear that there are multiple clients. That's what client-server computing is all about. However, in the second and third tier there can also be multiple instances of the same application. If this is the case, it is because of scalability, load-balancing and redundancy. Which means the system is important, so let's add extra equipment that does the same thing. This makes the server a very powerful system, but also introduces synchronisation problems. Examples  Web-applications. Where the first tier is the application-tier, the second tier is the application tier and the third tier is the database tier. Where does it come from? At the advance of multitasking operating systems in the nineteen-sixties, it became possible to access a single computer (the server) from different terminals (clients). The distance between the clients and the server became bigger and the number of clients increased. At the time the application and database tiers were still integrated. It is called client-server computing. With the booming of the Internet and e-commerce in the nineteen-nineties, the architecture became important, and much time and money was invested in it. As other good architectures have shown, it is a good idea to separate the application code from the data. This principle was applied to the client- server architecture. Companies created application servers to ease the creation of web applications. An N-tier architecture (with N more than 3) is really 3 tier architectures in which the middle tier is split up into new tiers. The application tier is broken down into separate parts. What these parts are differs from system to system. The following picture shows it:
  • 26. MARUTI SUZUKI INDIA LIMITED 25 When should you use it? You don't usually need to build your own application and database server. Most application developers either build the application specific front-end code, or the application specific back-end code. This code is then embedded in an existing application server and uses an existing database management server. How does it work? The architecture is so generic it is hard to say anything concrete about it. Communication between the different tiers often takes place via a network. Communication within a tier also is done over a (local) network. Clients don't communicate directly to each other. Clients communicate to the application server directly or to a broker that balances requests between separate server machines. The database layer usually contains only one database.
  • 27. MARUTI SUZUKI INDIA LIMITED 26 3.2 SQL Editor- PL/SQLDeveloper What is PL/SQL? PL/SQL stands for Procedural Language extension of SQL. PL/SQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle Corporation in the early 90’s to enhance the capabilities of SQL. The PL/SQL Engine: Oracle uses a PL/SQL engine to processes the PL/SQL statements. A PL/SQL code can be stored in the client system (client-side) or in the database (server-side). A Simple PL/SQL Block: Each PL/SQL program consists of SQL and PL/SQL statements which from a PL/SQL block. A PL/SQL Block consists of three sections:  The Declaration section (optional).  The Execution section (mandatory).  The Exception (or Error) Handling section (optional). Declaration Section: The Declaration section of a PL/SQL Block starts with the reserved keyword DECLARE. This section is optional and is used to declare any placeholders like variables, constants, records and cursors, which are used to manipulate data in the execution section. Placeholders may be any of Variables, Constants and Records, which stores data temporarily. Cursors are also declared in this section. Execution Section: The Execution section of a PL/SQL Block starts with the reserved keyword BEGIN and ends with END. This is a mandatory section and is the section where the program logic is written to perform any task. The programmatic constructs like loops, conditional statement and SQL statements form the part of execution section.
  • 28. MARUTI SUZUKI INDIA LIMITED 27 Exception Section: The Exception section of a PL/SQL Block starts with the reserved keyword EXCEPTION. This section is optional. Any errors in the program can be handled in this section, so that the PL/SQL Blocks terminates gracefully. If the PL/SQL Block contains exceptions that cannot be handled, the Block terminates abruptly with errors. 3.2.1Starting in PL/SQL Developer:  Login-id, Database Name and Password provided by the department are to be entered first.  If the parameters match the in-built records, access is permitted.  SQL window is opened wherein the queries for creation, updation, insertion, deletion etc. for new table is performed.  Press (shift + home) key combination to select a particular query.  Press F8 to execute.  The created table gets embedded in the database which will be later needed for the system designing as the QUERY SOURCE. The sample queries performed for creating a mock table in the initial stages of my training are shown as below: Creating Table: The CREATE TABLE statement is used to create a table in a database. Syntax CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type, .... ) CREATE INDEX index_name ON table_name (column_name) While creating a table few things are necessary such as datatype, commas, n etc. These tables are created in main database of the system. InsertingData: The INSERT INTO statement is used to insert a new row in a table.
  • 29. MARUTI SUZUKI INDIA LIMITED 28 Syntax It is possible to write the INSERT INTO statement in two forms. The first form doesn't specify the column names where the data will be inserted, only their values: INSERT INTO table_name VALUES (value1, value2, value3,... The second form specifies both the column names and the values to be inserted: INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...) While inserting into a table previously created should follow the sequence of the columns in the table. To insert a alpha-numeric value we put single-quotes( ‘ ‘) whereas not for numeric value. Updating Data: The UPDATE statement is used to update existing records in a table. Syntax UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Note: Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated. If you omit the WHERE clause, all records will be updated! DeletingData: The DELETE statement is used to delete rows in a table. Syntax DELETE FROM table_name WHERE some_column=some_value Note: Notice the WHERE clause in the DELETE syntax. The WHERE clause specifies which record or records that should be deleted. If you omit the WHERE clause, all records will be deleted!
  • 30. MARUTI SUZUKI INDIA LIMITED 29 GroupingData: Aggregate functions often need an added GROUP BY statement. The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns. Syntax SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operatorvalue GROUP BY column_name OrderingData: The ORDER BY keyword is used to sort the result-set by a specified column. The ORDER BY keyword sort the records in ascending order by default. If you want to sort the records in a descending order, you can use the DESC keyword. Syntax SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC Union: Syntax SELECT column_name(s) FROM table_name1 UNION SELECT column_name(s) FROM table_name2 Note: The UNION operator selects only distinct values by default. To allow duplicate values, use UNION ALL. UNION ALL Syntax SELECT column_name(s) FROM table_name1
  • 31. MARUTI SUZUKI INDIA LIMITED 30 UNION ALL SELECT column_name(s) FROM table_name2 The column names in the result-set of a UNION are always equal to the column names in the first SELECT statement in the UNION. Creating Indexes: An index can be created in a table to find data more quickly and efficiently. The users cannot see the indexes, they are just used to speed up searches/queries. Note: Updating a table with indexes takes more time than updating a table without (because the indexes also need an update). So you should only create indexes on columns (and tables) that will be frequently searched against. Syntax CREATE INDEX index_name ON table_name (column_name) UNIQUE INDEX Syntax CREATEUNIQUE INDEXindex_name ON table_name (column_name) Note: The syntax for creating indexes varies amongst different databases. Therefore: Check the syntax for creating indexes in your database. Table Aliases: You can give a table or a column another name by using an alias. This can be a good thing to do if you have very long or complex table names or column names. An alias name could be anything, but usually it is short. Syntax SELECT column_name(s) FROM table_name AS alias_name
  • 32. MARUTI SUZUKI INDIA LIMITED 31 Syntax for Columns SELECT column_name AS alias_name FROM table_name Alias Example We have a table called "Persons" and another table called "Product_Orders". We will give the table aliases of "p" and "po" respectively. Now we want to list all the orders that "Ola Hansen" is responsible for. We use the following SELECT statement: SELECT po.OrderID, p.LastName, p.FirstName FROM Persons AS p, Product_Orders AS po WHERE p.LastName='Hansen' AND p.FirstName='Ola' Auto Increment: Very often we would like the value of the primary key field to be created automatically every time a new record is inserted. We would like to create an auto-increment field in a table. Syntax The following SQL statement defines the "P_Id" column to be an auto-increment primary key field in the "Persons" table: CREATE TABLE Persons ( P_Id int NOT NULL AUTO_INCREMENT, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) ) By default, the starting value for AUTO_INCREMENT is 1, and it will increment by 1 for each new record. To let the AUTO_INCREMENT sequence start with another value, use the following SQL statement:
  • 33. MARUTI SUZUKI INDIA LIMITED 32 ALTER TABLE Persons AUTO_INCREMENT=100 To insert a new record into the "Persons" table, we will not have to specify a value for the "P_Id" column (a unique value will be added automatically): INSERT INTO Persons (FirstName,LastName) VALUES ('Lars','Monsen') The SQL statement above would insert a new record into the "Persons" table. The "P_Id" column would be assigned a unique value. The "FirstName" column would be set to "Lars" and the "LastName" column would be set to "Monsen" Constraint  Primary Key  Foreign Key  PrimaryKey The PRIMARY KEY constraint uniquely identifies each record in a database table. Primary keys must contain unique values. A primary key column cannot contain NULL values. Each table should have a primary key, and each table can have only ONE primary key. SQL PRIMARY KEY Constraint on CREATE TABLE The following SQL creates a PRIMARY KEY on the "P_Id" column when the "Persons" table is created: MySQL: CREATE TABLE Persons ( P_Id int NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255), PRIMARY KEY (P_Id) )  Foreign Key
  • 34. MARUTI SUZUKI INDIA LIMITED 33 A FOREIGN KEY in one table points to a PRIMARY KEY in another table. Let's illustrate the foreign key with an example. Look at the following two tables: The "Persons" table: P_Id LastName FirstName Address City 1 Hansen Ola Timoteivn 10 Sandnes 2 Svendson Tove Borgvn 23 Sandnes 3 Pettersen Kari Storgt 20 Stavanger The "Orders" table: O_Id OrderNo P_Id 1 77895 3 2 44678 3 3 22456 2 4 24562 1 Note that the "P_Id" column in the "Orders" table points to the "P_Id" column in the "Persons" table. The "P_Id" column in the "Persons" table is the PRIMARY KEY in the "Persons" table. The "P_Id" column in the "Orders" table is a FOREIGN KEY in the "Orders" table. The FOREIGN KEY constraint is used to prevent actions that would destroy links between tables. The FOREIGN KEY constraint also prevents that invalid data form being inserted into the foreign key column, because it has to be one of the values contained in the table it points to. SQL FOREIGN KEY Constraint on CREATE TABLE The following SQL creates a FOREIGN KEY on the "P_Id" column when the "Orders" table is created: MySQL: CREATE TABLE Orders ( O_Id int NOT NULL, OrderNo int NOT NULL, P_Id int, PRIMARY KEY (O_Id), FOREIGN KEY (P_Id) REFERENCES Persons(P_Id) ) To allow naming of a FOREIGN KEY constraint, and for defining a FOREIGN KEY constraint on multiple columns, use the following SQL
  • 35. MARUTI SUZUKI INDIA LIMITED 34 Joins Join is a KEYWORD used to query data from different tables on the basis of some relation between tables. Joins are of following types:  Inner Join  Left Join  Right Join Inner join: The INNER JOIN keyword return rows when there is at least one match in both tables. Syntax SELECT column_name(s) FROM table_name1 INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_name The INNER JOIN keyword return rows when there is at least one match in both tables. If there are rows in "Persons" that do not have matches in "Orders", those rows will NOT be listed. Left Join The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). Syntax SELECT column_name(s) FROM table_name1 LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_name PS: In some databases LEFT JOIN is called LEFT OUTER JOIN. The LEFT JOIN keyword returns all the rows from the left table, even if there are no matches in the right table. Right Join The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1). Syntax SELECT column_name(s)
  • 36. MARUTI SUZUKI INDIA LIMITED 35 FROM table_name1 RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_name PS: In some databases RIGHT JOIN is called RIGHT OUTER JOIN. The RIGHT JOIN keyword returns all the rows from the right table , even if there are no matches in the left table.
  • 37. MARUTI SUZUKI INDIA LIMITED 36 3.3 DATABASE OF POLICY SCHEMAS INTRODUCTION: MSIL, form different policy for customers benefit in transacting the commodity. The company frame various policies for different type of customer such as for Maruti employee, or for vendors, or for dealers, or Govt. employee, etc. These policies maintain a lots of details related. Such details are maintained in tables We have a table “POLICY" CURRENT_POLICY_NO number(10) OLD_POLICY_TRXN_NO number(10) POLICY_TRXN_NO number(10) ISSUE_DATE date RISK_INCEPTION_DATE date RISK_EXPIRY_DATE date POLICY_SELECTION varchar2(10) SERVICE_TAX_AMOUNT number(10) OUTLET_CODE number(10) IS_EXPIRED number(10) IS_TOTAL_DAMAGE number(10) EXPIRED_BY number(10) EXPIRED_DATE number(10) IS_CANCELLED varchar2(10) IS_PROOF_AVAILABLE varchar2(10) CERTIFICATE varchar2(10) UNDERTAKING varchar2(10) UPDATED_BY varchar2(10) UPDATED_DATE varchar2(10) CREATED_BY varchar2(10) CREATED_DATE varchar2(10) BLOCKED_REMARKS varchar2(10) IS_BLOCKED varchar2(10) CANCELLED_REMARKS varchar2(10) CANCELLED_BY varchar2(10) CANCELLED_DATE varchar2(10) EXTERNALACCINCLUDED varchar2(10) INS_FEEDBACK_SUBMITTED varchar2(10) INS_FEEDBACK_SUBMITTED_DATEvarchar2(10)
  • 38. MARUTI SUZUKI INDIA LIMITED 37 Table “policy_vehicle” maintains the records of a vehicle which is manufactured, sale, chassis no., engine detail, color type, etc POLICY_TRXN_NO number(10) CURRENT_POLICY_NO number(10) ENGINE_NO number(10) CHASSIS_NO number(10) SUB_MODEL_NO number(10) VEHICLE_REGN_NO number(10) VEHICLE_REGN_DATE date VEHICLE_TYPE varchar2(20) SEATING_CAPACITY varchar2(20) VEHICLE_EXSHOWROOM_PRICE varchar2(20) VEHICLE_SALE_DATE date YEAR_OF_MANUFACTURE varchar2(20) BRANCH_NAME varchar2(20) CREATED_BY varchar2(20) CREATED_DATE date UPDATED_BY varchar2(20) UPDATED_DATE date COLOR_TYPE varchar2(20) SP_DISPATCH_DATE date Table “Policy_client_Details” maintains the record of the client who is purchasing a vehicle from Maruti. POLICY_TRXN_NO number(10) CURRENT_POLICY_NO number(10) TITLE varchar2(20) Name varchar2(20) GENDER varchar2(20) DOB date ADDRESS varchar2(20) CITY_ID varchar2(20) PIN varchar2(20) PHONE_NO number(10) MOBILE number(10) EMAIL_ID varchar2(20) CREATED_BY varchar2(20) CREATED_DATE date CORPORATE_NAME varchar2(20) ADDRESS varchar2(20)
  • 39. MARUTI SUZUKI INDIA LIMITED 38 Table “City_ID” CITY_ID varchar2(20), STATE_ID varchar2(20), NAME varchar2(20), PRIVATE_CAR_ZONE varchar2(20), COMM_TO6_CAR_ZONE varchar2(20), COMM_ABOVE6_CAR_ZONE varchar2(20), ZONE_ID varchar2(20), FOR_CODE varchar2(20), INS_OFFICE_ID varchar2(20), REGION_ID varchar2(20), CREATED_BY varchar2(20), Table “OutletMaster” OUTLET_CODE varchar2(20) PARTY_CODE varchar2(20) OUTLET_NAME varchar2(20) TYPE varchar2(20) ADDRESS varchar2(20) PINCODE varchar2(20) CITY_ID varchar2(20) DISTRICT varchar2(20) C_PERSON varchar2(20) SIGNATORY varchar2(20) PHONE number(10) MOBILE number(10) FAX number(10) EMAIL varchar2(20) CREATED_BY varchar2(20) CREATED_DATE date ASSIGN_TO_OUTLET varchar2(20)
  • 40. MARUTI SUZUKI INDIA LIMITED 39 We have to create a table to show data from these above tables. These tables are inter-related with some relation. Table “Report-Detail” REGION_ID varchar2(20) CURRENT_POLICY_NOnumber(10) ISSUE_DATE date Outlet Name varchar2(20) CUSTOMER_NAMEvarchar2(20) Cust_city varchar2(20) SUB_MODEL varchar2(20) ENGINE_NO number(10) CHASSIS_NO number(10) In these tables columns has there own datatype. Datatypes are those functions which defines the type of input to be stored by the user. Different Datatypes are: 1. Varchar2() : it accepts alpha-numeric characters. 2. Date : it accepts only dates in specific style like DD/MM/YY (default) 3. Datetime : it accepts date & time in specific style like DD/MM/YY HH:MM:SS 4. Numbers() : it accepts only numbers. We even have to take out the count: POLICY COUNT DETAILS POLICY_ISSUED 25190 POLICY_RECONCILED 22182 POLICY_INCEPTED 23968 POLICY_CANCELLED 1279 POLICY_VB64VERIFIED 19372 POLICY_CDADJUSTED NULL POLICY_BREAKINAPPROVED 1025 POLICY_BREAKINREJECTED 247
  • 41. MARUTI SUZUKI INDIA LIMITED 40 SQL Coding: CREATE TABLE policy ( CURRENT_POLICY_NO number(10), OLD_POLICY_TRXN_NO number(10), POLICY_TRXN_NO number(10), ISSUE_DATE date, RISK_INCEPTION_DATE date, RISK_EXPIRY_DATE date, POLICY_SELECTION varchar2(10), SERVICE_TAX_AMOUNT number(10), OUTLET_CODE number(10), IS_EXPIRED number(10), IS_TOTAL_DAMAGE number(10), EXPIRED_BY number(10), EXPIRED_DATE number(10), IS_CANCELLED varchar2(10), IS_PROOF_AVAILABLE varchar2(10), CERTIFICATE varchar2(10), UNDERTAKING varchar2(10), UPDATED_BY varchar2(10), UPDATED_DATE varchar2(10), CREATED_BY varchar2(10), CREATED_DATE varchar2(10), BLOCKED_REMARKS varchar2(10), IS_BLOCKED varchar2(10) CANCELLED_REMARKS varchar2(10), CANCELLED_BY varchar2(10), CANCELLED_DATE varchar2(10), EXTERNALACCINCLUDED varchar2(10), INS_FEEDBACK_SUBMITTED varchar2(10), INS_FEEDBACK_SUBMITTED_DATE varchar2(10), primary key (CURRENT_POLICY_NO) ) CREATE TABLE policy_vehicle ( POLICY_TRXN_NO number(10), CURRENT_POLICY_NO number(10), ENGINE_NO number(10), CHASSIS_NO number(10), SUB_MODEL_NO number(10), VEHICLE_REGN_NO number(10), VEHICLE_REGN_DATE date, VEHICLE_TYPE varchar2(20), SEATING_CAPACITY varchar2(20), VEHICLE_EXSHOWROOM_PRICE varchar2(20), VEHICLE_SALE_DATE date, YEAR_OF_MANUFACTURE varchar2(20), BRANCH_NAME varchar2(20), CREATED_BY varchar2(20), CREATED_DATE date,
  • 42. MARUTI SUZUKI INDIA LIMITED 41 UPDATED_BY varchar2(20), UPDATED_DATE date, COLOR_TYPE varchar2(20), SP_DISPATCH_DATE date, primary key (CURRENT_POLICY_NO) ) CREATE TABLE policy_client_detail1 ( POLICY_TRXN_NO number(10) CURRENT_POLICY_NO number(10), TITLE varchar2(20), Name varchar2(20), GENDER varchar2(20), DOB date, ADDRESS varchar2(20), CITY_ID varchar2(20), PIN varchar2(20), PHONE_NO number(10), MOBILE number(10), EMAIL_ID varchar2(20), CREATED_BY varchar2(20), CREATED_DATE date, CORPORATE_NAME varchar2(20), ADDRESS varchar2(20), primary key (CURRENT_POLICY_NO) ) CREATE TABLE citymaster ( CITY_ID varchar2(20), STATE_ID varchar2(20), NAME varchar2(20), PRIVATE_CAR_ZONE varchar2(20), COMM_TO6_CAR_ZONE varchar2(20), COMM_ABOVE6_CAR_ZONE varchar2(20), ZONE_ID varchar2(20), FOR_CODE varchar2(20), INS_OFFICE_ID varchar2(20), REGION_ID varchar2(20), CREATED_BY varchar2(20), CREATED_DATE date ) CREATE TABLE outletmaster ( OUTLET_CODE varchar2(20), PARTY_CODE varchar2(20), OUTLET_NAME varchar2(20), TYPE varchar2(20), ADDRESS varchar2(20), PINCODE varchar2(20), CITY_ID varchar2(20), DISTRICT varchar2(20), C_PERSON varchar2(20),
  • 43. MARUTI SUZUKI INDIA LIMITED 42 SIGNATORY varchar2(20), PHONE number(10), MOBILE number(10), FAX number(10), EMAIL varchar2(20), CREATED_BY varchar2(20), CREATED_DATE date, ASSIGN_TO_OUTLET varchar2(20) ) SELECT c.REGION_ID, p.CURRENT_POLICY_NO, p.ISSUE_DATE, o.Outlet_Name, pcd.CUSTOMER_NAME, o.CITY_ID, pv.SUB_MODEL_NO, pv.ENGINE_NO, pv.CHASSIS_NO, pv.Vehicle_Sale_Date FROM policy1 p LEFT JOIN policy_vehicle pv on p .CURRENT_POLICY_NO = pv.CURRENT_POLICY_NO LEFT JOIN policy_client_detail1 pcd on p.CURRENT_POLICY_NO= pcd.CURRENT_POLICY_NO LEFT JOIN outletmaster o on p.OUTLET_CODE = o.OUTLET_CODE LEFT JOIN citymaster c on o.CITY_ID=c.CITY_I SELECT count(*) FROM policy p WHERE p.ISSUE_DATE>='1-jan-2011' AND p.ISSUE_DATE<='21-jan-2011' SELECT count(*) FROM policy_client_detail pcd WHERE pcd.CREATED_DATE>='1-jan-2011' AND pcd.CREATED_DATE<='21-jan-2011' SELECT count(*) FROM policy p WHERE p.RISK_INCEPTION_DATE>='1-jan-2011' AND p.RISK_INCEPTION_DATE<='21-jan-2011' SELECT count(*) FROM policy p WHERE p.CANCELLED_DATE>='1-jan-2011' AND p.CANCELLED_DATE<='21-jan-2011'
  • 44. MARUTI SUZUKI INDIA LIMITED 43 3.4 Stored Procedures What is a Stored Procedure? A stored procedure or in simple a proc is a named PL/SQL block which performs one or more specific task. This is similar to a procedure in other programming languages. A procedure has a header and a body. The header consists of the name of the procedure and the parameters or variables passed to the procedure. The body consists or declaration section, execution section and exception section similar to a general PL/SQL Block. A procedure is similar to an anonymous PL/SQL Block but it is named for repeated usage. We can pass parameters to procedures in three ways. 1) IN-parameters 2) OUT-parameters 3) IN OUT-parameters A procedure may or may not return any value. General Syntax to create a procedure is: CREATE [OR REPLACE] PROCEDURE proc_name [list of parameters] IS Declaration section BEGIN Execution section EXCEPTION Exception section END; IS - marks the beginning of the body of the procedure and is similar to DECLARE in anonymous PL/SQL Blocks. The code between IS and BEGIN forms the Declaration section. The syntax within the brackets [ ] indicate they are optional. By using CREATE OR REPLACE together the procedure is created if no other procedure with the same name exists or the existing procedure is replaced with the current code. The below example creates a procedure ‘employer_details’ which gives the details of the employee. 1> CREATE OR REPLACE PROCEDURE employer_details 2> IS 3> CURSOR emp_cur IS 4> SELECT first_name, last_name, salary FROM emp_tbl; 5> emp_rec emp_cur%rowtype; 6> BEGIN 7> FOR emp_rec in sales_cur 8> LOOP 9> dbms_output.put_line(emp_cur.first_name || ' ' ||emp_cur.last_name 10> || ' ' ||emp_cur.salary); 11> END LOOP;
  • 45. MARUTI SUZUKI INDIA LIMITED 44 12>END; 13> / How to execute a Stored Procedure? There are two ways to execute a procedure. 1) From the SQL prompt. EXECUTE [or EXEC] procedure_name; 2) Within another procedure – simply use the procedure name. procedure_name; NOTE: In the examples given above, we are using backward slash ‘/’ at the end of the program. This indicates the oracle engine that the PL/SQL program has ended and it can begin processing the statements.
  • 46. MARUTI SUZUKI INDIA LIMITED 45 3.5 Trigger A trigger is a pl/sql block structure which is fired when a DML statements like Insert, Delete, Update is executed on a database table. A trigger is triggered automatically when an associated DML statement is executed. Syntax of Triggers The Syntax for creating a trigger is: CREATE [OR REPLACE ] TRIGGER trigger_name {BEFORE | AFTER | INSTEAD OF } {INSERT [OR] | UPDATE [OR] | DELETE} [OF col_name] ON table_name [REFERENCING OLD AS o NEW AS n] [FOR EACH ROW] WHEN (condition) BEGIN --- sql statements END;  CREATE [OR REPLACE ] TRIGGER trigger_name - This clause creates a trigger with the given name or overwrites an existing trigger with the same name.  {BEFORE | AFTER | INSTEAD OF } - This clause indicates at what time should the trigger get fired. i.e for example: before or after updating a table. INSTEAD OF is used to create a trigger on a view. before and after cannot be used to create a trigger on a view.  {INSERT [OR] | UPDATE [OR] | DELETE} - This clause determines the triggering event. More than one triggering events can be used togetherseparated by OR keyword. The trigger gets fired at all the specified triggering event.  [OF col_name] - This clause is used with update triggers. This clause is used when you want to trigger an event only when a specific column is updated.  CREATE [OR REPLACE ] TRIGGER trigger_name - This clause creates a trigger with the given name or overwrites an existing trigger with the same name.  [ON table_name] - This clause identifies the name of the table or view to which the trigger is associated.  [REFERENCING OLD AS o NEW AS n] - This clause is used to reference the old and new values of the data being changed.By default, you reference the values as :old.column_name or :new.column_name. The reference names can also be changed from old (or new) to any otheruser-defined name. You cannot reference old values when inserting a record, or new values when deleting a record, because they do not exist.  [FOR EACH ROW] - This clause is used to determine whether a trigger must fire when each row gets affected ( i.e. a Row Level Trigger) or just once when the entire sql statement is executed(i.e.statement level Trigger).  WHEN (condition) -This clause is valid only for row level triggers. The trigger is fired only for rows that satisfy the condition specified. For Example: The price of a product changes constantly. It is important to maintain the history of the prices of the products.
  • 47. MARUTI SUZUKI INDIA LIMITED 46 We can create a trigger to update the 'product_price_history' table when the price of the product is updated in the 'product' table. 1) Create the 'product' table and 'product_price_history' table CREATE TABLE product_price_history (product_id number(5), product_name varchar2(32), supplier_name varchar2(32), unit_price number(7,2) ); CREATE TABLE product (product_id number(5), product_name varchar2(32), supplier_name varchar2(32), unit_price number(7,2) ); 2) Create the price_history_trigger and execute it. CREATE or REPLACE TRIGGER price_history_trigger BEFORE UPDATE OF unit_price ON product FOR EACH ROW BEGIN INSERT INTO product_price_history VALUES (:old.product_id, :old.product_name, :old.supplier_name, :old.unit_price); END; / 3) Lets update the price of a product. UPDATE PRODUCT SET unit_price = 800 WHERE product_id = 100 Once the above update query is executed, the trigger fires and updates the 'product_price_history' table. 4)If you ROLLBACK the transaction before committing to the database, the data inserted to the table is also rolled back. Types of PL/SQL Triggers There are two types of triggers based on the which level it is triggered. 1) Row level trigger - An event is triggered for each row upated, inserted or deleted. 2) Statement level trigger - An event is triggered for each sql statement executed. PL/SQL Trigger Execution Hierarchy The following hierarchy is followed when a trigger is fired. 1) BEFORE statement trigger fires first. 2) Next BEFORE row level trigger fires, once for each row affected. 3) Then AFTER row level trigger fires once for each affected row. This events will alternates between BEFORE and AFTER row level triggers. 4) Finally the AFTER statement level trigger fires.
  • 48. MARUTI SUZUKI INDIA LIMITED 47 For Example: Let's create a table 'product_check' which we can use to store messages when triggers are fired. CREATE TABLE product (Message varchar2(50), Current_Date number(32) ); Let's create a BEFORE and AFTER statement and row level triggers for the product table. 1) BEFORE UPDATE, Statement Level: This trigger will insert a record into the table 'product_check' before a sql update statement is executed, at the statement level. CREATE or REPLACE TRIGGER Before_Update_Stat_product BEFORE UPDATE ON product Begin INSERT INTO product_check Values('Before update, statement level',sysdate); END; / 2) BEFORE UPDATE, Row Level: This trigger will insert a record into the table 'product_check' before each row is updated. CREATE or REPLACE TRIGGER Before_Upddate_Row_product BEFORE UPDATE ON product FOR EACH ROW BEGIN INSERT INTO product_check Values('Before update row level',sysdate); END; / 3) AFTER UPDATE, Statement Level: This trigger will insert a record into the table 'product_check' after a sql update statement is executed, at the statement level. CREATE or REPLACE TRIGGER After_Update_Stat_product AFTER UPDATE ON product BEGIN INSERT INTO product_check Values('After update, statement level', sysdate); End; / 4) AFTER UPDATE, Row Level: This trigger will insert a record into the table 'product_check' after each row is updated. CREATE or REPLACE TRIGGER After_Update_Row_product AFTER insert On product FOR EACH ROW BEGIN INSERT INTO product_check Values('After update, Row level',sysdate); END;
  • 49. MARUTI SUZUKI INDIA LIMITED 48 / Now lets execute a update statement on table product. UPDATE PRODUCT SET unit_price = 800 WHERE product_id in (100,101); Lets check the data in 'product_check' table to see the order in which the trigger is fired. SELECT * FROM product_check;
  • 50. MARUTI SUZUKI INDIA LIMITED 49 3.6 CYCLIC CASCADING in a TRIGGER This is an undesirable situation where more than one trigger enter into an infinite loop. while creating a trigger we should ensure the such a situtation does not exist. The below example shows how Trigger's can enter into cyclic cascading. Let's consider we have two tables 'abc' and 'xyz'. Two triggers are created. 1) The INSERT Trigger, triggerA on table 'abc' issues an UPDATE on table 'xyz'. 2) The UPDATE Trigger, triggerB on table 'xyz' issues an INSERT on table 'abc'. In such a situation, when there is a row inserted in table 'abc', triggerA fires and will update table 'xyz'. When the table 'xyz' is updated, triggerB fires and will insert a row in table 'abc'. This cyclic situation continues and will enter into a infinite loop, which will crash the database.
  • 51. MARUTI SUZUKI INDIA LIMITED 50 CONCLUSION The project aimed at maintenance of policy details. The company ensures new policy for the retailers as well as for customer. Record of these policies are maintained in the database. Functionality of these policies is to provide extra benefits to customer and thus taking care of their satisfaction. The purpose of this document was to create an application that would allow to fetch the data from different tables in a database and provide it to the user as required. The objective was to ensure the availability of the procedures which reduces the execution time, thus are stored as pre-compiled functions. This target has been fruitfully achieved and successfully implemented. The hands-on experience that I attained at MSIL not only enhanced my technical skills, but also gave me an enriching experience of the company environment. I had the pleasing opportunity to interact with the elite staff and the other employees of the company, and to learn the inner working of the organization. I had learnt how one should present oneself, how one must behave with their seniors and colleagues; also that there is no greater success policy than hard work, and that punctuality is must. It was truly a wonderful experience to be able to work with the intellectual class. In concise, it was not only an industrial training, but an experience of a lifetime… Merits Of the Project  Ensuring in time & adequate procurement.  Analyzing the total count of issued vehicle.  Helping in maintaining records. LimitationsOf the Project  New data cannot be inserted in the system. Only the existing data in the in-built database can be implemented.
  • 52. MARUTI SUZUKI INDIA LIMITED 51 BIBLIOGRAPHY  SQL, PL/SQL: The Programming Language Of Oracle, 2nd Revised Edition; Ivan Bayross; BPB Publications; 1999.  Oracle developer 2000 by Ivan Bayross.  Database System S. K. Singh.  www.google.com  www.marutisuzuki.com  Maruti manuals