APPENDIX

image

This appendix contains a consolidated list of the references used in this book along with the description of the sample database used in the examples.

Bibliography

The following bibliography contains additional sources of interesting articles and papers. The bibliography is arranged by topic.

Database Theory

  • A. Belussi, E. Bertino, and B. Catania. An Extended Algebra for Constraint Databases (IEEE Transactions on Knowledge and Data Engineering 10.5 (1998): 686–705).
  • C. J. Date and H. Darwen. Foundation for Future Database Systems: The Third Manifesto. (Reading: Addison-Wesley, 2000).
  • C. J. Date. The Database Relational Model: A Retrospective Review and Analysis. (Reading: Addison-Wesley, 2001).
  • R. Elmasri and S. B. Navathe. Fundamentals of Database Systems. 4th ed. (Boston: Addison-Wesley, 2003).
  • M. J. Franklin, B. T. Jonsson, and D. Kossmann. Performance Tradeoffs for Client–server Query Processing (Proceedings of the 1996 ACM SIGMOD International Conference on Management of Data Montreal, Canada 1996. 149–160).
  • P. Gassner, G. M. Lohman, K. B. Schiefer, and Y. Wang. Query Optimization in the IBM DB2 Family (Bulletin of the Technical Committee on Data Engineering 16.4 (1993): 4–17).
  • Y. E. Ioannidis, R. T. Ng, K. Shim, and T. Sellis. Parametric query optimization (VLDB Journal 6 (1997):132–151).
  • D. Kossman, and K. Stocker. Iterative Dynamic Programming: A New Class of Query Optimization Algorithms (ACM Transactions on Database Systems 25.1 (2000): 43–82).
  • C. Lee, C. Shih, and Y. Chen. A graph-theoretic model for optimizing queries involving methods. (VLDB Journal 9 (2001):327–343).
  • P. G. Selinger, M. M. Astraham, D. D. Chamberlin, R. A. Lories, and T. G. Price. Access Path Selection in a Relational Database Management System (Proceedings of the ACM SIGMOD International Conference on the Management of Data. Aberdeen, Scotland: 1979. 23–34).
  • M. Stonebraker, E. Wong, P. Kreps. The Design and Implementation of INGRES (ACM Transactions on Database Systems 1.3 (1976): 189–222).
  • M. Stonebraker and J. L. Hellerstein. Readings in Database Systems 3rd edition, Michael Stonebraker ed.,  (Morgan Kaufmann Publishers, 1998).
  • A. B. Tucker. Computer Science Handbook. 2nd ed. (Boca Raton, Florida: CRC Press LLCC, 2004).
  • Brian Werne. Inside the SQL Query Optimizer (Progress Worldwide Exchange 2001, Washington D.C. 2001) http://www.peg.com/techpapers/2001Conf/

General

  • D. Rosenberg, M. Stephens, M. Collins-Cope. Agile Development with ICONIX Process, (Berkeley, CA: Apress, 2005).

MySQL

  • Robert A. Burgelman, Andrew S. Grove, Philip E. Meza, Strategic Dynamics. (New York: McGraw-Hill, 2006).
  • M. Kruckenberg and J. Pipes. Pro MySQL, (Berkeley, CA: Apress, 2005).

Open Source

  • Paulson, James W. “An Empirical Study of Open-Source and Closed-Source Software Products” IEEE Transactions on Software Engineering, Vol.30, No.5 April 2004.

Websites

Sample Database

The following sample database is used in the later chapters of this text. The following listing shows the SQL dump of the database.

Listing A-1. Sample Database Create Statements

-- MySQL dump 10.10
--
-- Host: localhost    Database: expert_mysql
-- ------------------------------------------------------
-- Server version       5.1.9-beta-debug-DBXP 1.0

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
*/;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

CREATE DATABASE IF NOT EXISTS expert_mysql;

--
-- Table structure for table 'expert_mysql'.'building'
--

DROP TABLE IF EXISTS 'expert_mysql'.'building';
CREATE TABLE 'expert_mysql'.'building' (
  'dir_code' char(4) NOT NULL,
  'building' char(6) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table 'expert_mysql'.'building'
--

 
/*!40000 ALTER TABLE 'expert_mysql'.'building' DISABLE KEYS */;
LOCK TABLES 'expert_mysql'.'building' WRITE;
INSERT INTO 'expert_mysql'.'building' VALUES
('N41','1300'),
('N01','1453'),
('M00','1000'),
('N41','1301'),
('N41','1305'),
UNLOCK TABLES;
/*!40000 ALTER TABLE 'expert_mysql'.'building' ENABLE KEYS */;

--
-- Table structure for table 'expert_mysql'.'directorate'
--

DROP TABLE IF EXISTS 'expert_mysql'.'directorate';
CREATE TABLE 'expert_mysql'.'directorate' (
  'dir_code' char(4) NOT NULL,
  'dir_name' char(30) DEFAULT NULL,
  'dir_head_id' char(9) DEFAULT NULL,
  PRIMARY KEY ('dir_code')
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table 'expert_mysql'.'directorate'
--

 
/*!40000 ALTER TABLE 'expert_mysql'.'directorate' DISABLE KEYS */;
LOCK TABLES 'expert_mysql'.'directorate' WRITE;
INSERT INTO 'expert_mysql'.'directorate' VALUES
('N41','Development','333445555'),
('N01','Human Resources','123654321'),
('M00','Management','333444444'),
UNLOCK TABLES;
/*!40000 ALTER TABLE 'directorate' ENABLE KEYS */;

--
-- Table structure for table 'expert_mysql'.'staff'
--

DROP TABLE IF EXISTS 'expert_mysql'.'staff';
CREATE TABLE 'expert_mysql'.'staff' (
  'id' char(9) NOT NULL,
  'first_name' char(20) DEFAULT NULL,
  'mid_name' char(20) DEFAULT NULL,
  'last_name' char(30) DEFAULT NULL,
  'sex' char(1) DEFAULT NULL,
  'salary' int(11) DEFAULT NULL,
  'mgr_id' char(9) DEFAULT NULL,
  PRIMARY KEY ('id')
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table 'expert_mysql'.'staff'
--

 
/*!40000 ALTER TABLE 'expert_mysql'.'staff' DISABLE KEYS */;
LOCK TABLES 'expert_mysql'.'staff' WRITE;
INSERT INTO 'expert_mysql'.'staff' VALUES
('333445555','John','Q','Smith','M',30000,'333444444'),
('123763153','William','E','Walters','M',25000,'123654321'),
('333444444','Alicia','F','St.Cruz','F',25000,NULL),
('921312388','Goy','X','Hong','F',40000,'123654321'),
('800122337','Rajesh','G','Kardakarna','M',38000,'333445555'),
('820123637','Monty','C','Smythe','M',38000,'333445555'),
('830132335','Richard','E','Jones','M',38000,'333445555'),
('333445665','Edward','E','Engles','M',25000,'333445555'),
('123654321','Beware','D','Borg','F',55000,'333444444'),
('123456789','Wilma','N','Maxima','F',43000,'333445555'),
UNLOCK TABLES;
/*!40000 ALTER TABLE 'expert_mysql'.'staff' ENABLE KEYS */;

--
-- Table structure for table 'tasking'
--

DROP TABLE IF EXISTS 'expert_mysql'.'tasking';
CREATE TABLE 'expert_mysql'.'tasking' (
  'id' char(9) NOT NULL,
  'project_number' char(9) NOT NULL,
  'hours_worked' double DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table 'tasking'
--

 
/*!40000 ALTER TABLE 'tasking' DISABLE KEYS */;
LOCK TABLES 'expert_mysql'.'tasking' WRITE;
INSERT INTO 'expert_mysql'.'tasking' VALUES
('333445555','405',23),
('123763153','405',33.5),
('921312388','601',44),
('800122337','300',13),
('820123637','300',9.5),
('830132335','401',8.5),
('333445555','300',11),
('921312388','500',13),
('800122337','300',44),
('820123637','401',500.5),
('830132335','400',12),
('333445665','600',300.25),
('123654321','607',444.75),
('123456789','300',1000);
UNLOCK TABLES;
/*!40000 ALTER TABLE 'expert_mysql'.'tasking' ENABLE KEYS */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

# Source on localhost: ... connected.

# Exporting metadata from bvm

DROP DATABASE IF EXISTS bvm;

CREATE DATABASE bvm;

USE bvm;

# TABLE: bvm.books

CREATE TABLE 'books' (

  'ISBN' varchar(15) DEFAULT NULL,

  'Title' varchar(125) DEFAULT NULL,

  'Authors' varchar(100) DEFAULT NULL,

  'Quantity' int(11) DEFAULT NULL,

  'Slot' int(11) DEFAULT NULL,

  'Thumbnail' varchar(100) DEFAULT NULL,

  'Description' text,

  'Pages' int(11) DEFAULT NULL,

  'Price' double DEFAULT NULL,

  'PubDate' date DEFAULT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

# TABLE: bvm.settings

CREATE TABLE 'settings' (

  'FieldName' char(30) DEFAULT NULL,

  'Value' char(250) DEFAULT NULL

) ENGINE=MyISAM DEFAULT CHARSET=latin1;

#...done.

USE bvm;

# Exporting data from bvm

# Data for table bvm.books:

INSERT INTO bvm.books VALUES (978–1590595053, 'Pro MySQL', 'Michael Kruckenberg, Jay Pipes and Brian
Aker', 5, 1, 'bcs01.gif', NULL, 798, 49.99, '2005-07-15'),


INSERT INTO bvm.books VALUES (978–1590593325, 'Beginning MySQL Database Design and Optimization',
'Chad Russell and Jon Stephens', 6, 2, 'bcs02.gif', NULL, 520, 44.99, '2004-10-28'),


INSERT INTO bvm.books VALUES (978–1893115514, 'PHP and MySQL 5', 'W. Jason Gilmore', 4, 3, 'bcs03.gif',
NULL, 800, 39.99, '2004-06-21'),


INSERT INTO bvm.books VALUES (978–1590593929, 'Beginning PHP 5 and MySQL E-Commerce', 'Cristian
Darie and Mihai Bucica', 5, 4, 'bcs04.gif', NULL, 707, 46.99, '2008-02-21'),


INSERT INTO bvm.books VALUES (978–1590595091, 'PHP 5 Recipes', 'Frank M. Kromann, Jon Stephens,
Nathan A. Good and Lee Babin', 8, 5, 'bcs05.gif', NULL, 672, 44.99, '2005-10-04'),


INSERT INTO bvm.books VALUES (978–1430227939, 'Beginning Perl', 'James Lee', 3, 6, 'bcs06.gif',
NULL, 464, 39.99, '2010-04-14'),


INSERT INTO bvm.books VALUES (978–1590595350, 'The Definitive Guide to MySQL 5', 'Michael Kofler',
2, 7, 'bcs07.gif', NULL, 784, 49.99, '2005-10-04'),


INSERT INTO bvm.books VALUES (978–1590595626, 'Building Online Communities with Drupal, phpBB, and
WordPress', 'Robert T. Douglass, Mike Little and Jared W. Smith', 1, 8, 'bcs08.gif', NULL, 560, 49.99, '2005-12-16'),


INSERT INTO bvm.books VALUES (978–1590595084, 'Pro PHP Security', 'Chris Snyder and Michael
Southwell', 7, 9, 'bcs09.gif', NULL, 528, 44.99, '2005-09-08'),


INSERT INTO bvm.books VALUES (978–1590595312, 'Beginning Perl Web Development', 'Steve Suehring',
8, 10, 'bcs10.gif', NULL, 376, 39.99, '2005-11-07'),


# Blob data for table books:

UPDATE bvm.books SET 'Description' = "Pro MySQL is the first book that exclusively covers
intermediate and advanced features of MySQL, the world's most popular open source database server.
Whether you are a seasoned MySQL user looking to take your skills to the next level, or youre a
database expert searching for a fast-paced introduction to MySQL's advanced features, this book is
for you." WHERE 'ISBN' = 978–1590595053;


UPDATE bvm.books SET 'Description' = "Beginning MySQL Database Design and Optimization shows you
how to identify, overcome, and avoid gross inefficiencies. It demonstrates how to maximize the many
data manipulation features that MySQL includes. This book explains how to include tests and branches
in your queries, how to normalize your database, and how to issue concurrent queries to boost
performance, among many other design and optimization topics. You'll also learn about some features
new to MySQL 4.1 and 5.0 like subqueries, stored procedures, and views, all of which will help you
build even more efficient applications." WHERE 'ISBN' = 978–1590593325;


UPDATE bvm.books SET 'Description' = "Beginning PHP 5 and MySQL: From Novice to Professional offers
a comprehensive introduction to two of the most popular open-source technologies on the planet: the
PHP scripting language and the MySQL database server. You are not only exposed to the core features
of both technologies, but will also gain valuable insight into how they are used in unison to create
dynamic data-driven web applications, not to mention learn about many of the undocumented features
of the most recent versions." WHERE 'ISBN' = 978–1893115514;


UPDATE bvm.books SET 'Description' = "Beginning PHP 5 E-Commerce: From Novice to Professional is
an ideal reference for intermediate PHP 5 and MySQL developers, and programmers familiar with web
development technologies. This book covers every step of the design and build process, and provides
rich examples that will enable you to build high-quality, extendable e-commerce websites." WHERE
'ISBN' = 978–1590593929;


UPDATE bvm.books SET 'Description' = "We are confident PHP 5 Recipes will be a useful and welcome
companion throughout your PHP journey, keeping you on the cutting edge of PHP development, ahead
of the competition, and giving you all the answers you need, when you need them." WHERE 'ISBN' =
978–1590595091;


UPDATE bvm.books SET 'Description' = "This is a book for those of us who believed that we didn't
need to learn Perl, and now we know it is more ubiquitous than ever. Perl is extremely flexible and
powerful, and it isn't afraid of Web 2.0 or the cloud. Originally touted as the duct tape of the
Internet, Perl has since evolved into a multipurpose, multiplatform language present absolutely
everywhere: heavy-duty web applications, the cloud, systems administration, natural language
processing, and financial engineering. Beginning Perl, Third Edition provides valuable insight into
Perl's role regarding all of these tasks and more." WHERE 'ISBN' = 978–1430227939;


UPDATE bvm.books SET 'Description' = "This is the first book to offer in-depth instruction about the
new features of the world's most popular open source database server. Updated to reflect changes
in MySQL version 5, this book will expose you to MySQL's impressive array of new features: views,
stored procedures, triggers, and spatial data types." WHERE 'ISBN' = 978–1590595350;


UPDATE bvm.books SET 'Description' = "Building Online Communities with Drupal, phpBB, and Wordpress
is authored by a team of experts. Robert T. Douglass created the Drupal-powered blog site NowPublic.com.
Mike Little is a founder and contributing developer of the WordPress project. And Jared W. Smith has
been a longtime support team member of phpBBHacks.com and has been building sites with phpBB since
the first beta releases." WHERE 'ISBN' = 978–1590595626;


UPDATE bvm.books SET 'Description' = "Pro PHP Security is one of the first books devoted solely
to PHP security. It will serve as your complete guide for taking defensive and proactive security
measures within your PHP applications. The methods discussed are compatible with PHP versions 3, 4,
and 5." WHERE 'ISBN' = 978–1590595084;


UPDATE bvm.books SET 'Description' = "Beginning Perl Web Development: From Novice to Professional
introduces you to the world of Perl Internet application development. This book tackles all areas
crucial to developing your first web applications and includes a powerful combination of real-world
examples coupled with advice. Topics range from serving and consuming RSS feeds, to monitoring
Internet servers, to interfacing with e-mail. You'll learn how to use Perl with ancillary packages
like Mason and Nagios." WHERE 'ISBN' = 978–1590595312;


# Data for table bvm.settings:

INSERT INTO bvm.settings VALUES ('ImagePath', 'c://mysql_embedded//images//'),

#...done.

Chapter Exercise Notes

This section contains some hints and helpful direction for the exercises included in Chapters 12, 13, and 14. Some of the exercises are practical exercises whereby the solutions would be too long to include in an appendix. For those exercises that require programming to solve I include some hints as to how to write the code for the solution. In other cases, I include additional information that should assist you in completing the exercise.

Chapter 12

The following questions are from Chapter 12, “Internal Query Representation.”

Question 1. The query in figure 12-1 exposes a design flaw in one of the tables. What is it? Does the flaw violate any of the normal forms? If so, which one?

Look at the semester attribute. How many values does the data represent? Packing data like this makes for some really poor performing queries if you need to access part of the attribute (field). For example, to query for all of the semesters in 2001, you would have to use a WHERE clause and use the LIKE operator: WHERE semester LIKE '%2001'. This practice of packing fields (also called multi-valued fields) violates First Normal Form.

Question 2. Explore the TABLE structure and change the SELECT DBXP stub to return information about the table and its fields

Change the code to return information like we did in Chapter 8 when we explored the show_disk_usage_command() method. Only this time, include the metadata about the table. Hint: see the table class.

Question 3. Change the EXPLAIN SELECT DBXP command to produce an output similar to the MySQL EXPLAIN SELECT command

Change the code to produce the information in a table like that of the MySQL EXPLAIN command. Note that you will need additional methods in the Query_tree class to gather information about the optimized query.

Question 4. Modify the build_query_tree function to identify and process the LIMIT clause

The changes to the code require you to identify when a query has the LIMIT clause and to abbreviate the results accordingly. By way of a hint, here is the code to capture the value of the LIMIT clause. You will need to modify the code in the DBXP_select_command() method to handle the rest of the operation.

SELECT_LEX_UNIT *unit= &lex->unit;
unit->set_limit(unit->global_parameters);

Question 5. How can the query tree query_node structure be changed to accommodate HAVING, GROUP BY, and ORDER clauses?

The best design is one that stays true to the query tree concept. That is, consider a design where each of these clauses is a separate node in the tree. Consider also if there are any heuristics that may apply to these operations. Hint: would it not be more efficient to process the HAVING clause nearest the leaf nodes? Lastly, consider rules that govern how many of each of these nodes can exist in the tree.

Chapter 13

The following questions are from Chapter 13, “Query Optimization.”

Question 1. Complete the code for the balance_joins() method. Hints: you will need to create an algorithm that can move conjunctive joins around so that the join that is most restrictive is executed first (is lowest in the tree)

This exercise is all about how to move joins around in the tree to push the most restrictive joins down. The tricky part is using the statistics of the tables to determine which joins will produce the fewest results. Look to the handler and table classes for information about accessing this data. Beyond that, you will need helper methods to traverse the tree and get information about the tables. This is necessary because it is possible (and likely) that the joins will be higher in the tree and may not contain direct reference to the table.

Question 2. Complete the code for the cost_optimization() method. Hints: you will need to walk the tree and indicate nodes that can use indexes

This exercise requires you to interrogate the handler and table classes to determine which tables have indexes and what those columns are.

Question 3. Examine the code for the heuristic optimizer. Does it cover all possible queries? If not, are there any other rules (heuristics) that can be used to complete the coverage?

You should discover that there are many such heuristics and that this optimizer covers only the most effective of the heuristics. For example, you could implement heuristics that take into account the GROUP BY and HAVING operations treating them in a similar fashion as project or restrict pushing the nodes down the tree for greater optimization.

Question 4. Examine the code for the query tree and heuristic optimizer. How can you implement the distinct node type as listed in the query tree class? Hint: see the code that follows the prune_tree() method in the heuristic_optimization() method

Most of the hints for this exercise are in the sample code. The following excerpt shows how you can identify when a DISTINCT option is specified on the query.

Question 5. How can you change the code to recognize invalid queries? What are the conditions that determine a query is invalid and how would you test for them?

Part of the solution for this exercise is done for you. For example, a query statement that is syntactically incorrect will be detected by the parser and an appropriate error displayed. However, for those queries that are syntactically correct by semantically meaningless, you will need to add additional error handling code to detect. Try a query that is syntactically correct but references the wrong fields for a query. Create tests of this nature and trace (debug) the code as you do. You should see places in the code where additional error handling can be placed. Lastly, you could also create a method in the Query_tree class that validates the query tree itself. This could be particularly handy if you attempt to create additional node types or implement other heuristic methods.

Question 6. (advanced) MySQL does not currently support the INTERSECT operation (as defined by Date). Change the MySQL parser to recognize the new keyword and process queries like SELECT * FROM A INTERSECT B. Are there any limitations of this operation and are they reflected in the optimizer?

What sounds like a very difficult problem has a very straight-forward solution. Consider adding a new node type named “intersect” that has two children. The operation merely returns those rows that are in both tables. Hint: use one of the many merge sort variants to accomplish this.

Question 7. (advanced) How would you implement the GROUP BY, ORDER BY, and HAVING clauses? Make the changes to the optimizer to enable these clauses.

There are many ways to accomplish this. In keeping with the design of the Query_tree class, each of these operations can be represented as another node type. You can build a method to handle each of these just as we did with restrict, project, and join. Note however that the HAVING clause is used with the GROUP BY clause and the ORDER BY clause is usually processed last.

Chapter 14

The following questions are from Chapter 14, “Query Execution.”

Question 1. Complete the code for the do_join() method to support all of the join types supported in MySQL. Hint: you need to be able to identify the type of join before you begin optimization. Look to the parser for details

To complete this exercise, you may want to restructure the code in the do_join() method. The example I used keeps all of the code together, but a more elegant solution would be one where the select-case statement in the do_join() method called helper methods for each type of join and possibly other helper methods for common operations (i.e., see the preempt_pipeline code). The code for the other forms of joins is going to be very similar to the join implemented in the example code.

Question 2. Examine the code for the check_rewind() method in the Query_tree class. Change the implementation to use temporary tables to avoid high memory usage when joining large tables

This exercise also has a straight-forward solution. See the MySQL code in the sql_select.cc file for details on how to create a temporary table. Hint: it’s very much the same as create table and insert. You could also use the base Spartan classes and create a temporary table that stores the record buffers.

Question 3. Evaluate the performance of the DBXP query engine. Run multiple test runs and record execution times. Compare these results to the same queries using the native MySQL query engine. How does the DBXP engine compare to MySQL?

There are many ways to record execution time. You could use a simple stopwatch and record the time based on observation or you could add code that captures the system time. This later method is perhaps the quickest and most reliable way to determine relative speed. I say relative because there are many factors concerning the environment and what is running at the time of the execution that could affect performance. When you conduct your test runs, be sure to use multiple test runs and perform statistical analysis on the results. This will give you a normalized set of data to compare.

Question 4. Why is the remove duplicates operation not necessary for the intersect operation? Are there any conditions where this is false? If so, what are they?

Let us consider what an intersect operation is. It is simply the rows that appear in each of the tables involved (you can intersect on more than two tables). Duplicates in this case are not possible if the tables themselves do not have duplicates. However, if the tables are the result of operations performed in the tree below and have not had the duplicates removed and the DISTINCT operation is included in the query, you will need to remove duplicates. Basically, this is an “it depends” answer.

Question 5. (advanced) MySQL does not currently support a CROSS PRODUCT or INTERSECT operation (as defined by Date). Change the MySQL parser to recognize these new keywords and process queries like SELECT * FROM A CROSS B and SELECT * FROM A INTERSECT B and add these functions to the execution engine. Hint: see the do_join() method

The files you need to change are the same files we changed when adding the DBXP keyword. These include lex.h and sql_yacc.yy. You may need to extend the sql_lex structure to include provisions for recording the operation type.

Question 6. (advanced) Form a more complete list of test queries and examine the limitations of the DBXP engine. What modifications are necessary to broaden the capabilities of the DBXP engine?

First, the query tree should be expanded to include the HAVING, GROUP BY, and ORDER BY clauses. You should also consider adding the capabilities for processing aggregate functions. These aggregate functions (e.g., max(), min(), etc.) could be fit into the Expression class whereby new methods are created to parse and evaluate the aggregate functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.198.59