With my new need for SQL usage comes new questions. What are key differences to remember and complex concepts in MySQL? Here are ten of them for you to ask yourself and answer in the comments below.
- When would one decide to use CHAR over VARCHAR for a faster performance with more limited data entry?
- How would one make a clustered index in a table?
- How do normalization and denormalization differ?
- What are triggers most commonly used for?
- Using sample database sakila, write a subquery to display information for an actor and all of the films that actor had been in.
- Explain constraints.
- List at least three different SQL constraints.
- How can you select unique records from a table?
- What is a stored procedure and how is it used?
- Which function can be used to replace specific parts of a string?
Here are my answers!
- Using fixed data in a column/attribute such as a Social Security number. After all, there are no SSN(s) holding more or less than 9 digits.
- A clustered index defines data order and is normally made by making a primary key as there can only be one of both. This new clustered index of unique numbered rows makes searching for data by rows much easier.
- Both different processes, normalization creates duplicates from existing overlapping data groups while denormalization removes those duplicates, making these data groups irregular in size, but not duplicated.
- Triggers are most commonly used to run when “triggered” by particular events such as when a statement inserts, updates, or deletes rows in the associated table.
- select * from film_actor where actor_id = (select actor_id from actor where last_name = ‘wahlberg’);
- Constraints are used to specify the limit on the data type of columns or the table. UNIQUE for example is a constraint that forbids duplicate data in any column.
- SQL constraints are: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK, DEFAULT
- You can select unique records from a table by using the DISTINCT clause.
- A stored procedure is a written routine in a database to be called upon and perform a list of commands. Handy for running multiple commands at once.
- The replace function. Syntax: REPLACE (string_expression, search_string, replacement_string)
These questions had been inspired from this article on Edureka.