SQL Select Null
SQL Select Null
• First of all we should know that what null value is? Null values are
used to represent missing unknown data.
• There can be two conditions:
1.Where SQL is NULL
2.Where SQL is NOT NULL
• If in a table, a column is optional, it is very easy to insert data in
column or update an existing record without adding a value in this
column.
• This means that field has null value.
• Where SQL is NULL:
• How to select records with null values only? (in the marks column)
• There is an example of student table:
• Let's see the query to get all the records where marks is NULL:
• How to select records with no null values(in marks column)? Let's see
the query to get all the records where marks is NOT NULL
• To check the output of the above INSERT statement, you have to type
the following SELECT statement:
• SELECT * FROM Student_Trigger;
Advantages of Triggers in SQL
• Insertion anomaly arises when you are trying to insert some data into
the database, but you are not able to insert it.
• Example: If you want to add the details of the student in the above
table, then you must know the details of the department; otherwise,
you will not be able to add the details because student details are
dependent on department details.
2. Deletion Anomaly:
• Deletion anomaly arises when you delete some data from the database,
but some unrelated data is also deleted; that is, there will be a loss of
data due to deletion anomaly.
• Example: If we want to delete the student detail, which has student_id
2, we will also lose the unrelated data, i.e., department_id 102, from
the above table.
3. Updating Anomaly:
• An update anomaly arises when you update some data in the database,
but the data is partially updated, which causes data inconsistency.
• Example: If we want to update the details of dept_head from Jaspreet
Kaur to Ankit Goyal for Dept_id 104, then we have to update it
everywhere else; otherwise, the data will get partially updated, which
causes data inconsistency.
Advantages of data redundancy in DBMS
• Solution
• F1={AB->C}
• F2={C->D}
• => (F1 u F2) = {AB->C, C->D}
Decomposition is not preserving