4.Database Concepts
4.Database Concepts
Data:
Importance of Data:
Human beings rely on data for making decisions. Besides, large amount of data when processed
with the help of a computer, show us the possibilities or hidden traits which are otherwise not
visible to humans. When one withdraws money from ATM, the bank needs to debit the
withdrawn amount from the linked account. So the bank needs to maintain data and update it as
and when required. The meteorological offices continuously keep on monitoring satellite data
for any upcoming cyclone or heavy rain.
Data of a student:
Name - Arun
Class- VI
Sec- A
Age- 11
Father’s name- Kumar
Mother’s Name- Geetha
Phone no- 9834512345
we need to explore the methods to store and manage data electronically.
Mark Register
Student ID Name Mark1 Mark2 Mark3 Total
1011A Arun 87 78 68
Staff Department
Emlpoyee id EmpDepartment Empname desiganamtion
T101 D10 Jai Manager
T102 D20 Ravi Sales
T103 D30 Sujatha SPARES
Manager
Departments STAFFRecord:
Empdept Check in time Check out time
D10 12,30 4.30pm
D20 9am 5,30
D30 3pm 6pm
D45 4pm 7pm
D453 3pm 9pm
Empname EmpSalary
Jai 25000
Sujatha 25000
The above table we view employees who have a salary of 25000
A view can just like any other table. It can be queried, updated, inserted into, deleted
from, and join with other tables and view
Advantages of view
We have great control over your data
We can give people access to some but not all of the information in a table
Read only view can also be given(cannot update)
Structure of Relational database
Each attribute as a set of permitted values called the domain of that attribute
Keys:
Primary key-
is a set of one or more attributes that can uniquely identify tuples within the relation.
There can be only 1 primary key in a table.
Allows only distinct (no duplicate) values and also forces mandatory entry (NOT
NULL) i.e. we cannot left it blank.
Candidate key-All attribute combinations inside a relation that can serve as primary key are
candidate keys as they are candidates for the primary key position
Alternate key-A candidate key that is not the primary key is called an Alternate Key.
Foreign Key- is a non-key attribute whose value is derived from the primary key of another
table is known as foreign key in its current table
REFERENTIAL INTEGRITY –is a rule that a DBMS uses to ensure relationship between
records in related tables are valid and user don’t accidentally delete or change the related data.
When referential integrity is enforced using Foreign Key you must observe the following
rules:
You cannot enter a value in Child Table which is not available in Master Table’s
Primary key column. However you can enter NULL values in foreign key.
Ex: we cannot have a order that is assigned to a customer that doesn’t exist.
You cannot delete a record from Master Table if matching record exists in related table.
Ex: we cannot a employee from employee table if there are orders assigned to the
employee in Order table
You cannot modify or change the Primary Key value in Master table if its matching
record is present in related table.
Ex: we cannot change the employee id in the employee table if there are orders
assigned to the employee in Order table.