Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dr. Djamal Ziani Professor Assistant King Saud University.

Similar presentations


Presentation on theme: "Dr. Djamal Ziani Professor Assistant King Saud University."— Presentation transcript:

1 Dr. Djamal Ziani Professor Assistant King Saud University

2  Understand and refine the requirements  Example: A manager ask you to write a statistical report about the professors.  Assume you have the following model:

3

4  SELECT lname, fname, salary, prof_rank, dept_name, school_name, cont(stu_num) FROM Professor AS P, Employee AS E, Department AS D, School AS S, Class AS C, Enrol AS R WHERE E.emp_num = P.emp_num (1) AND D.dept_code = P.dept_code (2) AND S.school_code = D.school_code (3) AND C.emp_num = P.emp_num (4) AND R.class_code = C.class_code (5)  Select prof_rank, count(emp_num), AVG(salary) FROM Professor AS P, Employee AS E WHERE E.emp_num = P.emp_num (1) GROUP BY prof_rank

5  Understand well the requirements  Have deep details on the requirements (what exact fields we want to display, what calculation to do, what frequency, …)  To whom is dedicated the work (Manager, employee, Director, user)  Get the requirements written and sign off by the requestor.

6  Before you jump in the development, try to be familiar with the ER and physical models.  Ask always the WHY question to understand well the models.  Write all your remarks and questions and send them to the responsible.  Write all the changes that you can do to improve the models.

7  Tracing  Tune the SQL ◦ Performance statistics ◦ The properties of Objects such as tables, clusters, indexes, and views ◦ The join order selected by the optimizer ◦ Degree of Parallelism  Distribution  Tune the access paths  Tune the memory  Tune the I/O and physical structure  Tune the resource contention .

8  Are there missing indexes (create new ones)  Are the existing indexes used, if not why  Are some indexes need to be rebuild (e.g deleted entries represent 20%)  Force the optimizer to use an index

9  View is a virtual table we can create view by using following query Create view view_name as select * from table_name  We can select data from view by using following query.select * from view_name;  Views have a useful role to play in any application and can be used to help improve performance  Example  CREATE VIEW cur_mth_sales AS SELECT isbn, sum(sales_val) total_sales FROM cur_mth_transactions GROUP BY ISBN;   SELECT name, total_sales FROM cur_mth_sales;

10  In its simplest form, "staging" involves putting something in a specific location to be accessed at a later time  CREATE TABLE new_table AS SELECT select_list FROM table_source [WHERE search_condition] [GROUP BY group_by_expression] [HAVING search_condition] [ORDER BY order_expression [ASC | DESC] ]  Example To do an annual report of sales: ◦ Create a staging table containing the sales of a month ◦ Each month update this staging table, by a script or a procedure ◦ At the end of year the staging table will contain all necessary data for the report, and the report we be very fast.

11  A denoramlized database is a way where you keeps redundant frequently-accessed data, duplicated across several tables, by grouping or partitioning data, making it possible to fulfill a user request without having to look at more than a single table.  Add some calculated field in tables  Add constraints to insure that the redundant copies of information are kept synchronized  speeding up reads (SELECT in SQL) while slowing down writes (INSERT, UPDATE, and DELETE).

12  Collection of associated values.  Normalization rules force repeating groups to be stored in an M table separate from an associated one table.  If a repeating group is always accessed with its associated parent table, denormalization may be a reasonable alternative.

13

14 This example design is for a mail order company that has 120,000,000 customers to whom they must send catalogs

15

16 Horizontal Partitioning

17 Vertical Partitioning

18  Add a calculated field in a table.  Example  We want to provide an annual report for companies which includes their outcomes  Our database includes the order data for 1000 companies.

19 OUTCOME


Download ppt "Dr. Djamal Ziani Professor Assistant King Saud University."

Similar presentations


Ads by Google