Posts

What are the main differences between INNODB and MYISAM?

Here are a few of the major differences between InnoDB and MyISAM: InnoDB has row-level locking. MyISAM only has full table-level locking. InnoDB has what is called referential integrity which involves supporting foreign keys (RDBMS) and relationship constraints, MyISAM does not (DMBS). InnoDB supports transactions, which means you can commit and roll back. MyISAM does not. InnoDB is more reliable as it uses transactional logs for auto recovery. MyISAM does not.

Why we use innodb as Engine in MySQL?

InnoDB is a storage engine in MySQL. InnoDB's greatest strengths are: Its design follows the ACID model, with transactions featuring commit, rollback, and crash recovery capabilities to protect user data. Row-level locking (without escalation to coarser granularity locks) and Oracle-style consistent reads increase multi-user concurrency and performance. Foreign key constraints. Allowing you to let the database ensure the integrity of the state of the database, and the relationships between tables. InnoDB tables arrange your data on disk to optimize common queries based on primary keys. Each InnoDB table has a primary key index called the clustered index that organizes the data to minimize I/O for primary key lookups. You can freely mix InnoDB tables with tables from other MySQL storage engines, even within the same statement. For example, you can use a join operation to combine data from InnoDB and MEMORY tables in a single query. InnoDB Limitations : No full-text indexing (Below-

How does request life cycle work in Laravel?

The entry point for all requests to a Laravel application is the public/index.php file. All requests are directed to this file by your web server (Apache / Nginx) configuration. The index.php file doesn't contain much code it's just starting point for loading the rest of the framework. The index.php file loads the Composer generated autoloader definition and then retrieves an instance of the Laravel application from bootstrap/app.php script. The first action taken by Laravel itself is to create an instance of the application/service container. HTTP / Console Kernels Next, the incoming request is sent to either the HTTP kernel or the console kernel, depending on the type of request that is entering the application. These two kernels serve as the central location that all requests flow through. For now, let's just focus on the HTTP kernel, which is located in the app/Http/Kernel.php. The HTTP kernel extends the Illuminate\Foundation\Http\ Kernel class, which defines an array

What is normalization in DBMS?

 Normalization is the technique of organizing the data into multiple tables to minimize data redundancy. Data redundancy means the reputation of data at multiple places. Different issues can be observed while insertion, Updation, Deletion. Unnecessary data reputation will increase the size of the database and leads to more issues. Normalization will break the table into two different tables.

How can we optimize database query?

MySQL is one of the most popular open-source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). Useful tips to improve MySQL Query for speed and performance. 1. Optimize Your Database You need to know how to design schemas to support efficient queries. Well-designed queries and schema are crucial for your application to work properly. Optimizing your MySQL queries alone will not bring excellent database performance. A well-structured database is crucial along with an optimized query. The following steps will help you to optimize your database. a. Normalize Tables b. Use Optimal Data Types c. Avoid Null Values d. Avoid Too Many Columns 2. Optimize Joins 3. Index All Columns Used in ‘where’, ‘order by’, and ‘group by’ Clauses 4. Use Full-Text Searches - MySQL full-text search (FTS) is far faster than queries using wildcard characters. To add a full-text search index to the students’ sample table, we can use the below MySQL command: mysql>Alter tab

What is Laravel localization? When we can us this?

When we are developing a multi-language site at that time we use laravel localization. Localization in Laravel in it's simplest term means changing the application's default language to the language preferred by the user. There are two different ways we can achieve localization in Laravel: 1. Using Short Keys 2. Using Translation Strings as Keys

What is the difference between self and static in PHP?

The main differences is that static allows late static bindings. One of the most useful scenarios that I found was for creating Base classes for Singleton Classes: class A { // Base Class     protected static $name = '';     protected static function getName() {         return static::$name;     } } class B extends A {     protected static $name = 'MyCustomNameB'; } class C extends A {     protected static $name = 'MyCustomNameC'; } echo B::getName(); // MyCustomNameB echo C::getName(); // MyCustomNameC Using return static::$name in the Base class will return what was statically attached when it was extended. If you were to use return self::$name then B::getName()  would return an empty string as that is what is declared in the Base class.

Why we need interface in PHP?

An interface allows unrelated classes to implement the same set of methods, regardless of their positions in the class inheritance hierarchy. An interface enables you to model multiple inheritance because a class can implement more than one interface whereas it can extend only one class. Interfaces are 100% abstract classes – they have methods but the methods have no ‘guts’. Interfaces cannot be instantiated – they are a construct in OOP that allows you to inject ‘qualities’ into classes .. like abstract classes. Where an abstract class can have both empty and working/concrete methods, interface methods must all be shells – that is to say, it must be left to the class (using the interface) to flesh out the methods. Interfaces allow you to define/create a common structure for your classes – to set a standard for objects. Interfaces solves the problem of single inheritance – they allow you to inject ‘qualities’ from multiple sources. Interfaces provide a flexible base/root s

What is autoload in PHP?

Autoloading is the process of automatically loading PHP classes without explicitly loading them with the require() , require_once() , include() , or include_once() functions. It's necessary to name your class files exactly the same as your classes. As of PHP 7.2.0 the __autoload() function has been deprecated. Now it is recommended to use the spl_autoload_register() for that purpose instead.

How can we prevent XSS attacks?

Preventing cross-site scripting is trivial in some cases but can be much harder depending on the complexity of the application and the ways it handles user-controllable data. In general, effectively preventing XSS vulnerabilities is likely to involve a combination of the following measures: Filter input on arrival - At the point where user input is received, filter as strictly as possible based on what is expected or valid input. Encode data on output - At the point where user-controllable data is output in HTTP responses, encode the output to prevent it from being interpreted as active content. Depending on the output context, this might require applying combinations of HTML, URL, JavaScript, and CSS encoding. Use appropriate response headers - To prevent XSS in HTTP responses that aren't intended to contain any HTML or JavaScript, you can use the Content-Type and X-Content-Type-Options headers to ensure that browsers interpret the responses in the way you intend. Co