Join Brad Wheeler for an in-depth discussion in this video CRUD operations, part of Database Clinic: MySQL.
- The next task involves basic data manipulation. CRUD is an acronym that stands for Create, Read, Update, and Delete. These are all basic operations that can be performed with most databases. Create refers to the creation of a new table or record. SQL refers to this as either CREATE to create a table, or INSERT to create new records inside a table. Read means to retrieve information from a database.
SQL uses the SELECT command. Update is a change to an existing record or table. SQL uses the UPDATE command. Finally, delete refers to removing a record from a table. SQL uses the DELETE command. This challenge will demonstrate how to perform CRUD operations on a range of databases. There are several tasks that our instructor will perform. I've provided them with the text of Shakespeare's Midsummer Night's Dream, plus a list of characters in the play.
Using those two data sets, the instructor will have to accomplish the following tasks. The first three tasks will execute concurrently. For each line in the text, create a corresponding record in the database. Each record will include the name of the character speaking, the absolute line number of the phrase, and the phrase itself, trimmed of any leading or following spaces. Then, for each record in the database, search for character names, convert them to uppercase, then update the record in the database.
For each record in the database, the instructor will also need to delete any lines that start with enter, exit, act, or scene. When all of their tasks are complete, the next step will be to read each line and print it out to the console. This task is not concurrent. During execution, the instructor will store performance data, and then create a table showing the average time for each operation. When you understand CRUD, you'll have a framework to understand any database.
No matter what language a database uses or how it stores data, it still has to satisfy these four operations. CRUD is one of those essential toolkits every programmer and administrator needs to understand. Let's take a look at how it works with this database.
- Strengths and weaknesses of MySQL
- Creating a database
- Joining data sets
- Integrating Python with MySQL
- Searching a database
- CRUD operations
- Performing calculations