delete
logo

Tutorial to wreck the database

logo

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:

  • Plural vs. Singular: Ideally for the best database schema table names has to be plurals like `users`,`employees`,`departments` which is helpful for everybody who are dealing with the database mainly developers. But in this case you have to use combination of plural and singular names in your database design for the table names like `users`,`employee`,`departments`,`management`
    If you use this format of naming people has to look up for the table name or maybe they will look after getting the error.
  • Camel vs. Underscore: This is another type of naming convention used in the database design while naming the tables. Camel naming convention cases represent name like this `employeeMessage`,`rollNo`. Underscore naming convention represents name like this `employee_message`,`roll_no`. Generally while creating a good database design for long name tables underscore convention use. But in this case use the combination of camel and underscore naming convention. So, that people has to look up into the database schema or memorise the name of the tables.

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:-

  • departmentName
  • ids
  • about_description

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 Email 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.

Share

2 Responses to “Tutorial to wreck the database”

  1. Robor says:

    Thank you! I would now go on this blog every day!

  2. Charlie says:

    Ugh, I liked! So clear and positively.
    Thanks

Leave a Reply

logo
logo