I have three table package,addimage,iternaries and triptitle is foreign key(common key) for all three table. my requirement is if i update package table using edit button then automatically updated addimage,iternaries table
In above figure 3 table package,addimage,iternaries and trip title and trips are foreign key i want to update those row whose triptitle or trips name is couple tour
First we want to Download Laravel 5.8 version for developing Crud application using Ajax. For this you have to open your terminal or command prompt and write below command. It will download Laravel 5.8 in your define directory.
Above command will command create migration file in database/migrations folder. In that file we have to define table column which you want to define in Mysql table. Below you can find source code of migration file.
Lastly for create Mysql table in your Database, you have to write following command in your terminal or command prompt. It will create ajax_cruds table in your define Database.
php artisan migrate
Step 4 – Create Model in Laravel 5.8
Now we want to make Model in Laravel 5.8, For this you have to write following command in your terminal or command prompt. It will create model file here app/AjaxCrud.php.
php artisan make:model AjaxCrud -m
Under this app/AjaxCrud.php file, you have to define table column for database operation which source code you can find below.
Step 5 – Create Blades Files
For display output data in browser, in Laravel 5.8 we have to create blade file in resources/views folder. Under this folder we have create ajax_index.blade.php file. In this file you can find HTML code and jQuery code for display data in jQuery Datatable.
Step 6 – Set Resource Route
Step 7 – Create Controller in Laravel 5.8
Lastly, We need to set resource route for ajax crud application. For this we have to open routes/web.php file.
Controller mostly used for handle HTTP request. Create new controller in Laravel 5.8 framework, we have to write following command.
This command will create AjaxCrudController.php file in app/Http/Controllers folder. In this controller file you can find all in build required method for do Crud operation. Under this controller for use AjaxCrud model, first we have to define use App\AjaxCrud; this statement at the header of the AjaxCrudController.php file.
index() – This is the root method of this controller. This method will received Ajax request for load data in jQuery DataTables plugin. If this method received ajax request then it will load data in jQuery DataTables plugin. In this ajax block you can find yajra datatables package code.
store() – For Insert Data into Mysql table using ajax in Laravel 5.8, here we have use store() method of AjaxCrudController.php. This method will received Ajax request for insert or add data. Under this method first it has validate for data. If there is any validation fails then it will send response to ajax request in JSON format. But there is no any validation fails then it will continue execution of code and first it will upload profile image of user and then after it will insert data into mysql table. And lastly it will send json response to ajax request.
edit() – This method is used for fetch single row of data from mysql table, and send data to ajax request in json formate which will be display under Bootstrap modal form.
update() – This method has received ajax request for update existing mysql table data. In this method first it check user has select profile image or not. If User is select image then in this method it will validate form data with selected file is image or not. But Suppose user has not select image then it will only validate textbox data only. If there is any validation error occur then it will send data to ajax request in json formate. After successfully validate form data then it will update data.
destroy() – For delete or remove mysql data, ajax request will be send to destroy() method. It will delete or remove mysql data in Laravel 5.8 by using ajax.
For run Laravel 5.8 application, you can write following command.
php artisan serve
For see Laravel 5.8 application in your browser, you have to write following url.
I have three table package,addimage,iternaries and triptitle is foreign key(common key) for all three table. my requirement is if i delete package table using delete button then automatically deleted addimage,iternaries table
In above figure 3 table package,addimage,iternaries and trip title and trips are foreign key i want to delete those row whose triptitle or trips name is couple tour
Q1. Can you create a table without using create command ?
A. Yes, we can create table with the help of SELECT INTO statement. It copies content of one table to another table. However, there should be at least one table from where we can copy content. Example : Copying all columns : select * into new_table from old_table where condition Copying specific column : select col1,col2 into new_table from old_table where condition Creating new empty table : select * into new_table from old_table where 1 = 0
Q2. What is Denormalization ?
A. It is the reverse process of Normalization. It is the process of trying to improve the readability of the database by grouping data. Denormalization is also used for speeding up the performance.
Q3. What are Joins ?
A. Join clause are used to combine rows from two or more tables, depending upon the columns between them.
Q4. What are the different types of Joins ?
A. Different types of Joins are :
INNER JOIN : It returns all records that are common in both tables.
LEFT OUTER JOIN : It returns all records from the left table, and matched records from right table
RIGHT OUTER JOIN : It returns all records from the right table, and matched records from left table.
FULL OUTER JOIN : It returns all records when there is a match in either left or right table.
Q5. Explain Transaction ?
A. Transaction refers to the collection of multiple statements, that are responsible for transferring a database from one consistent state to another consistent state.
Q6. Explain the role of views in database ?
A.View refers to the virtual table. We can create view using create view statement.
CREATE VIEW as Select col1
Q7. Explain Trigger ?
A. Triggers are defined as special kind of stored programs, which are automatically executed whenever a specific operation occurs in the database server.
Q8. What are Locks ?
A. Locking is the mechanism to protect data integrity and ensure data consistency during transactions. Locks are the most common cause of blocked processes. Stronger the Isolation level, more the chances of blocking.
Q9. Explain different types of Locks ?
A. Locks are broadly characterized into following types :
Shared Locks : These locks are acquired by readers during read operations. In other words, these locks exist when two transactions are granted read access. Data updation is not allowed until shared lock is released. Exclusive Locks : In exclusive lock, data items can be both read as well as written by the transaction. In Exclusive lock, multiple transactions do not modify the same data simultaneously.
Q10. What is Super Key ?
A. An attribute or set of attributes that uniqueness in database is refered to as Super key. It is the superset of Candidate key.
Q11. What is Candidate Key ?
A. A minimal set of attribute/attributes that can be used to uniquely identify a single row in a given relation is refered to as Candidate key.
Q12. Explain Primary Key ?
A. DB Designer selects one of the candidate key as primary key for a relation for the purpose of identification of a tuple uniquely. It is identified during table creation.
Q13. What is Composite Key ?
A. If a primary key has more than one attribute, then it is referred to as Composite key.
Q14. Explain Foreign Key ?
A. A set of attribute/attributes that is used to establish and enforce a link between data in two or more relations.
Q15. Can a table have more than one primary key ?
Q16. Can We Have NULL Value in Primary Key?
Q17. What are cursors ?
A. A cursor is a temporary work area created in system memory when a SQL statement is executed. A cursor can hold more than one row, but can process only one row at a time.
Q18.What are the differences between Hash join, Merge join and Nested loops?
The hash join is used when you have to join large tables.
Merge join is used when projections of the joined tables are sorted on the join columns.
The nested loop consists of an outer loop and an inner loop.
Q19. What do you understand by Proactive, Retroactive and Simultaneous Update ?
Proactive Update: These updates are applied to the database before it becomes effective in the real-world environment.
Retroactive Update: These retroactive updates are applied to a database after it becomes effective in the real-world environment.
Simultaneous Update: These updates are applied to the database at the same instance of time as it becomes effective in a real-world environment.
Q20.What do you understand by Data Independence?
A. When you say an application has data independence, it implies that the application is independent of the storage structure and data access strategies of data.