MYSQL questions and answers for the interview – Part 1

What is the primary key?

Primary key (primary key) – a column whose values in all the lines are different. Per- Wrist keys can be logical (natural) and surrogate (artificial). So, for an imaginary table “Users” the primary key can be the column e-mail (after all theoretically there cannot be two users with the same e-mail). But in practice it is better to use surrogate keys; their use makes it possible to abstract the keys from re- data. Also, primary keys cannot be changed, but what if the user has e-mail? The surrogate key is an additional field in the database. As a rule, this is the order number of the entry (although you can specify them at your own discretion, they were unique).

What are normalization and denormalization?

Normalization is the process of bringing the database to the form in which it will correspond to the rules of normal forms. Normalization minimizes the amount of excess information. Its goal is to save data only once but in the right place. A normalized database eliminates duplication and multiple maintenances of data. and the appearance of problems with the integrity of data that arise when you re-enter the same data. Denormalization is the process of consciously bringing the database to a form in which it is not will meet the rules of normalization. This is usually necessary to increase the pro- and the speed of data extraction by increasing data redundancy. If an application needs to frequently perform selections that take up too much time (for example, combining data from multiple tables), you should consider the possibility of denormalization. The possible solution is the following: render the results of the sample in a separate table. This increase the speed of execution of requests, but also means the need for constant maintenance of this new table. Before embarking on denormalization, it must be ensured that the expected results justify the costs to be faced.

What is mysql_pconnect? How does it differ from mysql_connect?

When using the mysql_connect () function, a new connection to the data zone. After calling mysql_close () or after the script is finished, is covered. The difference between mysql_pconnect () is that, first, when the function is called first It looks for an already open (persistent) connection with the database (persistent connection) if it is not – A new one is being built. Secondly, after the script is finished and when mysql_close () is called, the database with MySQL database does not show closed but remains open for later use.

What are MyISAM and InnoDB?

MyISAM and InnoDB are table types.

How are they different?

MyISAM – does not support transactions, and its main shortcomings and advantages are related to this; – in most cases, it is faster since there are no transaction costs; – takes up less disk space; – less memory consumption for updates; – full-text index; – Fast INSERT, SELECT. InnoDB – Transaction support; – Line lock. UPDATE does not block the entire table; – behaves well with mixed load (insert | select | update | delete).

How to make an index in MySQL?

For primary keys (PRIMARY KEY), the index is created automatically.

What is SQL injection?

SQL injection – the embedding of malicious code into queries to the database. Using SQL injection an attacker can not only get private information from the database, and, under certain conditions, but also to make changes there. Vulnerability to SQL injections is because of the user. The query enters the database query without proper processing: so that the script is not vulnerable. It is required to make sure that all user data falls into all questions to the database in a shielded form.

Close

About The Author

Ruchi Singla
An enthusiast writer with years of experience, who loves to create beautiful thoughts into words. She writes with a zeal and enjoys reading vogue with a good cup of coffee when not writing. Ruchi is working as a content writer for many businesses, helping them gain an extra edge over their competitors. As a content writer, she is responsible for enhancing engagement and traffic on the blog by brainstorming exciting content ideas.

This site uses Akismet to reduce spam. Learn how your comment data is processed.