Beruflich Dokumente
Kultur Dokumente
Material
Structure
There are number of possible data structures such as flat file, RDBMS etc.
RDBMS:
In RDBMS, data is stored in the form of table. Each table consist of rows and columns.
Row : Record (Horizontal, if you store 10 student details in a table, you will have 10 rows)
Column: Vertical group of values within a table. It contains values from a single field (E.g. S. No.)
Null : A field with a NULL value is one that has been left blank during record creation.
SQL Commands
There can be divided into four sub groups such as DDL, DML, DCL, DQL
DDL : Data Definition Language, statements are used to define the database structure
DML : Data manipulation Language, used to store, retrieve, modify & delete data from database
DCL : Data Control Language, used to give right/permission for a data access
DQL : Data Query Language, used to read the data from database
E.g. SELECT
Update anomalies : When we try to update one data item having its copies scattered over several
places, a few instances get updated properly while a few others are left with old values. So data will be
inconsistent
Deletion anomalies : When we try to delete one data item having its copies scattered over several
places, a few instances get deleted properly while a few others are left in database. So data will be
inconsistent
Insertion anomalies : Consider a Student table with course details in same table. If I want to add a
course, I need to give student details as well. So I can’t add new course without student record. This is
called insertion anomalies.
There are 3 important normal forms 1st, 2nd and 3rd. Additional forms like Boyce Codd Normal form also
available.
In Short
Student Table:
Here Student_Id & Project_Id are prime attributes (primary keys) where Student_Name & Project_Name
are non-prime attributes (not primary keys).
According to 2nd Normal Form, every non-prime attribute should dependent on all prime attributes in
the table. In the above example, Student_Name is dependent on prime key Student_Id, Project_Name is
dependent on Project_Id.
As 2nd Normal Form states, Student_Name & Project_Name both should dependent on Student_Id &
Project_Id. If it’s not dependent on both separate them into new table.
Student table:
Project table:
Project_Id Project_Name
Here Book_id determines the Book_type_id. Book_type_id determines the Book_type. So Book_type
transitively depends on Book_id. Rule of 3rd Normal Form is, If transitively dependent appear in a table,
separate them into two tables.
BCNF:
Its slightly stronger version of 3rd Normal form. So called 3.5 Normal Form.
A relational schema R is in Boyce–Codd normal form if and only if for every one of its dependencies X →
Y, at least one of the following conditions hold:
Please read example from this web site which gives better understanding about BCNF
http://www.vertabelo.com/blog/technical-articles/boyce-codd-normal-form-bcnf
SQL Clauses:
WHERE clause : Where clause is used to specify condition while retrieving data from table
Like clause : Like clause is used as condition in SQL query. Like clause compares data with an
expression using wildcard operators.
Group by : Used to group results of a SELECT query based on one or more columns.
Distinct : Used with Select statement to retrieve unique values from the table
Aggregate Functions:
These functions return a single value after calculating from a group of values
avg() – average,
Transaction
A transaction can be defined as a group of tasks. A single task is the minimum processing unit which
cannot be divided further (E.g. Update/Insert/Delete are task which can’t be further divided).
Dead lock
In a multi-process system, deadlock is an unwanted situation, where a transaction indefinitely waits for
a resource that is held by another transaction.
For every transaction enters system (let’s say Ti) create a node in graph (a circle). If Ti request a resource
X which is held by transaction Tj, then draw a directed edge from Ti to Tj.