Please write a stored function named which will take two inputs (type, keyword). The keyword is a substring used to search the course name. You must use LIKE for the pattern match.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please write a stored function named which will take two inputs (type, keyword).
The keyword is a substring used to search the course name. You must use LIKE for the pattern match.

 If the type is not 1 or 2, return an error message “Please input a valid type.”
 If the keyword is empty or null, return an error message “Please input a valid keyword.”
 If there is no course name contains the keyword, return “No course found that contains keyword: zzz.” where zzz
is the input keyword.
 If type is 1, return all course ID: course name that course name contains the keyword.                                                   If type is 2, return all course ID: student ID who took the courses that course name contains the keyword.
 The return should be in one line and your report format must match the test cases.
 You need to use group_concat() function to merge multiple rows output into one line.

MariaDB
+
I sid
1001 I Austin
I 1002 I Mary
I 1003 I Claudia
1 1004 I Andrew
1 1005 I
Helen
I 1007 I Sarah
1
6 rows in set (0.010
+N
MariaDB [dreamhome]>
cid
+
dreamhome]>
1
1
1
1
I first_name
1
1
1
1
+
--
14
———
-+——
▬▬▬▬▬▬▬▬▬▬
+-
————
7 rows in set (0.014
MariaDB [dreamhome]>
I sid
+
name
CPS1231
CPS2231
1 CPS2232
1 CPS3500
I CPS3740
CPS5920 1 Database Systems
CPS5921 I Data Mining
Java1
Java2
| cid
——
Select *
I
I
I last_name
I
I
I
Huang
Smith
--+
Lee
Lin
Wu
Lee
sec)
Data Structure
Web Programming
Select *
————
Database Introductio
sec)
———+
I
1001 I CPS2231 1
1003 I CPS2231 I 2015 I
1004 T CPS2231 1 2014 T
1001 1 CPS2232 1 2016 T
1004 1 CPS2232 1 2014 1
1005 I CPS2231 I
1007 I
2016 I
CPS2231 1 2015
CPS5920 I
2016 I
1003 I
1007 I
1003
1001 I
1003 I
CPS3740 I 2014 1
CPS5921 I 2016 I
CPS3500 I 2017 |
CPS2231 I 2014 |
CPS2232 I 2014 I
1004 I
1004 I CPS2231 | 2013 | Fal1
from Students;
2013 I Fall
---
rows in set (0.001 sec)
-+
Fal1
Fall
from
I
Spring
Spring
Fall
Spring
Spring
Spring
Fall
Fall
Spring
Spring
I birthday
I
I
1990-01-01 I CS
1976-02-08 I IT
1987-03-21
1947-08-25 I
1997-01-25 I CS
1995-09-15 I
IT
-
Courses;
——————
credits I
4 I
--+--
+
year I semester I grade I
Select * from Students_Courses;
T
I
I
+43333
<< < ÖÖ « »u<Õ ÛÛÛ
4 1
I
| C
I
major
Math
1
I
Biology 1
zipcode
07123
08348
91384
07101
I 07083
1
04101
————
I
Transcribed Image Text:MariaDB + I sid 1001 I Austin I 1002 I Mary I 1003 I Claudia 1 1004 I Andrew 1 1005 I Helen I 1007 I Sarah 1 6 rows in set (0.010 +N MariaDB [dreamhome]> cid + dreamhome]> 1 1 1 1 I first_name 1 1 1 1 + -- 14 ——— -+—— ▬▬▬▬▬▬▬▬▬▬ +- ———— 7 rows in set (0.014 MariaDB [dreamhome]> I sid + name CPS1231 CPS2231 1 CPS2232 1 CPS3500 I CPS3740 CPS5920 1 Database Systems CPS5921 I Data Mining Java1 Java2 | cid —— Select * I I I last_name I I I Huang Smith --+ Lee Lin Wu Lee sec) Data Structure Web Programming Select * ———— Database Introductio sec) ———+ I 1001 I CPS2231 1 1003 I CPS2231 I 2015 I 1004 T CPS2231 1 2014 T 1001 1 CPS2232 1 2016 T 1004 1 CPS2232 1 2014 1 1005 I CPS2231 I 1007 I 2016 I CPS2231 1 2015 CPS5920 I 2016 I 1003 I 1007 I 1003 1001 I 1003 I CPS3740 I 2014 1 CPS5921 I 2016 I CPS3500 I 2017 | CPS2231 I 2014 | CPS2232 I 2014 I 1004 I 1004 I CPS2231 | 2013 | Fal1 from Students; 2013 I Fall --- rows in set (0.001 sec) -+ Fal1 Fall from I Spring Spring Fall Spring Spring Spring Fall Fall Spring Spring I birthday I I 1990-01-01 I CS 1976-02-08 I IT 1987-03-21 1947-08-25 I 1997-01-25 I CS 1995-09-15 I IT - Courses; —————— credits I 4 I --+-- + year I semester I grade I Select * from Students_Courses; T I I +43333 << < ÖÖ « »u<Õ ÛÛÛ 4 1 I | C I major Math 1 I Biology 1 zipcode 07123 08348 91384 07101 I 07083 1 04101 ———— I
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education