Mdu Workshop
Mdu Workshop
Practical Report
On
“Workshop Practice Lab”
(ASDP- ……)
By
Name: ________________________________
Class: ________________________________
The matter presented in this seminar has not been submitted by us for the award
of any other degree elsewhere.
This is to certify that the above statement is correct to the best of our knowledge.
Date: …………………
Signature: …………………..
(LAB INCHARGE)
DECLARATION
Signature:______________
Student Name:___________________
ACKNOWLEDGEMENT
We would like to take this opportunity to express our deep sense of gratitude to
all who helped us directly or indirectly during this seminar work.
First of all, we would like to express our deepest gratitude to our seminar
supervisor________________________ (practical incharge) for his enormous
help and advice and for providing inspiration which cannot be expressed with
words. We would have not accomplished this seminar without his patient care,
understanding and encouragement. His advice, encouragement and critics are
source of innovative ideas, inspiration and causes behind the successful
completion of this seminar work. The confidence shown on us by him was the
biggest source of inspiration for us.
Date: …………………
Signature:______________
Student Name:___________________
INDEX
S.No. Experiments Remark
To manufacture the fitting job as per given
1.
drawing.
2. To make the double V- butt joint with arc welding.
To manufacture the job on centre lathe machine as
3.
per given drawing .
To manufacture the half lap carpentry job as per
4. given drawing.
To make the box by sheet metal operation.
5.
To study basics of manufacturing science related to tool
6. and operations of foundary shop.
10.
11.
12.
13.
14.
15.
5|Page
MAYA DEVI UNIVERSITY, DEHRADUN
LAB MANUAL
Course Name : EXPERIMENT NO. 1
Branch: ME Semester : I
Faculty : Mr.
PRECAUTIONS-
Ensure that job is securely held in the Vice, otherwise it may spill away and injure
you.
Hand hacksaw should be straight during cutting of V shape.
RESULT-
The fitting job has successfully manufactured.
6|Page
Tools used in Fitting Workshop :
1. Holding Tools
2. Marking Tools
3. Measuring Tools
4. Cutting Tools
5. Finishing Tools
6. Striking Tool
They are 3 types of Marking tools used in the fitting workshop and are as
follows.
Scriber
Dot Punch
Center Punch
Flat file
Square file
Triangular file
Round file
Half-round file
Swiss or Needle file
9|Page
MAYA DEVI UNIVERSITY, DEHRADUN
LAB MANUAL
Course Name : EXPERIMENT NO. 2
Workshop Practice Lab
Branch: ME Semester : I
Faculty : Mr.
THEORY- Welding Process, Different Joints, Arc Welding principle, and Techniques in
Wilding.
PROCEDURE-
1. Cut the required dimension work piece from lot and remove the all burrs.
2. Hold the work piece in Vice and make its surface smooth.
3. Coat the surface of job with chalk and allow it to dry.
4. layout the desired dimension, mark line & spot with scriber and punch.
5. Hold the job again on vice and make double V Butt joint.
6. Place the work piece at welding table in desired Butt joint position.
7. Set the voltage and current for work pieces and weld them.
8. Switch off the welding machine and allow to cool them.
9. Hold the welded pieces with tong and chip off the slag from weld portion, using
chipping hammer.
10. Cool down the job with cold water, put the Roll No. with punch Numbers.
10 | P a g e
PRECAUTIONS-
1. Ensure that the pieces are placed in desired position.
2. Use proper eye shield to protect eyes
3. Use gloves to protect hands.
4. Maintain proper distance from work pieces.
RESULT-
The job has successfully made.
11 | P a g e
MAYA DEVI UNIVERSITY, DEHRADUN
LAB MANUAL
Course Name : EXPERIMENT NO. 3
Manufacturing Practices / Workshop Lab
AIM : - To manufacture the job on centre lathe machine as per given drawing .
PRECAUTIONS : -
1. Ensure that job is firmly held in the jaws , otherwise it may slip away and injured you .
2. Tool must be held in tool holder tightly .
3. Tool must be sharp .
4. Run the machine with proper speed .
5. Maintain properly work piece .
PROCEDURE :-
1.Cut the required dimentions from the raw material .
2.Load the job on machine from one end provide filling operation on it .
3.Provide turning operation on dia 30x25 and knurling by knurling tool .
4.Provide proper taper , turning diameter 30 to dia 20 x15 mm .
5.Unload the job and reload on machine from the machine end . 6.Facing the end to
maintain length .
7.Turn dia 30x25 mm jobs .
8. Turn dia 20 x35 mm .
9 , Champher the job 2 mm x 45 mm from end .
10. Unload job from machine , mark roll no . and submit it .
12 | P a g e
RESULT : The turning job as per given drawing is successfully manufactured .
OBSERVATIONS :
13 | P a g e
MAYA DEVI UNIVERSITY, DEHRADUN
LAB MANUAL
Course Name : EXPERIMENT NO. 4
Workshop Practice Lab
AIM: - To manufacture the half lap carpentry job as per given drawing.
TOOLS AND EQUIPMENT: - Work bench carpentry Vice Jack planer, Cross cut saw,
Tennon Saw, Firmers Chisel, Mallet, Try square, Marking Gauge, Pencil. Scale, Wood
Working File, Sand paper etc.
PROCEDURE:-
1. Cut the 255mm × 50mm × 25mm.Piece from lot.
2. Remove all burrs and make it smooth through planer.
3. Now mark over piece through, Gauge & Pencil and convert it through planer
250mm × 45mm × 20 mm. pieces.
4. Through saw cut the piece in two half’s.
5. Place one half into vice and mark over 45mm length that booth one side.
6. Now cut the piece from 45mm length upto 10mm depth.
7. Place the same piece in vertical position and Remove the 45mm × 45mm × 10mm
piece.
8. Take second piece horizontally in vice.
14 | P a g e
Carpentry is a skilled trade and a craft in which the primary work
performed is the cutting, shaping and installation of building materials
during the construction of buildings, ships, timber bridges, concrete
formwork, etc. Carpenters traditionally worked with natural wood and
did the rougher work such as framing, but today many other materials
are also used and sometimes the finer trades of cabinetmaking and
furniture building are considered carpentry.
Joint, in carpentry, junction of two or more members of a framed
structure. Joinery, or the making of wooden joints, is one of the
principal functions of the carpenter and cabinetmaker. Wood, being a
natural material, is not uniform in quality, and moisture, present in the
tree during growth, is uneven in cut wood.
timber joints
15 | P a g e
Basic timber joints used in carpentry.
The object of the joint is to fix two members together so that the joint has the
greatest possible mechanical strength and is as unobtrusive as possible. Though
there are many joints in use, they fall into a few basic groups, many being
variations and elaborations on fundamentally simple ideas. Practically all are based
on handwork, and with few exceptions most machine-made joints follow the
traditional patterns; most joints rely to a considerable extent on a combination of
mechanical fit and glue for their strength. Common types of joints include the
dovetail, used for joining two flat members together at right angles, as in the sides
of a drawer; the dowelled joint, in which dowelling is employed to impart
mechanical strength; and the mortise and tenon, used to join a horizontal member
with the vertical member of a frame.
What follows is a list of what we consider to be the essential tools for carpentry,
handily divided into sections based on hand tools, power tools, accessories,
storage, and safety equipment. While not every one of these tools will be required
for every job, this list will provide a comprehensive guide to tools that have no
replacement in their functionality.
Because carpentry is such a broad field of study, with many possible projects and
outcomes depending on your skill level, choosing only the tools that you’re most in
need of for a project you have in mind is the best way to go. That way, you can
continue to collect tools that are appropriate both to your desires, and your carpentry
skill level. Before you know it, you’ll have a fine set of
tools and the know-how to put them to good use!
Hand Tools
1.Claw Hammer
One of the most basic tools of the carpentry trade, a claw hammer will allow you
to drive nails with one end and remove them with the other. Look for one that has
a comfortable but secure grip and is not too heavy to hold and swing.
16 | P a g e
\
2. Tape Measure
Plastic measuring tapes are cheap and simple but tend to stretch and lose
accuracy over time. Go for a metal measuring tape, preferably a retractable
model that’s good for measuring larger pieces of uncut lumber.
3. Measuring Squares
Any tool also known as a “carpenter’s square” must be essential, right? That’s
absolutely true for measuring squares, as they’ll allow you to identify, measure, and
mark right angles during your projects.
4. Chisels
Great for hand-carving or lathe turning, chisels were once the primary tool for
carving out joints in Japanese carpentry. Often sold in sets, you’ll need a variety of
chisels to perform any meaningful or detailed work.
17 | P a g e
5. Mallets
A wooden mallet is complementary to a chisel set, allowing you to precisely
drive the sharp heads into your workpiece. Rubber mallets are useful in putting
together joints and will not damage wood when tapped with light to medium
force.
6. Handsaw
The workhorse of hand tool carpentry, handsaws are used to rip and crosscut
boards to size. Look for blades that are taper ground, allowing better clearance
around the teeth and a smoother, more efficient cutting motion.
7. Backsaw
Designed with thin blades and finely set teeth, backsaws are the detail-oriented
companion to the handsaw. Supported by a heavy strip of brass or steel over the
top of the blade, they excel at detail work and can be used to cut mortise and tenon
18 | P a g e
or dovetail joints.
9. Planes
Used to smooth wooden surfaces while gradually reducing their thickness, planes
are a complex and multi-part hand tool with something of a cult following in the
classical carpentry community. A good bench plane will get you through 90% of
projects, while rabbet and block planes are reserved for more specialized angled
work.
19 | P a g e
11. Grinder
While not technically a hand tool, a motorized bench grinder is used almost
solely in the refinishing of hand tools like chisels gouges. Chipped or worn
blades can often be refurbished through the combination of a few times through
a grinder and finishing with a sharpening stone.
13. Screwdrivers
First and foremost, when using a screwdriver, the tip must fit the size of the screw
slot in question. Therefore, you’ll need screwdrivers in a range of sizes to
accommodate whatever size of screw you come up against in your projects.
20 | P a g e
14. Clamps
You can rarely have too many clamps in a woodworking shop, and a wide
selection of bar clamps, miter clamps, and C-clamps will always hold you in good
stead when you need an “extra hand”. Good clamps can be expensive, so
consider renting extra sets for especially large projects.
Power Tools
16. Jigsaw
Also known as a saber saw, these versatile and inexpensive power tools do a fine
job of cutting boards to a rough size but can’t be relied on for straight cuts. Instead,
use them for curved cuts and quick projects where precision is not key.
21 | P a g e
17. Circular Saw
A rough and ready workhorse for carpentry in a woodshop or on a job site, the
circular saw has become a staple of construction contractors everywhere.
Thanks to advances in materials technology, you can now find lightweight and
exceptionally powerful circular saws available for entirely reasonable prices.
18. Router
Used for cutting grooves, curved figures, and joints, routers can easily replace
a whole family of hand planes. Fixed routers are suspended above the
workpiece and lowered into the cut as one unit, while plunge routers deploy
only the cutting edge via spring-loaded columns.
19. Sander
Great for taking much of the time and effort out of finishing a piece of wood,
even the finest of powered sanders will only get you partway there. Once
you’ve progressed to a “finishing sander”, there will still be a short period of
hand-sanding necessary to achieve a truly fine finish.
20. Biscuit Joiner
A particularly specialized saw and joiner combo, the biscuit joiner cuts a small
section of wood out of the edge of a board to which glue and a “biscuit” of
compressed wood are added. As the glue and wood expand to fill the small
hole, a strong and durable joint is created.
The most central aspect of any woodworking shop, a table saw will be your
most substantial investment for home woodworking. Traditional cabinet saws
are large, heavy, and extremely accurate and efficient; more modern
portable models allow you to take much of this utility with you to a job site.
Sometimes known as a chop saw, the radial arm saw is a quick and ready tool
for making rips, crosscuts, bevels, or miter cuts on a job site or in your home
workshop. While lacking some of the precision of a table saw, they are an
indispensable tool for increasing efficiency in trim and molding work.
23. Band Saw
A continuous loop of metal driven between two wheels, the band saw
always cuts downward – thereby eliminating the possibility of kickback on a
workpiece. It performs many of the same functions of a radial arm saw (if
somewhat less accurately) and can be used for curved cuts as well.
24. Planer
After purchasing a table or band saw for your home workshop,the planer might
be the next most essential power tool. The best planers can be precisely
adjusted to evenly smooth surfaces on all four sides of a workpiece, saving
much time and effort when compared to using a hand plane.
25. Lathe
An adjunct art form to carpentry’s many straight lines and right angles,
incorporating a lathe into your workshop allows you to enter the world of
turned pieces such as bowls, cups, and decorative table legs. You’ll need
specialized turning tools to take full advantage of a lathe in your home
workshop.
26. Universal Machine
When space is limited and you may not be able to fit many power tools into
one woodshop, the universal machine is your answer. Combining the functions
of a table saw, jointer, thickness planer, spindle shaper, and mortiser, it’s an
all-in-one solution ideally suited to cramped workspaces.
Accessories
27. Carpenter’s Pencil
Flat instead of round, the carpenter’s pencil is more versatile and accurate than
a standard pencil in measuring precise markings for woodworking cuts. Next
Level Carpentry covers how to sharpen a carpenter’s pencil here:
If you own any power tools that are not cordless, chances are you will one
day need an extension cord to get the most use out of them. Even extra-long
extension cords are now available at a reasonable price, making them an
easy addition to your carpentry toolkit.
29. Miter Box
A simple wooden jig used for cutting miter joints and square ends, you can also
find them available in plastic or metal. Two raised sides and a groove in the
middle allow you to slot your saw into predetermined angles to guide your cuts.
30. Bench Hook
Used for crosscutting short lengths of wood with a backsaw, the bench hook is
primarily helpful as a safety measure. Readymade bench hooks are available,
or
you can make your own by attaching two blocks to a flat board.
Whether you choose a shop vac for its portability and versatility or a
dedicated dust collection system attached to your table saw, you’ll need
something to make sure your work surfaces are free of dust. Aside from
increasing accuracy and precision in your work, this will also keep your floors
safer for walking on.
MAYA DEVI UNIVERSITY, DEHRADUN
LAB MANUAL
Course Name : EXPERIMENT NO. 5
Workshop Practice Lab
Branch: ME Semester : I
Faculty : Mr.
PROCEDURE:-
1. Take the 27 gauge Aluminum sheet and mark 200mm × 120mm 2 rectangle with
scriber and scale.
2. Cut the 200mm × 120mm 2 rectangle piece with cutter from sheet.
3. Take 20mm dimension with scale and mark it from all side with scriber.
4. Place the sheet on anvil in such way so that 20mm should be outside from
platform.
5. Now with mallet, strike over outer part of sheet and fold it.
6. Fold the 20mm from all side of piece and box will made.
Meaning
The complete knowledge of fundamental workshop technology and manufacturing
processes is highly troublesome for anybody to claim competence over it. It deals
with numerous aspects of workshops procedures also for providing the basic
working awareness of the various engineering materials, tools, accessories,
manufacturing processes, basic concepts of machine instruments, production
criteria’s, traits and uses of numerous testing instruments and calibrating or
inspecting units for checking materials or products designed in various production
shops in a commercial environment. It also explains and illustrates the use of several
hand tools (calibrating, marking, forming and supporting gear etc.), tools, machinery
and diverse methods of production that facilitate forming or shaping the existing raw
materials into appropriate usable forms. Below are some of the manufacturing
processes that are worth reading.
Machining
Tools used for machining are immobile power-driven units used to form or shape
solid materials, specifically metals. The forming is done by removing extra materials
from a work-piece. Machine tools make up the foundation of advanced industry and
are utilized either indirectly or directly in the manufacturing of tool parts.
Traditional chip-making tools form the work-piece by trimming away the unwanted
part accessible as chips. Presses implement a several shaping processes, which
includes shearing, pressing, or elongating. Non-traditional machine tools implement
light, electric powered, chemical, and sonic power; superheated gas; and high-
energy compound beams to form the exotic supplies and materials that have been
created to meet the requirements of modern technology.
Joining
Every joining approach has particular design needs, while certain joint needs may
propose a particular joining approach. Design for assembly, and fastener selection
apply their own specifications.
Bolting is a standard fastening method, for instance, but welding may cut down the
weight of assemblies. Naturally, joints intended for the two approaches would differ
tremendously.
However, all joint patterns must consider features such as load factors, assembly
effectiveness, operating surroundings, overhaul and upkeep, and the materials
chosen.
Welding is generally a cost-effective approach to fabricate. It doesn't require
overlapping materials, and so it removes excess weight brought on by other
fastening methods. Fasteners don't have to be purchased and stored in stock.
Welding also can minimize costs related to extra parts, for example angles mounted
between parts.
Forming
Metal forming is the approach of creating the metallic components by deforming the
metal but not by removing, cutting, shredding or breaking any part. Bending,
spinning, drawing, and stretching are a few important metal forming process in
manufacturing. The metal press such as die and punching tools are implemented for
this manufacturing process.
Advantages: – Same equipment can be utilized for manufacturing various components
by simply changing the dies.
Disadvantages: – High apparatus and tooling expenses. – Heat treatment must be
applied afterwards.
Casting
Casting is a manufacturing process in which a solid is dissolved into a liquid, heated
to appropriate temperature (sometimes processed to change its chemical formula),
and is then added into a mold or cavity. Thus, in just one step, complex or simple
shapes can be crafted from any kind of metal that has the capability to be melted.
The end product can have practically any arrangement the designer wants.
Furthermore, the reluctance to working challenges can be improved, directional
attributes can be managed, and a pleasing look can be developed.
CNC machine
The term CNC stands for 'computer numerical control', and the CNC
machining
Once the CNC program is generated, the operator loads it to the CNC
machine. Types of CNC Machining Operations
CNC machining is a manufacturing process suitable for a wide variety of
industries, including automotive, aerospace, construction, and agriculture,
and able to produce a range of products, such as automobile frames, surgical
equipment, airplane engines, and hand and garden tools. The process
encompasses several different computer-controlled machining operations—
including mechanical, chemical, electrical, and thermal processes—
which remove the necessary material from the workpiece to produce a
custom- designed part or product. While chemical, electrical, and thermal
machining processes are covered in a later section, this section explores
some of the most common mechanical CNC machining operations
including:
Drilling
Milling
Turning
6. Why alloy steel is used in industries ? 7. What is the composition of High speed
steel ?
8. Give some uses of High carbon steel and its percentage of carbon . 9. Name some
elements which are used to make alloy steel .
Heat treatment
1. What is meant by heat treatment ?
2. What is isothermal transformation ?
3. What are the various factor to influence the hardening process of a metal ?
4. How do you classify the heat treatment processes ?
5. What is hardening process ?
6. What is casehardening ? And why is it done ?
7. What is annealing process ?
8. What is the difference between gas nitriding and cyaniding ?
9. How can we test the hardness of a metal ?
10. What is tempering of steel ?
Cutting tools
1. Differentiate the single point and multipoint cutting tools .
2. What is the difference between HCS and HSS tools .
3. What is machinability ?
4. Define the role of cutting fluids in manufacturing .
5. What are the characteristics of an ideal cutting tool ?
6. Classify the types of tool material ,
7. Name some element to make hard the cutting tools .
8. What is difference between orthogonal and oblique cutting ?
9. Give two examples of each cutting process .
10. What are the conditions which influence the metal cutting ?
Lathe machine
1. What is the working principle of lathe machine ?
2. What is the difference between turret and capstan lathe ?
3. Define cutting speed , feed and depth of cut .
4. What is the translating gear and its importance ?
5. Name the operation performed on lathe machine . Name the main parts of lathe
machine .
6 . Name the main parts of lathe machine .
7. What are the lathe accessories ?
8. What is lead screw and its importance ?
Milling machine
Grinding machine
Fitting
1. What is fastening ?
2. How many types are fastening ?
3. What is the difference between BSW and metric thread ?
4. What is the difference between right hand and left hand thread ?
5. Define lead and pitch .
6. Name the different type of threads ?
7. What is riveting ?
8. Name the riveted joint .
9. What are the main operation during fitting works ?
10. Name the general instruments used in fitting .
11. What is the process of marking ?
Carpentry
Ref . Books
1. Manufacturing technology by R.K Rajput ( Laxmi publications )
2. Workshop technology by B.S Raghuvanshi ( Dhanpat Rai & co . )
A
Practical Report
On
Computer Applications
By
Name: ________________________________
Class: ________________________________
The matter presented in this seminar has not been submitted by us for the award
of any other degree elsewhere.
This is to certify that the above statement is correct to the best of our knowledge.
Date: …………………
Signature: …………………..
(LAB INCHARGE)
DECLARATION
Signature:______________
Student Name:___________________
ACKNOWLEDGEMENT
We would like to take this opportunity to express our deep sense of gratitude to
all who helped us directly or indirectly during this seminar work.
First of all, we would like to express our deepest gratitude to our seminar
supervisor________________________ (practical incharge) for his enormous
help and advice and for providing inspiration which cannot be expressed with
words. We would have not accomplished this seminar without his patient care,
understanding and encouragement. His advice, encouragement and critics are
source of innovative ideas, inspiration and causes behind the successful
completion of this seminar work. The confidence shown on us by him was the
biggest source of inspiration for us.
Date: …………………
Signature:______________
Student Name:___________________
Experiment No.-1
Retrieving All Records from a Table
Objective:
Learn how to retrieve all records from a table using SQL.
Prerequisites:
Sample Table:
Let's assume we have a table named Employees with the following structure:
Step-by-Step Instructions:
1. Open Your DBMS: Launch your preferred DBMS (e.g., MySQL Workbench,
pgAdmin, etc.).
2. Connect to the Database: Connect to the database where your table is located.
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual database name
4. Write the SQL Query: To retrieve all records from the Employees table, use
the following SQL query:
sql
Copy code
SELECT * FROM Employees;
5. Execute the Query: Run the query. You can usually do this by clicking a
"Run" button or executing the command from the command line.
6. View the Results: Check the output/results pane to see all records from the
Employees table.
Expected Output: After executing the query, you should see a result set that looks like this:
Conclusion: You have successfully retrieved all records from the Employees table
using SQL. This fundamental operation is essential for data retrieval in any database
application.
Exercises:
1. Modify the query to select specific columns (e.g., Name and Salary).
2. Experiment with a different table in your database to retrieve records.
Experiment No.-2
Selecting Specific Columns from a Table
Objective:
Learn how to select specific columns from a table using SQL.
Prerequisites:
Sample Table:
Continuing with the Employees table, which has the following structure:
Step-by-Step Instructions:
1. Open Your DBMS: Launch your preferred DBMS (e.g., MySQL Workbench,
pgAdmin, etc.).
2. Connect to the Database: Connect to the database where your table is located.
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual
database name
4. Write the SQL Query: To select specific columns (e.g., Name and Salary)
from the Employees table, use the following SQL query:
sql
Copy code
SELECT Name, Salary FROM Employees;
5. Execute the Query: Run the query by clicking the "Run" button or executing
the command from the command line.
6. View the Results: Check the output/results pane to see the selected columns.
Expected Output: After executing the query, you should see a result set that looks like this:
Name Salary
John Doe 60000
Jane Smith 55000
Alice Brown 50000
Conclusion: You have successfully selected specific columns (Name and Salary)
from the Employees table using SQL. This allows you to retrieve only the data you
need, making queries more efficient.
Exercises:
Experiment No.-3
Using the WHERE Clause to Filter Records
Objective:
Learn how to filter records from a table using the WHERE clause in SQL.
Prerequisites:
Sample Table:
We will continue using the Employees table, which has the following structure:
Step-by-Step Instructions:
1. Open Your DBMS: Launch your preferred DBMS (e.g., MySQL Workbench,
pgAdmin, etc.).
2. Connect to the Database: Connect to the database where your table is located.
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual
database name
4. Write the SQL Query: To filter records where the Position is
Developer, use the following SQL query:
sql
Copy code
SELECT * FROM Employees WHERE Position = 'Developer';
5. Execute the Query: Run the query by clicking the "Run" button or executing
the command from the command line.
6. View the Results: Check the output/results pane to see the filtered records.
Expected Output: After executing the query, you should see a result set that looks like this:
Conclusion: You have successfully filtered records from the Employees table
using the WHERE clause. This allows you to retrieve specific data based on certain
conditions.
Exercises:
1. Modify the query to filter records where Salary is greater than 55000.
sql
Copy code
SELECT * FROM Employees WHERE Salary > 55000;
2. Experiment with filtering based on different criteria, such as Name or
Position.
Experiment No.-4
Sorting Records Using ORDER BY
Objective:
Learn how to sort records from a table using the ORDER BY clause in SQL.
Prerequisites:
Sample Table:
We will continue using the Employees table, which has the following structure:
Step-by-Step Instructions:
1. Open Your DBMS: Launch your preferred DBMS (e.g., MySQL Workbench,
pgAdmin, etc.).
2. Connect to the Database: Connect to the database where your table is located.
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual
database name
4. Write the SQL Query: To sort the records by Salary in ascending order,
use the following SQL query:
sql
Copy code
SELECT * FROM Employees ORDER BY Salary ASC;
5. Execute the Query: Run the query by clicking the "Run" button or executing
the command from the command line.
6. View the Results: Check the output/results pane to see the sorted records.
Expected Output: After executing the query, you should see a result set sorted by salary:
Conclusion: You have successfully sorted records from the Employees table using
the ORDER BY clause. This allows you to organize your data in a meaningful way.
Exercises:
sql
Copy code
SELECT * FROM Employees ORDER BY Name DESC;
2. Experiment with sorting by multiple columns (e.g., first by Position, then
by Salary).
Experiment No.-5
Using Aggregate Functions in SQL
Objective:
Learn how to use aggregate functions to perform calculations on your data in SQL.
Prerequisites:
Sample Table:
We will continue using the Employees table, which has the following structure:
EmployeeID Name Position Salary
1 John Doe Manager 60000
2 Jane Smith Developer 55000
3 Alice Brown Designer 50000
Step-by-Step Instructions:
1. Open Your DBMS: Launch your preferred DBMS (e.g., MySQL Workbench,
pgAdmin, etc.).
2. Connect to the Database: Connect to the database where your table is located.
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual
database name
4. Use Aggregate Functions:
o COUNT: Count the number of employees.
sql
Copy code
SELECT COUNT(*) AS TotalEmployees FROM
Employees;
o SUM: Calculate the total salary of all employees.
sql
Copy code
SELECT SUM(Salary) AS TotalSalary FROM
Employees;
o AVG: Calculate the average salary.
sql
Copy code
SELECT AVG(Salary) AS AverageSalary FROM
Employees;
o MIN: Find the minimum salary.
sql
Copy code
SELECT MIN(Salary) AS MinimumSalary FROM
Employees;
o MAX: Find the maximum salary.
sql
Copy code
SELECT MAX(Salary) AS MaximumSalary FROM
Employees;
5. Execute Each Query: Run each query one by one by clicking the "Run"
button or executing the commands from the command line.
6. View the Results: Check the output/results pane to see the results for each
aggregate function.
Expected Outputs:
Copy code
TotalEmployees
3
SUM: Total salary of all employees.
Copy code
TotalSalary
165000
AVG: Average salary of employees.
Copy code
AverageSalary
55000
MIN: Minimum salary among employees.
Copy code
MinimumSalary
50000
MAX: Maximum salary among employees.
Copy code
MaximumSalary
60000
Conclusion:
Exercises:
1. Use COUNT with a WHERE clause to count employees with a salary greater
than 55000.
sql
Copy code
SELECT COUNT(*) AS CountAbove55000 FROM Employees
WHERE Salary > 55000;
2. Find the total salary of employees in a specific position (e.g., Manager).
sql
Copy code
SELECT SUM(Salary) AS TotalManagerSalary FROM
Employees WHERE Position = 'Manager';
Experiment No.-6
Complex Queries Using JOIN
Objective:
Learn how to write complex SQL queries that involve multiple tables using different
types of JOIN operations: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL
JOIN.
Prerequisites:
Sample Tables:
1. Employees Table:
Step-by-Step Instructions:
1. Open Your DBMS: Launch your preferred DBMS (e.g., MySQL Workbench,
pgAdmin, etc.).
2. Connect to the Database: Connect to the database where your tables are
located.
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual
database name
Example Queries:
1. INNER JOIN
sql
Copy code
SELECT Employees.Name, Departments.DepartmentName
FROM Employees
INNER JOIN Departments ON Employees.EmployeeID =
Departments.EmployeeID;
2. LEFT JOIN
Retrieve all employees and their department names, including those without a
department.
sql
Copy code
SELECT Employees.Name, Departments.DepartmentName
FROM Employees
LEFT JOIN Departments ON Employees.EmployeeID =
Departments.EmployeeID;
3. RIGHT JOIN
Retrieve all departments and the employees in them, including departments without
employees.
sql
Copy code
SELECT Employees.Name, Departments.DepartmentName
FROM Employees
RIGHT JOIN Departments ON Employees.EmployeeID =
Departments.EmployeeID;
4. FULL JOIN
sql
Copy code
SELECT Employees.Name, Departments.DepartmentName
FROM Employees
FULL JOIN Departments ON Employees.EmployeeID =
Departments.EmployeeID;
Execute Each Query:
Run each query one by one by clicking the "Run" button or executing the commands
from the command line.
Expected Outputs:
INNER JOIN Output:
Name DepartmentName
Jane Smith IT
John Doe HR
LEFT JOIN Output:
Name DepartmentName
John Doe HR
Jane Smith IT
Alice Brown NULL
RIGHT JOIN Output:
Name DepartmentName
John Doe HR
Jane Smith IT
NULL Marketing
FULL JOIN Output:
Name DepartmentName
John Doe HR
Jane Smith IT
Alice Brown NULL
NULL Marketing
Conclusion:
You have successfully written complex SQL queries using various types of JOIN
operations to retrieve related data from multiple tables.
Exercises:
1. Create a query that lists all employees with their department names, but show
employees from the HR department only.
sql
Copy code
SELECT Employees.Name, Departments.DepartmentName
FROM Employees
LEFT JOIN Departments ON Employees.EmployeeID =
Departments.EmployeeID
WHERE Departments.DepartmentName = 'HR';
2. Write a query to count how many employees belong to each department,
including departments with no employees.
sql
Copy code
SELECT Departments.DepartmentName,
COUNT(Employees.EmployeeID) AS EmployeeCount
FROM Departments
LEFT JOIN Employees ON Employees.EmployeeID =
Departments.EmployeeID
GROUP BY Departments.DepartmentName;
Experiment No.-7
Subqueries, Nested Queries, and Set Operations
Objective:
Learn how to use subqueries and nested queries in SQL, as well as implement set
operations.
Prerequisites:
Sample Tables:
1. Employees Table:
3. Select the Database: If necessary, use the command to select the database:
sql
Copy code
USE your_database_name; -- Replace with your actual
database name
Subqueries and Nested Queries
1. Subquery Example
sql
Copy code
SELECT Name
FROM Employees
WHERE Salary > (SELECT AVG(Salary) FROM Employees);
2. Nested Query Example
List employees who work in the department with the highest salary.
sql
Copy code
SELECT Name
FROM Employees
WHERE EmployeeID IN (
SELECT EmployeeID
FROM Departments
WHERE EmployeeID IS NOT NULL
AND DepartmentID = (SELECT DepartmentID FROM
Departments ORDER BY EmployeeID DESC LIMIT 1)
);
Set Operations
1. UNION
Retrieve all unique positions from the Employees table and a hypothetical
Contractors table.
sql
Copy code
SELECT Position FROM Employees
UNION
SELECT Position FROM Contractors; -- Assuming
Contractors table exists
2. INTERSECT
sql
Copy code
SELECT Name FROM Employees
INTERSECT
SELECT Name FROM Contractors; -- Assuming Contractors
table exists
3. EXCEPT
sql
Copy code
SELECT Name FROM Employees
EXCEPT
SELECT Name FROM Contractors; -- Assuming Contractors
table exists
Execute Each Query:
Run each query one by one by clicking the "Run" button or executing the commands
from the command line.
Expected Outputs:
Conclusion:
You have successfully implemented subqueries, nested queries, and set operations in
SQL to manipulate and retrieve data from multiple tables.
Exercises:
1. Create a query to find employees whose salary is less than the salary of Jane
Smith.
sql
Copy code
SELECT Name
FROM Employees
WHERE Salary < (SELECT Salary FROM Employees WHERE
Name = 'Jane Smith');
2. If you have a Projects table, find all project names that are not assigned to
any employees.
sql
Copy code
SELECT ProjectName FROM Projects
EXCEPT
SELECT ProjectName FROM EmployeeProjects; --
Assuming EmployeeProjects table exists
Description: A university wants to keep track of its students, courses, and the
professors who teach those courses. The database should also manage the enrollment
of students in courses.
1. Student
o Attributes:
StudentID (Primary Key)
FirstName
LastName
DateOfBirth
Email
2. Course
o Attributes:
CourseID (Primary Key)
CourseName
Credits
3. Professor
o Attributes:
ProfessorID (Primary Key)
FirstName
LastName
Email
Department
4. Enrollment
o Attributes:
EnrollmentID (Primary Key)
Semester
Year
Grade
Relationships:
1. Enrolls
o Between: Student and Course
o Cardinality: Many-to-Many (A student can enroll in many courses, and
a course can have many students)
o Associative Entity: Enrollment (to capture additional attributes like
Semester, Year, and Grade)
2. Teaches
o Between: Professor and Course
o Cardinality: One-to-Many (A professor can teach multiple courses, but
each course is taught by one professor)
ER Diagram Representation:
css
Copy code
[Student] ------------------------< [Enrollment]
>------------------------ [Course]
|
|
|
|
[Professor]
---------------------------------------------------------
------|
Diagram Components:
1. Entities:
o Rectangles represent entities: Student, Course, Professor, Enrollment.
2. Attributes:
o Ovals connected to their respective entities for attributes.
o Underlined attributes indicate primary keys (e.g., StudentID, CourseID,
ProfessorID).
3. Relationships:
o Diamonds represent relationships (Enrolls, Teaches).
o Lines indicate the cardinality of the relationships (1 to Many, Many to
Many).
Example of ER Diagram:
If you were to create a visual ER diagram using diagramming software, it might look
something like this:
sql
Copy code
+-----------------+ +-----------------+
| Student | | Professor |
|-----------------| |-----------------|
| StudentID (PK) | | ProfessorID (PK)|
| FirstName | | FirstName |
| LastName | | LastName |
| DateOfBirth | | Email |
| Email | | Department |
+-----------------+ +-----------------+
| |
| |
| |
| |
| |
| |
+-----------------------+
| Teaches |
+-----------------------+
|
|
|
+-----------------+
| Course |
|-----------------|
| CourseID (PK) |
| CourseName |
| Credits |
+-----------------+
|
|
|
+-----------------+
| Enrollment |
|-----------------|
| EnrollmentID (PK)|
| Semester |
| Year |
| Grade |
+-----------------+
Conclusion:
4o mini
Experiment No.-8
To convert an ER diagram into relational schemas, we’ll take the entities, attributes,
and relationships identified in the ER diagram and define them in terms of tables.
Each table will correspond to an entity or a relationship, with attributes as columns.
Scenario Recap
From the university database example, we had the following entities and their
attributes:
1. Student
o StudentID (PK)
o FirstName
o LastName
o DateOfBirth
o Email
2. Course
o CourseID (PK)
o CourseName
o Credits
3. Professor
o ProfessorID (PK)
o FirstName
o LastName
o Email
o Department
4. Enrollment (associative entity for the many-to-many relationship between
Student and Course)
o EnrollmentID (PK)
o StudentID (FK)
o CourseID (FK)
o Semester
o Year
o Grade
Relational Schemas
1. Student Table
sql
Copy code
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Email VARCHAR(100) UNIQUE
);
2. Course Table
sql
Copy code
CREATE TABLE Course (
CourseID INT PRIMARY KEY,
CourseName VARCHAR(100),
Credits INT
);
3. Professor Table
sql
Copy code
CREATE TABLE Professor (
ProfessorID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100) UNIQUE,
Department VARCHAR(50)
);
4. Enrollment Table
sql
Copy code
CREATE TABLE Enrollment (
EnrollmentID INT PRIMARY KEY,
StudentID INT,
CourseID INT,
Semester VARCHAR(20),
Year INT,
Grade CHAR(2),
FOREIGN KEY (StudentID) REFERENCES
Student(StudentID),
FOREIGN KEY (CourseID) REFERENCES
Course(CourseID)
);
Primary Keys (PK): Each table has a primary key that uniquely identifies
each record.
Foreign Keys (FK): In the Enrollment table, StudentID and
CourseID act as foreign keys referencing the Student and Course tables,
respectively. This establishes the relationship between these tables.
Data Types: Appropriate data types are assigned based on the nature of the
data (e.g., VARCHAR, INT, DATE, CHAR).
Conclusion
Initial Tables:
1. Student
o StudentID (PK)
o FirstName
o LastName
o DateOfBirth
o Email
2. Course
o CourseID (PK)
o CourseName
o Credits
3. Professor
oProfessorID (PK)
o FirstName
o LastName
o Email
o Department
4. Enrollment
o EnrollmentID (PK)
o StudentID (FK)
o CourseID (FK)
o Semester
o Year
o Grade
Normalization Process
1. First Normal Form (1NF)
All attributes contain only atomic values (no repeating groups or arrays).
Each column contains values of a single type.
Analysis:
The initial tables already meet 1NF requirements, as all attributes are atomic.
It is in 1NF.
All non-key attributes are fully functionally dependent on the primary key.
Analysis:
The Enrollment table is the only candidate for potential violation. If the
same student enrolls in multiple courses, then Semester, Year, and Grade
depend only on EnrollmentID, not on the composite of StudentID and
CourseID.
No Changes Needed:
Since all non-key attributes in other tables depend on their respective primary
keys, the schema is already in 2NF.
It is in 2NF.
There are no transitive dependencies (non-key attributes do not depend on
other non-key attributes).
Analysis:
The Professor table might have a transitive dependency if, for example,
Department could be derived from another attribute or could link to another
entity.
Adjustments:
Normalized Schema:
sql
Copy code
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Email VARCHAR(100) UNIQUE
);
2. Course Table (Remains unchanged)
sql
Copy code
CREATE TABLE Course (
CourseID INT PRIMARY KEY,
CourseName VARCHAR(100),
Credits INT
);
sql
Copy code
CREATE TABLE Professor (
ProfessorID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100) UNIQUE
);
sql
Copy code
CREATE TABLE Department (
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR(100)
);
sql
Copy code
CREATE TABLE Enrollment (
EnrollmentID INT PRIMARY KEY,
StudentID INT,
CourseID INT,
Semester VARCHAR(20),
Year INT,
Grade CHAR(2),
FOREIGN KEY (StudentID) REFERENCES
Student(StudentID),
FOREIGN KEY (CourseID) REFERENCES
Course(CourseID)
);
sql
Copy code
CREATE TABLE Professor_Department (
ProfessorID INT,
DepartmentID INT,
PRIMARY KEY (ProfessorID, DepartmentID),
FOREIGN KEY (ProfessorID) REFERENCES
Professor(ProfessorID),
FOREIGN KEY (DepartmentID) REFERENCES
Department(DepartmentID)
);
Summary of Normalization
1NF: Ensured all attributes are atomic and the tables are properly structured.
2NF: Confirmed that non-key attributes are fully functionally dependent on the
primary keys.
3NF: Eliminated transitive dependencies by introducing a new Department
table, improving the structure and efficiency of the database.
This normalization process will help in reducing redundancy and ensuring data
integrity in the university database.
4o mini
Experiment No.-10
Here's how to create the tables for the university database and define the primary and
foreign keys based on the normalized schema discussed previously.
1. Student Table
sql
Copy code
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
DateOfBirth DATE,
Email VARCHAR(100) UNIQUE
);
2. Course Table
sql
Copy code
CREATE TABLE Course (
CourseID INT PRIMARY KEY,
CourseName VARCHAR(100),
Credits INT
);
3. Professor Table
sql
Copy code
CREATE TABLE Professor (
ProfessorID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100) UNIQUE
);
4. Department Table
sql
Copy code
CREATE TABLE Department (
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR(100)
);
5. Professor_Department Table (to establish the many-to-many relationship
between Professors and Departments)
sql
Copy code
CREATE TABLE Professor_Department (
ProfessorID INT,
DepartmentID INT,
PRIMARY KEY (ProfessorID, DepartmentID),
FOREIGN KEY (ProfessorID) REFERENCES
Professor(ProfessorID),
FOREIGN KEY (DepartmentID) REFERENCES
Department(DepartmentID)
);
6. Enrollment Table
sql
Copy code
CREATE TABLE Enrollment (
EnrollmentID INT PRIMARY KEY,
StudentID INT,
CourseID INT,
Semester VARCHAR(20),
Year INT,
Grade CHAR(2),
FOREIGN KEY (StudentID) REFERENCES
Student(StudentID),
FOREIGN KEY (CourseID) REFERENCES
Course(CourseID)
);
Primary Keys (PK): Each table defines a primary key that uniquely identifies
each record (e.g., StudentID, CourseID, ProfessorID,
DepartmentID, and EnrollmentID).
Foreign Keys (FK):
o In the Enrollment table, StudentID and CourseID are foreign
keys referencing the Student and Course tables, respectively.
o In the Professor_Department table, ProfessorID references
the Professor table, and DepartmentID references the
Department table.
Conclusion
These SQL statements define the structure of the university database, ensuring that
data integrity is maintained through the use of primary and foreign keys. You can
execute these statements in your SQL database management system to create the
respective tables.
Experiment No.-11
To create a new database and define its schema, you can use SQL commands. Below
is a step-by-step guide to creating a university database and defining its schema based
on the previously discussed tables.
First, you need to create the database. You can do this with the following SQL
command:
sql
Copy code
CREATE DATABASE UniversityDB;
sql
Copy code
USE UniversityDB;
Now, you can define the schema by creating the necessary tables along with their
primary and foreign keys. Here’s the SQL code for creating each table:
1. Student Table
sql
Copy code
CREATE TABLE Student (
StudentID INT PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
DateOfBirth DATE,
Email VARCHAR(100) UNIQUE NOT NULL
);
2. Course Table
sql
Copy code
CREATE TABLE Course (
CourseID INT PRIMARY KEY,
CourseName VARCHAR(100) NOT NULL,
Credits INT CHECK (Credits > 0)
);
3. Professor Table
sql
Copy code
CREATE TABLE Professor (
ProfessorID INT PRIMARY KEY,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
Email VARCHAR(100) UNIQUE NOT NULL
);
4. Department Table
sql
Copy code
CREATE TABLE Department (
DepartmentID INT PRIMARY KEY,
DepartmentName VARCHAR(100) NOT NULL
);
5. Professor_Department Table (to establish the many-to-many relationship)
sql
Copy code
CREATE TABLE Professor_Department (
ProfessorID INT,
DepartmentID INT,
PRIMARY KEY (ProfessorID, DepartmentID),
FOREIGN KEY (ProfessorID) REFERENCES
Professor(ProfessorID),
FOREIGN KEY (DepartmentID) REFERENCES
Department(DepartmentID)
);
6. Enrollment Table
sql
Copy code
CREATE TABLE Enrollment (
EnrollmentID INT PRIMARY KEY,
StudentID INT,
CourseID INT,
Semester VARCHAR(20) NOT NULL,
Year INT CHECK (Year >= 2000), -- assuming years
should be realistic
Grade CHAR(2),
FOREIGN KEY (StudentID) REFERENCES
Student(StudentID),
FOREIGN KEY (CourseID) REFERENCES
Course(CourseID)
);
Execution
You can execute the above SQL commands in your SQL database management
system (e.g., MySQL Workbench, pgAdmin) to create the UniversityDB database
and define its schema.
Conclusion
By following these steps, you have successfully created a new database and defined
its schema, establishing the structure needed to manage the university's data
effectively.
Experiment No.-12
Creating indexes on tables is an effective way to improve query performance in a
database. Below, I'll provide SQL commands to create indexes on the tables in the
UniversityDB database, focusing on columns that are commonly used in search
conditions, joins, and foreign key relationships.
sql
Copy code
CREATE INDEX idx_student_lastname ON
Student(LastName);
2. Index on the Course Table
o Index on CourseName to speed up searches by course name.
sql
Copy code
CREATE INDEX idx_course_name ON Course(CourseName);
3. Index on the Professor Table
o Index on LastName to speed up searches by professor last name.
sql
Copy code
CREATE INDEX idx_professor_lastname ON
Professor(LastName);
4. Index on the Department Table
o Index on DepartmentName to speed up searches by department name.
sql
Copy code
CREATE INDEX idx_department_name ON
Department(DepartmentName);
5. Index on the Enrollment Table
o Composite index on StudentID and CourseID to speed up joins and
queries related to enrollments.
sql
Copy code
CREATE INDEX idx_enrollment_student_course ON
Enrollment(StudentID, CourseID);
6. Index on the Professor_Department Table
o Composite index on ProfessorID and DepartmentID for efficient
joins.
sql
Copy code
CREATE INDEX idx_professor_department ON
Professor_Department(ProfessorID, DepartmentID);
Execution
You can execute the above SQL commands in your SQL database management
system (e.g., MySQL Workbench, pgAdmin) after creating the tables in the
UniversityDB database.
Considerations
Index Types: The default index type is a B-tree index, which is suitable for
most queries. You may consider other types (like full-text indexes) based on
your specific use cases.
Performance Trade-offs: While indexes speed up read operations, they can
slow down write operations (INSERT, UPDATE, DELETE) because the index
must also be updated. It's important to balance the need for fast queries with
the overhead of maintaining indexes.
Monitoring: Regularly monitor query performance and adjust indexes as
necessary based on query patterns and application needs.
Conclusion
By creating these indexes, you enhance the query performance for frequently
accessed columns, especially those involved in searches and joins. This will lead to
faster data retrieval and an overall improved user experience in applications relying
on the UniversityDB database
Experiment No.-13
Optimizing SQL queries is crucial for improving performance, especially in
databases with large datasets. Below are strategies for optimizing queries, including
rewriting them for better efficiency and leveraging indexes.
1. Using Indexes
Example Query:
sql
Copy code
SELECT FirstName, LastName
FROM Student
WHERE LastName = 'Smith';
2. Avoiding SELECT *
Example Query:
sql
Copy code
SELECT *
FROM Course
WHERE Credits > 3;
Rewritten Query:
sql
Copy code
SELECT CourseID, CourseName
FROM Course
WHERE Credits > 3;
3. Filtering Early
Example Query:
sql
Copy code
SELECT p.FirstName, p.LastName, c.CourseName
FROM Professor p
JOIN Course c ON p.ProfessorID = c.ProfessorID
WHERE c.Credits > 3;
Optimization: If you can filter before joining, do so. This reduces the amount of data
being processed in the join.
Rewritten Query:
sql
Copy code
SELECT p.FirstName, p.LastName, c.CourseName
FROM Professor p
JOIN (
SELECT *
FROM Course
WHERE Credits > 3
) c ON p.ProfessorID = c.ProfessorID;
4. Using EXISTS Instead of IN
Example Query:
sql
Copy code
SELECT FirstName, LastName
FROM Student
WHERE StudentID IN (SELECT StudentID FROM Enrollment
WHERE Grade = 'A');
Optimization: Using EXISTS can sometimes be more efficient than using IN,
particularly when dealing with subqueries.
Rewritten Query:
sql
Copy code
SELECT FirstName, LastName
FROM Student s
WHERE EXISTS (
SELECT 1
FROM Enrollment e
WHERE e.StudentID = s.StudentID AND e.Grade = 'A'
);
5. Limiting Results
Example Query:
sql
Copy code
SELECT FirstName, LastName
FROM Student
ORDER BY LastName;
Optimization: If you only need a subset of the results, use LIMIT to reduce the
number of rows returned.
Rewritten Query:
sql
Copy code
SELECT FirstName, LastName
FROM Student
ORDER BY LastName
LIMIT 10;
6. Using Joins Effectively
Example Query:
sql
Copy code
SELECT s.FirstName, s.LastName, e.Grade
FROM Student s, Enrollment e
WHERE s.StudentID = e.StudentID;
Optimization: Use explicit JOIN syntax for clarity and potential performance
benefits.
Rewritten Query:
sql
Copy code
SELECT s.FirstName, s.LastName, e.Grade
FROM Student s
JOIN Enrollment e ON s.StudentID = e.StudentID;
7. Utilizing Aggregate Functions Wisely
Example Query:
sql
Copy code
SELECT COUNT(*)
FROM Enrollment
WHERE Semester = 'Fall' AND Year = 2023;
Optimization: Ensure there are indexes on Semester and Year to speed up the
aggregation.
Use your database's query analyzer or execution plan feature to see how queries are
executed. This can help you identify bottlenecks and inefficient operations.
Conclusion
This trigger will log details of new enrollments into a separate Enrollment_Log
table.
This trigger will update a hypothetical Status column in the Student table based
on the average grade. Assume grades are represented numerically.
This trigger will prevent the deletion of a course if there are any records in the
Enrollment table for that course.
Conclusion
By using triggers effectively, you can automate various tasks in your database,
enhance data integrity, and maintain consistency without manual intervention.
Triggers can help enforce business rules and keep your database clean and accurate.
Make sure to test triggers thoroughly to avoid unintended consequences, especially
when they involve updates and deletes.
A
Practical Report
On
“Workshop Practice Lab”
(ASDP- ……)
By
Name: ________________________________
Class: ________________________________
The matter presented in this seminar has not been submitted by us for the award
of any other degree elsewhere.
This is to certify that the above statement is correct to the best of our knowledge.
Date: …………………
Signature: …………………..
(LAB INCHARGE)
DECLARATION
Signature:______________
Student Name:___________________
ACKNOWLEDGEMENT
We would like to take this opportunity to express our deep sense of gratitude to
all who helped us directly or indirectly during this seminar work.
First of all, we would like to express our deepest gratitude to our seminar
supervisor________________________ (practical incharge) for his enormous
help and advice and for providing inspiration which cannot be expressed with
words. We would have not accomplished this seminar without his patient care,
understanding and encouragement. His advice, encouragement and critics are
source of innovative ideas, inspiration and causes behind the successful
completion of this seminar work. The confidence shown on us by him was the
biggest source of inspiration for us.
Date: …………………
Signature:______________
Student Name:___________________
INDEX
75 | P a g e
15.
76 | P a g e
List of Experiments
Learn how to retrieve all records from a table using SQL.
Learn how to select specific columns from a table using SQL.
Learn how to filter records from a table using the WHERE clause in SQL.
Learn how to sort records from a table using the ORDER BY clause in SQL
Learn how to use aggregate functions to perform calculations on your data in SQL.
Learn how to write complex SQL queries that involve multiple tables using different
types of JOIN operations: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
Learn how to use subqueries and nested queries in SQL, as well as implement set
operations.
To convert an ER diagram into relational schemas, we’ll take the entities, attributes,
and relationships identified in the ER diagram and define them in terms of tables.
Each table will correspond to an entity or a relationship, with attributes as columns.
To apply normalization techniques (1NF, 2NF, and 3NF) to ensure database
efficiency for our university database example.
To create the tables for the university database and define the primary and foreign
keys based on the normalized schema discussed previously.
To create a new database and define its schema, using SQL commands.
SQL Commands to Create Indexes
Applying indexes in database with example
Triggers for the University Database
| P a g e No.
List of Experiments
To manufacture the fitting job as per given drawing.
To make the double V- butt joint with arc welding.
To manufacture the job on centre lathe machine as per given drawing .
To manufacture the half lap carpentry job as per given drawing.
To make the box by sheet metal operation.
To study basics of manufacturing science related to tool and operations of foundary shop.
Study of tools and operations of Smithy shop
Minor Project:
To make a minor project by the students in batches comprising the operations performed
in different shops.
| P a g e No.
List of Experiments
To determine the viscosity of a given fluid using the capillary tube method.
To measure the pressure distribution along a horizontal pipe and verify Bernoulli’s
equation.
To determine the Reynolds number for flow in a pipe and analyze the flow type
(laminar, transitional, or turbulent).
To measure the head loss caused by different pipe fittings, such as bends, valves,
and elbows.
To determine the flow rate of a fluid using a Venturi meter.
To determine the surface tension of a liquid using the drop weight method.
| P a g e No.