Database and Relations | Lessoncup Programming Blog

Thursday, 19 December 2013

Database and Relations

Hi, today i am going to tell you about Database and Table Relations, to any web application if it is dynamic before start the application we must plan for the database it is called Database Schema Architecture, i will try to give some useful information on database and relations as i got experience from my production environment.


the first thing we must know about database and y we use it, a database is a storage place where all data will be store, i will give you an example in real world , if we want to store our books are any other stuff we use some kind of storage things like shelf, Freeze and related things and how we use them sometimes we keep new Stuff in storage and sometimes we remove our old stuff from storage this is happen with every person completely in real world

come to programming world it will happen same things like real world, with database we store some useful data into tables, and whenever we need we use it and update it and if the data is no more to use finally we remove it from database, the database is fell like a shelf and fell tables like racks, in shelf (database) we keep different kind of books (data) in different racks ( tables), whenever we need a book (data) we take from racks (tables)

now before start the development we should plan a database and how many tables we need to create and what table is related to which table.. i feel to design the architectural database in awesome software is Workbench


now what is relations, it is also a simple thing just compare with real world ... i always compare the programming to real world with that we can easily get logic and concept. well in real world a relation is called which is adding to one person to another person, we seen and asked many times if you see your friend with a girl  you will ask to you friend what is your relation with her.. so relation word comes with adding two people.

come to programming world there is few types of relations we can give to database tables
  • one to many
  • many to one
  • one to one

One To Many
it is simple one person can have many relations, it means one category contain many sub category's like if you take CAR's category we have many CAR brands that is store in sub category's
  • cars_table -------> sub_cars_table

Many To Many
in both tables each record can be related to number of records in the other table. For instance, and this kind of relationships require a third table

One to One
in both tables have only one record and each primary key value related to only one record in the related table. Thank you to Read

1 comment :

Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA

Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons