delete
10 ways to wreck the database
1. Dumping raw data
If you want that nobody understand the database data. Store the data not as useful information. Store in a raw format so that if somebody wants the data dump of a particular table or the data of many table using join they will not able to analyse the result. For example you have a table named as `employee`,’department`,`timesheet`. If you are dumping the data combining the result of all the three tables into spreadsheet than analyst can’t analyse that how many people are available for evening shift, to get the required result the analyst has to put some effort and understand the data in the spreadsheet.
2. Random naming
Random naming in your database design makes things difficult for the people. Random naming engaged developers to look every time database schema and naming convention. Random naming is particularly used for because developers make random errors while coding the application.
First step is to apply random naming to table names:
Random naming will applied to the field names of the tables. You can use the combination of all the above naming convention to make the people impossible to use database freely without error. For instance table `department` has fields like this:-
There is another notation which you can use to make the things impossible. It named as Hungarian Notation.
Hungarian Notation: Hungarian notation naming is like this where you put the prefixes. For instance table user and its fields:
`tblUser`
`txtFirstName`
`str_last_Name`
`bool_is_active`
3. No Real Keys
Now this is really interesting if you want to lose data than keys in your table are enemies. Don’t ever use real keys in your tables if you want to ruin the data of the table. If you are not using any other key always there will be duplicity. It will create data confusion for the developers which are the real data and which not. Use the by default auto-increment column as primary key. Don’t add any unique key. Like table users has only primary key:
`Users`
`userId` AUTO_INCREMENT PRIMARY KEY
`Name`
4. No Foreign Keys
Foreign keys are helpful in referencing one table column to another table. It restricts the delete operation from the table. If you don’t use any foreign key in your database than you can easily delete the data from the table. Due to this there will be many orphan rows will become. Without foreign key than developers has to check the references in the code while updating or insertion.
5. No Constraints
If you want to create more difficulties for the people than don’t ever use constraints in your table definition. Don’t put any ‘NOT NULL’, ‘DEFAULT VALUES’ etc. This will help you in entering the garbage value into the database. In addition to this don’t use the correct data type for the table column definition as in `users` table for `first_name` you use VARCHAR(45) but instead this use TEXT.
6. Use Non-Atomic fields
Non-Atomic fields are the fields which contains two or more pieces of information. It will create a problem to the developers. For instance in `users` table there is one column `name` which contains the name of the user i.e. first name, middle name and last name.
|
name |
|
John Mc Lein |
So if developers have to show the first name than they have to break the name column data with the space.
7. Use of Magical Numbers
Magical numbers refer to an unnamed or ill-documented numerical constant value. In terms of database following are the magical numbers which has to take care at the programming end. Magical numbers are basically the exceptions. Like for Date field ‘2008-02-30’ is an exceptional value. Following are the examples
ID=0;
Suppose in table `users` column `age` has default 0 value then while calculating the average value of the age developer has to intentionally put `age`>0
8. Polymorphic Fields
Polymorphic fields are the fields whose data is totally different than the name of the field. For instance in `users` table content has to enter:
| Name | Prefcontact | contactinfo |
| Jashua Morrie | jashua@tutorialsolve.com | |
| Veer | NULL | www.tutorialsolve.com |
9. EAV (Entity-attribute-value)
EAV is basically the value which will be meaningful only after combining two columns. For instance:
| ID | Property | Value |
| 1 | Weight | 50 |
| 2 | Married? | False |
So developer has to check the both values of the table while getting the correct result.
10. ER-Design
ER-Diagram should be like that so that nobody can easily get the information from visualising the ER-Diagram.
Thank you! I would now go on this blog every day!
Ugh, I liked! So clear and positively.
Thanks