May 18, 2015

Storing images in database or in file system

Images in database:

Advantages:
  1. Secured
  2. Easy backup and Recovery
  3. Simple queries

Disadvantages:
  1. Large size of database
  2. Performance degradation of database with heavy images
  3. Slower access speed


Images in file system:

Advantages:
  1. Easier access
  2. Increased performance (database’s performance will not be affected)
  3. Faster access (File system access is faster than database access)

Disadvantages:
  1. Less secure
  2. Complex process to backup and restore
  3. Added complexity while storage
(Suggested way: Create an ID, copy the ID, change the filename of the image and store the image to the database)

Suggestion:

Store Images in file system if:
  1. Number of images are huge
  2. Database space is limited
  3. Available database is costlier
  4. No problem in securing the images (Try setting permission over the images)

Store Images in database if:
  1. Number of images are considerably less (Try storing images in separate table)
  2. Not worried about the size of the database space (If you have enough space)
  3. Database cost can be met
  4. Scared about the security over the images in filesystem



Tips:

  1. While the image is uploaded, check for the format of the image (Not all formats are viewable in the webpage)
  2. Use compression algorithms to compress the size of the image
  3. Check if the image uploaded is really an image (There are chances of uploading any PHP scripts to the image location)
  4. Create a thumbnail image for every image uploaded.
  5. While storing the image in the file system, create a table in the database with Auto-incrementing attribute that creates an ID for every image uploaded. Rename the image of any name to imageID.ext and imageID.thumb.ext (Naming conventions can be in any form that helps you to identify the image). In this way the images can be fetched from the file system instantly

May 15, 2015

Keys in SQL

  1. Primary Key
  2. Candidate Key
  3. Foreign Key
  4. Alternate Key
  5. Composite or Compound Key
  6. Unique Key


Candidate Key :


A Column with
  • Unique values
  • No null values


[A Table can have more than one column with above attributes. All these columns are candidate keys]


Primary Key:


A Column with
  • Unique values
  • No null values


[A Table can have more than one column with above attributes. But one of these column can be a primary key]


(Info: A table can have only one primary key but any number of candidate keys)


Alternate Key


When a table contains more than one candidate key (say 3 candidate keys), after selecting a column as a Primary key, other 2 columns are called as an Alternate Key


Unique Key:


A Column
  • with Unique values
  • can have null values


(Info: A table may not necessarily contain all the keys, but at least a primary key)

Composite Key:

Two or more columns collectively used to identify a row
Example: 
1. Identifying a student in a student table using his name and his father name
2. Identifying a student in a student table using his name, father name & Birth-date


Foreign Key:

  • Presence of a column in a table which is a primary key for another table.
  • This column is responsible for establishing relationship between two tables.

Multi-tenant and Single-tenant architecture

Multi-tenant architecture website:


  1. Single instance
  2. Data from multiple companies/users stored in a same database server
  3. Data are partitioned to prevent mismatching
  4. Standard and common configuration, templates, styles for all companies/users
  5. No individual considerations
  6. Any modifications are common to all
  7. Customization for single company/user is difficult
  8. Advantages:
    1. Safe - Any changes / modifications are common to all
    2. Meets the needs of most of the companies/users


Single-tenant architecture website:

  1. Separate instance and infrastructure for every company/user
  2. Used by companies/user when they need personal customization
  3. Every company/user has a distinct database server
  4. Advantages:
    1. More Secure - No data migration/ mismatching
    2. Preferred if the company needs a legal requirement

Tags: Multi-tenant and Single-tenant architecture, Multi-tenant, Single-tenant

June 25, 2014

Naming of C++ and C#

We know that C++ is the predecessor of C. Then why C++ and not D?

C++ (Pronounced as See Plus Plus) was renamed from C with Classes. More new features where added to it and the Version is Incremented by 1. Hence the increment operator itself was used. There is a programming language D too.

C# (Pronounced as See Sharp) was inspired by musical notation where a sharp indicates that the written note should be made a semitone higher in pitch. The sharp symbol also resembles a ligature of four "+" symbols (in a two-by-two grid), further implying that the language is an increment of C++.


March 25, 2014

Tetra pak

About the Pack:

Visit the local supermarket and there are so many different kinds of packages on the shelves. As an environmentally conscious consumer, how do you figure out which to choose? It helps to know exactly what you're buying. See what goes into a Tetra Pak package below.

Packaging material

1. Paperboard
The main ingredient in all our packages is paperboard. We use just enough to make the package stable, without adding unnecessary weight. Paperboard is a renewable raw material, made from wood.

2. Polyethylene
Thin layers of polyethylene - a commonly used plastic - are added to seal in the liquid and protect the product from external moisture.

3. Aluminium
Packages designed to store food without refrigeration also contain a thin layer of aluminium foil. This protects the product from oxygen, flavours and light.

Raw Materials:

Why use renewable raw material?

Tetra Pak packages are mostly made of wood, which is a renewable material.

Renewable simply means that the supply regrows naturally. Wood is renewed when trees grow at the same rate or faster than they are cut down. Tetra Pak only buys paperboard from suppliers who ensure that their wood comes from known and acceptable sources.

Forest Protection:

As wood is the main material in our packaging, it's natural we are interested in conserving all forests, not just those we use for our packages.

That's why we work with trusted global organisations such as the World Wide Fund for Nature (WWF), the Global Forest & Trade Network (GFTN) and Forest Stewardship Council™ (FSC™) to increase responsible forestry worldwide.

Life of a package:

Using renewable raw materials
We use renewable materials, as far as this is possible without reducing the performance of the package.

Recycling
To increase recycling, we work with customers, public authorities, NGOs, industry groups and community associations.


Your role as a consumer
At this stage in the package's life cycle - from the store to the recycling station - what you do also plays an important role.

Making production and distribution efficent
Customers use our equipment to package their products. We continously work to reduce the consumption of energy and water, and to minimize the amount of waste.


Turning raw materials into packaging material
Our goal is to minimise energy use and reduce waste during production at our factories.


Using certified paperboard
In 2008, 97% of the paperboard in Tetra Pak packages came from environmentally certified, responsibly managed forests. (Not bad going, but the goal, of course, is 100%).

Design for environment:

By using resources sparingly and designing cartons which can be recycled effectively, Tetra Pak's product developers help to minimise the packages' environmental impact. In practice, this means:

  1. Increasing the amount of renewable material in the package
  2. Reducing the amount of plastic in caps and packaging material
  3. Increasing efficiency of our equipment
  4. Minimising energy consumption
  5. Finding ways to eliminate waste
  6. Minimising emissions to air and water
  7. Securing efficient storage and transport solutions
Recycling:

What happens to used cartons?

If you live in an area where household rubbish is separated for recycling, your used cartons will be transported to a recycling plant. There, they will be soaked in water to separate the paperboard from the plastic and aluminium layers. The paper content can then be turned into new products like toilet paper, tissue and notebooks. The plastic and aluminium can also be recovered to make things like roof tiles or plastic pots.

Energy recovery

Recycling is not the only way to dispose of old cartons responsibly. They can also be incinerated and the energy recovered to generate heat and electricity. Some countries, such as Denmark, have decided to handle rubbish in this way. In Europe in 2007, 33% of all drink cartons were used to generate energy.

Source: http://campaign.tetrapak.com/