Indexing Consider a relational database that consists of the relational tables created by the following CREATE TABLE statements: CREATE TABLE PART( P_PARTKEY NUMBER(12) NOT NULL, P_NAME VARCHAR(55) NOT NULL, P_RETAILPRICE NUMBER(12,2) NOT NULL, CONSTRAINT PART_PEKEY PRIMARY KEY (P_PARTKEY) ); CREATE TABLE SUPPLIER( S_SUPPKEY NUMBER(12) NOT NULL, S_NAME CHAR(25) NOT NULL S_NATIONKEY NUMBER(12) NOT NULL, S_PHONE CHAR(15) NOT NULL, CONSTRAINT SUPPLIER_PKEY PRIMARY KEY (S_SUPPKEY) ); CREATE TABLE PARTSUPP( PS_PARTKEY NUMBER(12) NOT NULL, PS_SUPPKEY NUMBER(12) NOT NULL, PS_SUPPLYCOST NUMBER(12,2) NOT NULL, CONSTRAINT PARTSUPP_PKEY PRIMARY KEY (PS_PARTKEY, PS_SUPPKEY), CONSTRAINT PARTSUPP_FKEY1 FOREIGN KEY (PS_PARTKEY) REFERENCES PART(P_PARTKEY), CONSTRAINT PARTSUPP_FKEY2 FOREIGN KEY (PS_SUPPKEY) REFERENCES SUPPLIER(S_SUPPKEY) ); Determine what index should be created to improve the performance of the queries listed below in the best possible way. Consider each one of the queries as an individual case. If you decide that an index should be created, then list the names of attributes that form an index key. Remember that the order of attributes in an index key is important. If you decide not to create an index explain why the performance will not suffer when a new index is not available. Assume that all relational tables are large enough to make full tables scan more time consuming that accessing the tables through an index. i) SELECT * FROM PART WHERE P_NAME = 'MOTHER-BOARD' AND P_RETAILPRICE = 250; ii) SELECT COUNT(*) FROM PART WHERE P_NAME= 'COOLING-FAN'; iii) SELECT PS_SUPPKEY FROM PARTSUPP WHERE PS_PARTKEY = 'MOTHER-BOARD'; v) SELECT S_NAME FROM SUPPLIER; vi) SELECT PS_PARKEY,COUNT(*) FROM PARTSUPP GROUP BY PS_PARTKEY HAVING COUNT(*) >3;
Indexing
Consider a relational
CREATE TABLE PART(
P_PARTKEY NUMBER(12) NOT NULL,
P_NAME VARCHAR(55) NOT NULL,
P_RETAILPRICE NUMBER(12,2) NOT NULL,
CONSTRAINT PART_PEKEY PRIMARY KEY (P_PARTKEY) );
CREATE TABLE SUPPLIER(
S_SUPPKEY NUMBER(12) NOT NULL,
S_NAME CHAR(25) NOT NULL
S_NATIONKEY NUMBER(12) NOT NULL,
S_PHONE CHAR(15) NOT NULL,
CONSTRAINT SUPPLIER_PKEY PRIMARY KEY (S_SUPPKEY) );
CREATE TABLE PARTSUPP(
PS_PARTKEY NUMBER(12) NOT NULL,
PS_SUPPKEY NUMBER(12) NOT NULL,
PS_SUPPLYCOST NUMBER(12,2) NOT NULL,
CONSTRAINT PARTSUPP_PKEY PRIMARY KEY (PS_PARTKEY, PS_SUPPKEY), CONSTRAINT PARTSUPP_FKEY1 FOREIGN KEY (PS_PARTKEY) REFERENCES PART(P_PARTKEY),
CONSTRAINT PARTSUPP_FKEY2 FOREIGN KEY (PS_SUPPKEY) REFERENCES SUPPLIER(S_SUPPKEY) );
Determine what index should be created to improve the performance of the queries listed below in the best possible way. Consider each one of the queries as an individual case. If you decide that an index should be created, then list the names of attributes that form an index key. Remember that the order of attributes in an index key is important. If you decide not to create an index explain why the performance will not suffer when a new index is not available. Assume that all relational tables are large enough to make full tables scan more time consuming that accessing the tables through an index.
i) SELECT * FROM PART WHERE P_NAME = 'MOTHER-BOARD' AND P_RETAILPRICE = 250;
ii) SELECT COUNT(*) FROM PART WHERE P_NAME= 'COOLING-FAN';
iii) SELECT PS_SUPPKEY FROM PARTSUPP WHERE PS_PARTKEY = 'MOTHER-BOARD';
v) SELECT S_NAME FROM SUPPLIER;
vi) SELECT PS_PARKEY,COUNT(*) FROM PARTSUPP GROUP BY PS_PARTKEY HAVING COUNT(*) >3;
Subject: MySQL
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)