Database Concepts -Part II(Brief Introduction) 

Primary Key & Foreign Key Constraints

When Primary key of any table is included in any other table then this column is referred to as Foreign

key.Let us see this through an example. In our student table , Admission No is Primary key so as to identify each and every student. Let us make another table "Monthly_Fee" in which we store monthly fee

paid by each student in every month, to accomodate this we make following table as

Monthly_Fee

Fee_Month,

Fee_Date,(Primary Key)

Admission_No (Foreign Key)

Receipt_No(Primay Key)

Fee_amount & so on 

Two or more column can be combined to defined as Composite Primary Key

Here we define Receipt_No + Fee_Date column as Composite Primary Key.

Most Commonly used SQL Command: To access column(s) from database table, one can

use SELECT command ,Syntax of Select command as follows:

Select Column(s) from Table where condition(Column name)

one can select multiple Column name separated by comma, From Database Table name where

Some condition has to be fulfilled,In our case we use following Select command

Select Admission_no, Fee_Month From Monthly_fee where Receipt_no = 123;

Select,From,Where are reserved words in SQL, all SQL commands terminate with semicolon(;)

Thats All for Today.. 

Will give some more Commands with example in  next session...

Till the Happy Learning!!!


 

Comments