I have two tables, Police and Violations [Police holds the data of policemen, and Violations contains the data of all parking violations], and the essential idea is that a police can cancel any number of Violationss but, only one Violations canceled by a single police.So essentially, it could be seen as (police PK(username)) 1:M (Violations PK(Violations#)) Now, the Violations table will have the username of the police as a Foreign Key. Now if the one of the police cancels the specific Violation, then the username of this police , date and time of cancel, will also be added rather than this it will have a null value in Violations table.
The problem is when a Violation inserted into the database the field belong to that police in Violations table is NULL and I wish to avoid this NULL value. [ I mean, (username, date, time) will have value only if police cancel a Violations which is mean update the status of Violations to cancel. ]
It sounds as though you are talking about an optional relationship (0 or 1 to M). A NULL in an FK is a fairly standard way of indicating that a relationship is not present.
In this case, it means that there is no cancelling police officer because the violation is not cancelled. Right?
I don't see why nulls are a problem here.
But, if you want to get rid of NULLS here, there is a fairly simple way to do it. Just create a relationship table, containing FKs to both of your tables. And remove the FK from the violations table. Now, instead of having a NULL anywhere, just don't insert a row in the relationship table! Later on, when a cancellation does occur, just insert a new row in the relatonshp table.