2. Institute of Southern Punjab
Student No Full Name
1
2
3
(BSIT-023R14P-39)
(BSIT-021R15-10)
(BSIT-021R15-04)
M. Bassam Bukhari
Anzar Abbas
Aqib Nazir
Presented By:
8. Database & Table Coding
Create database if not exists
Gourmet_Foods_Company;
Create table if not exists
Gourmet_Foods_Company.Continent
( Cont_ID int(20) auto_increment primary key,
Cont_Name varchar(50) not null )
Institute of Southern Punjab
9. Views
• In SQL, a view is a virtual table based on the
result set of an SQL statement
• A view contains rows and columns, just like a
real table
create view view_name AS SELECT
column_name from
database_name.table_name;
Institute of Southern Punjab
10.
11. Joins
• An SQL JOIN clause is used to combine
rows from two or more tables, based on a
common field between them
SELECT column_name(s) FROM table1
INNER JOIN table2 ON
table1.column_name =table2.column_name
Institute of Southern Punjab
12. Stored-Procedure
• A stored procedure is a set of SQL
statements that can be stored in the server
• It is a method to encapsulate repetitive
tasks
• They allow for variable declarations, flow
control and other useful programming
techniques
Institute of Southern Punjab
13. Syntax
DELIMITER //
Create procedure show_continent()
Begin
Select *from
gourmet_foods_company.continent;
END //
Institute of Southern Punjab
14. Triggers
• Kind of stored procedures
• Use only for DML commands
• It fires automatically when these actions are
attempted
Institute of Southern Punjab
15. Syntax
DELIMITER //
CREATE trigger insertlocation after insert on location for
each row
BEGIN
insert into gourmet_foods_company.location VALUES
('@Loc_ID','@Loc_Name','@Loc_Country','@Loc_State','
@Loc_City');
END //
Institute of Southern Punjab
16. Indexes
• Use for sorting record
• Create a sorted virtual copy
• Faster for efficient searching
CREATE INDEX index_name ON
database_name.table_name(column_name);
Institute of Southern Punjab