Skip to content
Sign in

Mysql Developer Interview Practice & Warmup for Tahoua

See an example

Practise 40 Mysql Developer interview questions one at a time: answer out loud, compare with the model answer, and mark the ones to practise again. Your progress is saved to your account.

Try it now — to save your work to your account (and see it in the Expertini app), create a free account or sign in.

40 questions for Mysql Developer

40Questions in this set
0Practised
0Got it
0To practise again
Question 1 of 40
General

What are your career goals as a MySQL Developer, and how do you see this role aligning with them?

Answer out loud first — then compare.

How did you do?

Write your answer — get AI feedback

40 Mysql Developer interview questions and answers

Open a question to read a model answer. Treat it as a guide — your own examples will always land better.

1What are your career goals as a MySQL Developer, and how do you see this role aligning with them?
GeneralEasy

My primary career goal is to evolve from a developer who uses databases to a specialist who masters database design, performance, and architecture. I'm particularly interested in large-scale, high-traffic systems. This role at your company aligns perfectly with my goals because it involves working on complex database schemas, optimizing queries for high concurrency, and potentially contributing to database-as-a-service initiatives. I'm eager to tackle challenges that will hone my skills in query optimization, data modeling, and replication, which are all key stepping stones toward an architect-level position. I also hope to contribute to a culture of continuous learning and share my knowledge with the team.

2How do you stay informed about new features and best practices in MySQL and the broader database industry?
GeneralEasy

I have a multi-faceted approach to staying current. I regularly follow key blogs from the MySQL community, such as the Percona and Planet MySQL blogs. I subscribe to newsletters from database-focused companies and influencers. I also make it a point to attend virtual conferences and meetups, like the FOSDEM MySQL track or local user groups, whenever possible. Finally, I dedicate personal time to experimenting with new features and versions, for example, testing the performance improvements of MySQL 8.0's common table expressions (CTEs) or the new data dictionary.

3Describe a project where you had to collaborate with a non-technical stakeholder to understand their data requirements. How did you handle the communication?
GeneralMedium

SITUATION: We were building a new analytics dashboard for the marketing team. The lead marketer, who had little technical background, was requesting a complex report that would run on demand. TASK: My role was to translate their business needs into a clear, efficient database schema and a performant query, without overwhelming them with technical jargon. I needed to explain why certain data points were expensive to retrieve and propose a more efficient solution. ACTION: I started by asking open-ended questions about their goals, not just their data requests. I used an analogy, comparing our database to a library's catalog system, to explain how we could retrieve information faster by organizing it correctly. I sketched out a simple diagram on a whiteboard to visualize the data flow. I also created a small prototype with a limited data set to show them the difference in query speed between their initial request and my optimized proposal. RESULT: The marketer understood the trade-offs and agreed to a slightly modified report that was significantly faster and more scalable. This collaborative approach built trust and resulted in a solution that met their needs while adhering to our performance standards.

4What is your approach to salary negotiation, and what are your expectations for this role?
GeneralMedium

I've conducted thorough research on the market rate for a MySQL Developer with my experience level and skill set in this location. I understand that compensation is a blend of base salary, benefits, and company culture. I'm looking for a compensation package that is fair and competitive, reflecting the value I'll bring to the team in database design, optimization, and maintenance. My research indicates a range between X and Y for a role of this seniority. While I am open to discussion, I am confident that my skills and experience align with the top end of this range. I'm also very interested in the company's long-term growth and professional development opportunities, as these are equally important to me.

5Why are you interested in this company specifically, and how do you see yourself contributing to our company culture?
GeneralEasy

I'm drawn to your company for two main reasons: the nature of your product and your reputation for technical excellence. Your platform tackles complex data problems at scale, which is precisely the kind of challenge I'm passionate about. I've also heard great things about your engineering culture—the emphasis on clean code, robust architecture, and a collaborative environment. I believe I can contribute significantly by bringing my expertise in writing efficient, scalable SQL, and my experience in optimizing databases for high-traffic applications. I also look forward to sharing knowledge and learning from the rest of the team. I'm a firm believer that great code is a team effort, and I'm eager to contribute to a culture of mutual respect and continuous improvement.

6Explain the difference between MyISAM and InnoDB storage engines in MySQL. When would you choose one over the other?
TechnicalEasy

MyISAM and InnoDB are the two most common MySQL storage engines, each with distinct features. The key differences are: InnoDB supports transactions (ACID-compliant), while MyISAM does not. InnoDB has row-level locking, which allows for higher concurrency, whereas MyISAM uses table-level locking. InnoDB also provides foreign key support, ensuring referential integrity, which MyISAM lacks. Additionally, InnoDB includes crash recovery capabilities through a transaction log, making it much more reliable. MyISAM, on the other hand, is generally faster for read-heavy operations due to its simpler structure and no transactional overhead. Therefore, I would almost always choose InnoDB for any modern application that requires data integrity, concurrency, and transactional safety. MyISAM might be considered for a read-only or read-heavy application where transactional integrity is not a concern, such as a logging or reporting table, but even then, InnoDB's performance and features often make it the superior choice.

7How do you analyze and optimize a slow query in MySQL?
TechnicalMedium

My process for optimizing a slow query is systematic. First, I identify the slow queries, typically by using the slow query log or `Performance_Schema`. Once a specific query is targeted, I use the `EXPLAIN` command to get a detailed execution plan. The `EXPLAIN` output tells me if indexes are being used correctly, if a full table scan is happening, the join type, and the order of operations. Based on this analysis, I look for common issues like missing indexes, non-optimal join orders, or using functions on columns in the `WHERE` clause. I'll then create or modify indexes to cover the query's `WHERE` and `JOIN` conditions, and sometimes the columns in the `SELECT` clause to create a covering index. If the query is still slow, I might try to rewrite it, perhaps using a `JOIN` instead of a subquery or re-evaluating the table structure. Finally, after making a change, I re-run `EXPLAIN` and check the `Performance_Schema` or slow query log to confirm the improvement.

8What is normalization in database design, and what are its benefits? Can you explain the first three normal forms?
TechnicalMedium

Normalization is the process of organizing data in a database to reduce data redundancy and improve data integrity. Its primary benefits are minimizing data storage, avoiding data modification anomalies (insertion, update, and deletion), and making the database structure more flexible and easier to maintain. The first three normal forms are: 1. First Normal Form (1NF): Each column contains a single, atomic value. There are no repeating groups of data within rows. 2. Second Normal Form (2NF): It must be in 1NF, and all non-key attributes must be fully dependent on the primary key. This means no partial dependencies. 3. Third Normal Form (3NF): It must be in 2NF, and all non-key attributes must be free of transitive dependencies. This means a non-key attribute cannot be dependent on another non-key attribute. The goal is to move towards higher normal forms to improve data integrity, although sometimes a level of denormalization is acceptable for performance reasons, particularly in reporting or data warehousing.

9What are the different types of joins in SQL, and what is the difference between them?
TechnicalEasy

Joins are used to combine rows from two or more tables based on a related column between them. The main types are: 1. `INNER JOIN`: Returns only the rows where there is a match in both tables. It's the most common type. 2. `LEFT JOIN` (or `LEFT OUTER JOIN`): Returns all rows from the left table and the matched rows from the right table. The unmatched rows from the right table will have `NULL` values. 3. `RIGHT JOIN` (or `RIGHT OUTER JOIN`): Returns all rows from the right table and the matched rows from the left table. The unmatched rows from the left table will have `NULL` values. 4. `FULL JOIN` (or `FULL OUTER JOIN`): Returns all rows when there is a match in either the left or right table. It combines the results of both `LEFT` and `RIGHT` joins. MySQL does not have a native `FULL JOIN`, but it can be simulated using a `UNION` of a `LEFT JOIN` and a `RIGHT JOIN`. The choice of join depends entirely on the required output and the relationship between the tables.

10Explain the concept of an index in MySQL. How do you decide which columns to index?
TechnicalMedium

An index is a data structure, similar to an index in a book, that improves the speed of data retrieval operations on a database table. It does so by providing a quick lookup of rows based on the values in one or more columns, avoiding a full table scan. MySQL primarily uses B-tree indexes, which are efficient for a wide range of queries, including equality and range searches. I decide which columns to index based on a few key factors: 1. Columns used in `WHERE` clauses. 2. Columns used in `JOIN` conditions. 3. Columns used in `ORDER BY` or `GROUP BY` clauses. 4. I also consider creating composite (multi-column) indexes for queries that use multiple columns in their `WHERE` clause. However, it's important not to over-index, as indexes consume disk space and can slow down `INSERT`, `UPDATE`, and `DELETE` operations.

11What is the purpose of `stored procedures` and `functions` in MySQL? What are their key differences?
TechnicalMedium

Both stored procedures and functions are sets of pre-compiled SQL statements stored on the database server. Their main purpose is to reduce network traffic, improve performance by avoiding repeated parsing and compilation, and enhance security by encapsulating complex logic and granting execute permissions without giving direct table access. The key differences are: 1. A `FUNCTION` must return a single value, while a `STORED PROCEDURE` can return multiple values (via `OUT` parameters) or no value at all. 2. A `FUNCTION` can be called from within an SQL statement (e.g., in a `SELECT` clause), while a `STORED PROCEDURE` cannot. It must be called using `CALL`. 3. A `FUNCTION` cannot contain `INSERT`, `UPDATE`, or `DELETE` statements (unless it's a a specific type of procedure), while a `STORED PROCEDURE` can. 4. Error handling is generally more robust in stored procedures.

12How do you handle transactions in MySQL, and what are the ACID properties?
TechnicalMedium

I handle transactions in MySQL using `START TRANSACTION`, `COMMIT`, and `ROLLBACK` statements. A transaction is a single unit of work that either completes entirely or fails entirely. The ACID properties are the four main principles that guarantee data integrity within a transaction: 1. `Atomicity`: The transaction is treated as a single, indivisible unit. It either completes fully or is rolled back completely. 2. `Consistency`: The transaction must bring the database from one valid state to another. It ensures data integrity constraints are maintained. 3. `Isolation`: Concurrent transactions are isolated from each other. Changes made by one transaction are not visible to other transactions until the first transaction is committed. 4. `Durability`: Once a transaction is committed, its changes are permanent and will survive a system crash or power loss. InnoDB is the only MySQL storage engine that fully supports the ACID properties.

13Explain MySQL replication. What are its benefits and common types?
TechnicalHard

MySQL replication is the process of copying data from one MySQL database server (the 'master') to one or more other servers (the 'slaves'). The primary benefit is improved scalability, as read operations can be distributed across multiple slave servers, reducing the load on the master. It also provides a high-availability solution and a backup mechanism. The two main types are: 1. `Asynchronous Replication`: The master doesn't wait for the slave to acknowledge that it has received the data. This is the default and most common type, offering high performance but with the risk of data loss if the master fails before changes are replicated. 2. `Semi-Synchronous Replication`: The master waits for at least one slave to acknowledge receipt of the data before committing the transaction. This offers a balance between performance and durability. I would choose replication for applications with a high read-to-write ratio or for disaster recovery purposes.

14What is the difference between a `Primary Key` and a `Unique Key`?
TechnicalEasy

A `Primary Key` is a special `Unique Key`. A table can have only one `Primary Key`, which uniquely identifies each record in the table. It cannot contain `NULL` values. A `Unique Key`, on the other hand, can be applied to multiple columns in a table and can contain `NULL` values. A unique key simply enforces uniqueness for a column or set of columns, but it does not serve as the primary identifier for the row.

15How do `foreign keys` work, and why are they important?
TechnicalEasy

A `foreign key` is a field or collection of fields in one table that uniquely identifies a row in another table. It establishes a link between two tables, creating a parent-child relationship. Foreign keys are crucial for maintaining `referential integrity`, which ensures that the relationships between data are consistent and valid. For example, if you have a `products` table and an `orders` table, a foreign key in the `orders` table (e.g., `product_id`) would reference the primary key in the `products` table. This prevents you from creating an order for a product that doesn't exist. It also helps prevent accidental deletion of parent records that still have child records linked to them.

16What is the difference between `TRUNCATE`, `DELETE`, and `DROP` commands?
TechnicalMedium

`TRUNCATE`, `DELETE`, and `DROP` are all used to remove data, but they operate at different levels and have distinct behaviors. 1. `TRUNCATE` is a Data Definition Language (DDL) command that quickly removes all rows from a table by deallocating the table's data. It is fast because it doesn't log individual row deletions, and it cannot be rolled back. It resets auto-increment values. 2. `DELETE` is a Data Manipulation Language (DML) command that removes one or more rows from a table. It is slower than `TRUNCATE` as it logs each row deletion, but it is transactional and can be rolled back. It does not reset auto-increment values. 3. `DROP` is a DDL command that removes the entire table from the database, including the table structure, all data, indexes, and constraints. It cannot be rolled back. The choice depends on the specific need: `DELETE` for targeted row removal with rollback capability, `TRUNCATE` for a full, fast removal of all data from a table, and `DROP` to remove the table schema itself.

17When would you use a `subquery` versus a `JOIN`?
TechnicalMedium

Both subqueries and joins can be used to combine data from multiple tables, but they have different use cases and performance implications. A `JOIN` is generally preferred because it is often more efficient. The database engine is optimized to handle joins, and the query optimizer can use indexes to quickly combine rows. A `subquery` is a query nested inside another query. I would use a subquery when the nested query can be run independently and its result set is a simple list of values, for example, to find all users who have placed an order in the last month. However, complex or correlated subqueries can be very slow. In most cases where a `JOIN` can achieve the same result as a `subquery`, the `JOIN` should be used for better performance and readability.

18How do you handle pagination in MySQL efficiently for large datasets?
TechnicalHard

Pagination with `OFFSET` and `LIMIT` can be very inefficient for large datasets, especially with a high `OFFSET` value, because MySQL has to read and discard all the rows up to the offset before retrieving the limited set. A better approach is to use a `WHERE` clause on an indexed column to filter the results. For example, instead of `LIMIT 10 OFFSET 10000`, I would use `WHERE id > last_id_from_previous_page ORDER BY id ASC LIMIT 10`. This method uses the index on `id` and is much more performant. This requires keeping track of the last ID from the previous page, which is a common pattern in web applications.

19What is the difference between `VARCHAR` and `CHAR` data types?
TechnicalEasy

`VARCHAR` and `CHAR` are both used for storing string data, but they differ in how they manage storage. `CHAR` is a fixed-length data type. If you declare a `CHAR(10)` column, it will always store 10 characters, padding with spaces if the string is shorter. This is efficient for small, consistent-length data like two-letter country codes. `VARCHAR` is a variable-length data type. It only uses the storage needed for the actual string plus a small overhead (1 or 2 bytes) to store the length of the string. `VARCHAR` is generally the preferred choice for most string data as it saves space, especially for columns with variable-length content.

20How do you back up and restore a MySQL database?
TechnicalMedium

The most common and simplest method is using the `mysqldump` command-line utility. For a full backup, I'd use `mysqldump -u [user] -p[password] [database_name] > backup.sql`. For a single table, I'd specify the table name. To restore, I would use the `mysql` command: `mysql -u [user] -p[password] [database_name] < backup.sql`. For large, production databases, I would use a more robust, non-locking tool like Percona XtraBackup, which performs a hot backup, allowing the database to remain online during the backup process. For a disaster recovery plan, I would implement a combination of physical backups (using a tool like XtraBackup) and logical backups (using `mysqldump`) and regularly test the restoration process to ensure the backups are valid.

21What is the `OPTIMIZE TABLE` command, and when is it useful?
TechnicalMedium

`OPTIMIZE TABLE` is a command used to defragment a table and reclaim unused space. It rebuilds the table and its indexes, which can improve performance for tables that have undergone many `DELETE`, `UPDATE`, or `INSERT` operations. It is particularly useful for InnoDB tables where rows have been deleted, as it can reclaim space left by fragmented records. It is also beneficial for MyISAM tables, which can become heavily fragmented over time. I would run this command periodically on tables that experience frequent data changes or when a significant amount of data has been purged, but it's important to remember that it can lock the table for the duration of the operation.

22How do you handle database migrations and schema changes in a team environment?
TechnicalHard

Managing schema changes in a team requires a structured approach to avoid conflicts and downtime. I prefer using a schema migration tool, such as `Flyway` or `Liquibase`. These tools use version control to manage SQL scripts that define schema changes (e.g., `V1__create_users_table.sql`, `V2__add_email_index.sql`). The process is as follows: 1. A developer writes a new migration script for their feature. 2. The script is peer-reviewed and checked into version control (e.g., Git). 3. The migration tool is run as part of the deployment process. It tracks which scripts have been executed and runs only the new ones. This ensures a consistent, repeatable process across all environments. For larger changes that might cause downtime, I would consider a 'safe' online schema change tool like `pt-online-schema-change` from the Percona Toolkit, which allows for changes to be made without locking the table.

23Explain the concept of `ACID` properties in the context of a bank transaction. What happens if one property is violated?
TechnicalMedium

SITUATION: Imagine a bank transfer from Account A to Account B. This is a single transaction that involves two steps: decrementing Account A's balance and incrementing Account B's balance. TASK: We need to ensure that this operation is performed correctly and reliably, even if the system fails mid-way. ACTION: We use a transaction with the ACID properties. The `Atomicity` property ensures that both steps either succeed or fail as a single unit. If the transfer from A fails, the increment to B is rolled back. `Consistency` ensures that the total sum of money in the bank remains the same, before and after the transaction. `Isolation` guarantees that if someone else queries the balances while the transaction is in progress, they won't see an inconsistent state (e.g., seeing the money debited from A but not yet credited to B). `Durability` ensures that once the transaction is committed, the changes are permanent, even if the server crashes immediately after. RESULT: Without these properties, a violation could lead to serious data corruption. For example, if atomicity is violated and the system crashes after debiting Account A but before crediting Account B, the money would be lost, leading to an inconsistent state and potential financial disaster.

24What is the purpose of `GROUP BY` and `HAVING` clauses?
TechnicalEasy

`GROUP BY` is used to arrange identical data into groups. It's often used with aggregate functions like `COUNT()`, `SUM()`, `AVG()`, etc., to perform a calculation on each group of rows. The `HAVING` clause is similar to the `WHERE` clause, but it is used to filter the results of `GROUP BY` after the grouping has occurred. You cannot use aggregate functions in the `WHERE` clause. For example, to find all departments with more than 10 employees, you would `GROUP BY` department and then use `HAVING COUNT(*) > 10`. The `WHERE` clause filters rows before grouping, while `HAVING` filters the groups themselves.

25How do you secure a MySQL database?
TechnicalMedium

Securing a MySQL database is a multi-layered process. First, at the host level, I ensure the server is configured securely and only listens on a specific IP address. I would also use firewalls to restrict access to the MySQL port. At the MySQL level, the core steps are: 1. `User and privilege management`: I'd create dedicated users for each application and grant them only the minimum necessary privileges using the `GRANT` command. The root user should not be used by applications. 2. `Password management`: I'd enforce strong password policies and use an authentication plugin like `caching_sha2_password`. 3. `Encryption`: I would enable SSL/TLS for all client connections and consider data-at-rest encryption. 4. `Auditing`: I'd configure the audit log to track all database activities. 5. `Configuration`: I'd review the `my.cnf` file to disable unnecessary features and ensure secure defaults are in place, like disabling `LOAD DATA LOCAL INFILE` if not needed. Regular security audits and patch management are also critical.

26What are common table expressions (CTEs) and when would you use them?
TechnicalMedium

Common Table Expressions (CTEs), introduced in MySQL 8.0, are temporary, named result sets that exist only for the duration of a single query. They are defined using the `WITH` clause. I use them to improve the readability and maintainability of complex queries, especially those that involve multiple subqueries or recursive logic. CTEs allow me to break down a complex query into smaller, more logical, and reusable pieces, much like defining a local variable in a programming language. They are particularly useful for recursive queries (e.g., finding all employees in a management hierarchy) and for avoiding redundant subqueries.

27What is a `View` in MySQL, and what are its pros and cons?
TechnicalMedium

A `View` is a virtual table based on the result-set of an SQL query. It does not store data on its own; it's a way to present data from one or more underlying tables in a simplified, customized, and consistent manner. The pros are: 1. `Simplification`: They can hide complex joins and calculations, making a database easier to use. 2. `Security`: They can restrict user access to only certain rows or columns of a table without granting full permissions. 3. `Abstraction`: They provide a layer of abstraction, allowing changes to the underlying table structure without affecting dependent applications. The main con is performance; a view's query is executed every time the view is accessed, which can be slow if the underlying query is complex. Also, not all views are updatable, especially if they contain joins or aggregate functions.

28Explain the difference between `DELETE FROM table WHERE ...` and `DELETE FROM table`.
TechnicalEasy

`DELETE FROM table WHERE ...` is a targeted `DML` command that removes specific rows that match the condition in the `WHERE` clause. It is a transactional operation, and each deletion is logged, making it slower but enabling a `ROLLBACK`. `DELETE FROM table` without a `WHERE` clause removes all rows from the table. It is also a DML command and can be rolled back, but it is slower than `TRUNCATE` because it still logs each individual row deletion. A common mistake is to forget the `WHERE` clause, which can lead to unintended data loss.

29What are the common challenges when scaling a MySQL database, and what strategies do you use to overcome them?
TechnicalHard

The most common challenge is handling increased write load, as MySQL is fundamentally a single-write-master system. Other challenges include slow queries, I/O bottlenecks, and contention for resources. To overcome these, I use a combination of strategies: 1. `Vertical Scaling`: Upgrading the hardware (CPU, RAM, faster storage). This is a short-term solution. 2. `Horizontal Scaling`: The primary method for long-term scalability. This involves using replication to create read replicas, distributing the read load across multiple servers. 3. `Sharding`: For applications with a very high write load, I would consider sharding, which involves partitioning the data into multiple databases. This is complex but provides near-linear scalability. 4. `Caching`: Implementing a caching layer (e.g., Redis or Memcached) to reduce database hits for frequently accessed data. 5. `Query Optimization`: Continuously monitoring and optimizing the slowest queries is a fundamental and ongoing task to ensure performance.

30How would you handle a situation where a developer is running a long-running, non-indexed query that is causing a performance degradation on a production server?
TechnicalHard

SITUATION: I'm monitoring the production server, and I notice a significant increase in CPU and a sudden drop in application performance. The `SHOW PROCESSLIST` command reveals a query running for several minutes without an end in sight. TASK: My immediate task is to identify the query, understand its impact, and take action to restore service, then prevent a recurrence. ACTION: I would first get the process ID of the problematic query and immediately `KILL` it. This is a critical step to free up resources and restore service to the application and other users. Then, I would analyze the query's text and execution plan using `EXPLAIN`. I would identify that it is doing a full table scan and lacking a proper index. After confirming the issue, I would work with the developer to understand the purpose of the query. I would recommend adding the necessary indexes to the table, and potentially rewriting the query to be more efficient. I'd also suggest that such queries should be run on a read replica if possible, or during off-peak hours, rather than on the production master. RESULT: The immediate action of killing the query restored service. The follow-up analysis and collaboration led to a permanent fix, improving the application's overall performance and preventing similar incidents in the future. We also updated our best practices to include running `EXPLAIN` on all new queries before they are deployed to production.

31What is the difference between a `FULLTEXT` index and a regular `B-tree` index?
TechnicalMedium

`B-tree` indexes are the default and most common index type in MySQL. They are used for a wide range of lookups, including equality, range, and sorting. They are efficient for columns in `WHERE` clauses, `JOIN` conditions, and `ORDER BY` clauses. A `FULLTEXT` index, on the other hand, is a specialized index used for text search operations on `VARCHAR` or `TEXT` columns. It indexes individual words within a string and allows for natural language searches using the `MATCH AGAINST` syntax. You cannot use a `B-tree` index for a `MATCH AGAINST` query, and you cannot use a `FULLTEXT` index for a standard `WHERE column LIKE 'string%'` query. They serve different purposes, with `FULLTEXT` being optimized for complex text matching and ranking.

32What is the difference between a `TRIGGER` and a `STORED PROCEDURE`?
TechnicalMedium

A `TRIGGER` is a special type of stored procedure that is automatically executed in response to a specific event on a table, such as an `INSERT`, `UPDATE`, or `DELETE`. It's a way to enforce business logic or data integrity at the database level. A `STORED PROCEDURE`, as previously discussed, is a set of pre-compiled SQL statements that you must explicitly call to execute. A trigger cannot be called directly; it is event-driven. A stored procedure is a general-purpose block of code, while a trigger is a specialized, event-driven mechanism for data manipulation. Triggers can be useful for tasks like automatically updating a summary table or logging data changes, but they can be a source of performance overhead and hidden complexity if not used carefully.

33What is the `information_schema` database, and why is it important?
TechnicalEasy

The `information_schema` is a virtual, read-only database that provides metadata about the MySQL server. It contains information about all the other databases, tables, columns, indexes, privileges, and other database objects that the current user has access to. It's a powerful tool for developers and DBAs to inspect the database structure without having to parse `SHOW CREATE TABLE` output. I use it to programmatically get information about my database, for example, to list all tables in a specific schema, find all columns of a certain data type, or check for missing primary keys. It's an essential resource for developing automation scripts, monitoring, and database introspection.

34What is the `JSON` data type in MySQL, and when would you use it?
TechnicalMedium

The `JSON` data type, available since MySQL 5.7, allows you to store and manipulate JSON documents directly within the database. It stores the data in a binary format, which makes it more efficient for searching and accessing individual values than storing JSON as a simple text string. I would use the `JSON` data type when dealing with semi-structured data where the schema is not fixed or needs to be flexible. For example, storing user preferences, product attributes, or event logs where new fields might be added over time. The main benefit is the ability to query and index fields within the JSON document using a powerful set of built-in functions, like `JSON_EXTRACT`, `JSON_CONTAINS`, and `JSON_ARRAY_APPEND`.

35Explain `SQL Injection` and how to prevent it.
TechnicalMedium

`SQL Injection` is a security vulnerability where an attacker can execute malicious SQL commands by manipulating user-supplied input. It typically happens when user input is concatenated directly into a SQL query without proper sanitization. The attacker can then gain unauthorized access, modify, or delete data. The primary method for prevention is to use `prepared statements` with `parameterized queries`. With prepared statements, the SQL query structure is sent to the database engine separately from the user data. The database engine then compiles the query and substitutes the parameters safely, preventing the user input from being executed as code. Other prevention methods include input validation and using the principle of least privilege for database users.

36What is the difference between `NOW()` and `CURRENT_TIMESTAMP()`?
TechnicalEasy

In MySQL, `NOW()` and `CURRENT_TIMESTAMP()` are synonyms. They both return the current date and time as a `DATETIME` value. The only practical difference is that `CURRENT_TIMESTAMP()` is a standard SQL function, whereas `NOW()` is MySQL-specific. For a developer, the choice is mostly a matter of preference or compatibility with other SQL dialects. However, it's worth noting that if you use `CURRENT_TIMESTAMP` as a default value for a column, it will be updated automatically on every row update, while `NOW()` does not have this behavior as a default value.

37How do you handle `deadlocks` in MySQL, and what is the difference between a `row lock` and a `table lock`?
TechnicalHard

A `deadlock` occurs when two or more transactions are waiting for each other to release a lock. MySQL's InnoDB storage engine has a deadlock detection mechanism that automatically rolls back one of the transactions to resolve the issue, returning an error. To prevent deadlocks, I follow these best practices: 1. `Keep transactions short and concise`. 2. `Access tables and rows in a consistent order`. 3. `Use less restrictive lock types`. A `row lock` (InnoDB) locks a specific row, allowing high concurrency, while a `table lock` (MyISAM) locks the entire table, preventing other sessions from making changes. I would use row-level locking for most applications to maximize concurrency.

38What is a `temporary table`, and when would you use one?
TechnicalMedium

A `temporary table` is a special type of table that is only visible to the current user session and is automatically deleted when the session ends. I would use a temporary table to store intermediate results for a complex query, especially when the query involves multiple joins and aggregations. It can be a performance improvement over using a subquery, as the temporary table's data is written to disk once, and subsequent operations can use indexes on it. They are also useful for debugging complex queries by breaking them down into manageable steps.

39What is the difference between `VARCHAR(255)` and `TEXT`?
TechnicalMedium

Both `VARCHAR` and `TEXT` data types are used to store variable-length strings, but they have key differences. `VARCHAR(255)` can store a maximum of 255 characters (or up to 65,535 in MySQL 5.0.3+), while `TEXT` can store up to 65,535 characters. `VARCHAR` values are stored in the row, which can make table scans faster. `TEXT` values are stored separately from the row data, with a pointer in the row pointing to the external storage. This means `TEXT` columns can be slower to access. I would use `VARCHAR` for most string data where the maximum length is known and relatively small, and `TEXT` for larger blocks of text like articles, comments, or notes.

40How would you handle a data model that needs to store hierarchical or tree-like data (e.g., categories with subcategories)?
TechnicalHard

There are several common patterns for storing hierarchical data, each with its pros and cons. 1. `Adjacency List Model`: This is the simplest approach, where each row has a `parent_id` column that points to its parent. It's easy to insert and update, but querying the full hierarchy (e.g., getting all descendants of a node) can be complex and inefficient, requiring recursive queries or multiple queries. 2. `Nested Set Model`: This model stores a left and right value for each node, defining its position in the tree. It's very efficient for reading the entire tree or a subtree, but insertions and updates are very expensive as they require recalculating and updating the left/right values of many nodes. 3. `Materialized Path Model`: This model stores the full path to a node in a separate column (e.g., '/1/3/7'). This makes it easy to get a subtree with a `LIKE` query but can become unwieldy and less flexible. The best approach depends on the read/write ratio of the data. For a read-heavy hierarchy, a Nested Set or Materialized Path might be more suitable. For a write-heavy or simple hierarchy, an Adjacency List is often the best choice.

Practise related roles

How to practise for a Mysql Developer interview

Reading model answers feels productive, but interviews are spoken. For each question: say your answer out loud (or write it), then open the model answer and compare. Be honest with the rating — “practise again” questions come back when you filter for them, so your next session starts where you are weakest.

A routine that works

  • Day 1: go through every question once and rate yourself.
  • Next days: filter for “Practise again” and repeat until most are “Got it”.
  • Behavioural questions (“Tell me about a time…”) need a real story: build them in Behavioural (STAR) mastery, then rehearse them against the clock in the practice timer.
  • Keep your final answers in your Q&A vault.
Where do these questions come from?

Each role’s set was written with AI (Google Gemini) for that job title and saved, so everyone practising for the role sees the same set. They are typical questions for the role, not a list from any particular employer, and the model answers are guidance — not facts about you.

Is it free?

Practising ready-made sets is free, with no account needed. An account saves your progress and notes (also in the Expertini app). Two things use an AI request from your plan: AI feedback on an answer you write, and creating a set for a job title that does not have one yet.

How is the AI feedback scored?

The AI rates your answer from 1 to 5 against a fixed rubric (does it answer the question, is it specific and structured, does it show a result) and suggests a better version that keeps your facts. Where a detail is missing it leaves a [placeholder] for you to fill in — it does not invent achievements. It is a practice aid, not a prediction of how an interviewer will react.

What is saved to my account?

For each role: which questions you have practised, your 1–3 self ratings and your notes. Answers you type for AI feedback are not saved unless you click “Save to Q&A vault”.