I am new to web programming and have been exploring issues related to web security.
I have a form where the user can post two types of data - lets call them "safe" and "unsafe" (from the point of view of sql).
Most places recommend storing both parts of the data in database after sanitizing the "unsafe" part (to make it "safe").
I am wondering about a different approach - to store the "safe" data in database and "unsafe" data in files (outside the database). Ofcourse this approach creates its own set of problems related to maintaining association between files and DB entries. But are there any other major issues with this approach, especially related to security?
UPDATE: Thanks for the responses! Apologies for not being clear regarding what I am considering "safe" so some clarification is in order. I am using Django, and the form data that I am considering "safe" is accessed through the form's "cleaned_data" dictionary which does all the necessary escaping.
For the purpose of this question, let us consider a wiki page. The title of wiki page does not need to have any styling attached with it. So, this can be accessed through form's "cleaned_data" dictionary which will convert the user input to "safe" format. But since I wish to provide the users the ability to arbitrarily style their content, I can't perhaps access the content part using "cleaned_data" dictionary.
Does the file approach solve the security aspects of this problem? Or are there other security issues that I am overlooking?