Unit - 1 - Database Concepts
Unit - 1 - Database Concepts
Data :
➢ Data is a collection of raw facts which have not been processed to reveal
useful information.
Information:
➢ It is produced by processing of data.
Database:
➢ May be defined as a collection of interrelated data stored together to serve
multiple applications.
➢ It is a computer based record keeping system.
➢ It not only allows to store but also allows us modification of data as per
requirements.
DBMS :
➢ A DBMS refers to the Database Management System.
➢ It is a software that is responsible for storing,manipulating, maintaining and
utilizing databases.
➢ A database along with a DBMS is referred to as a database system.
➢ DBMS softwares are : Oracle, MySQL , Sybase, SQLite, etc..
Purpose of DBMS:
➢ Database reduces Redundancy (Reduction in Redundancy):
It removes duplication of data because data is kept at one place and all
the application refers to the centrally maintained database.
➢ Database controls Inconsistency (Improved Consistency:
When two copies of the same data do not agree to each other, then it is
called Inconsistency. By controlling redundancy, the inconsistency is also
controlled.
➢ Database facilitate sharing of Data(Improved Availability):
Data stored in the database can be shared among several users.
➢ Database ensures Security (Improved Security):
Data is protected against accidental or intentional disclosure to
unauthorized persons or unauthorized modification.
➢ Database maintains Integrity:
It enforces certain integrity rules to insure the validity or correctness
of data. For Example. A date cannot be like 25/25/2000.
➢ Database enforces Standard:
Database is maintained in a standard format which helps to data
interchange or migration of data between two systems.
➢ User Friendly:
Using a DBMS. it becomes very easy to access, modify and delete
data. It reduces
the dependency of users on computer specialists to perform various dara
related operations in a DBMS because of its user friendly interface.
Relational Database:
➢ In relational databases model data is organized into tables. (i.e. rows and
columns).
➢ These tables are also known as relations.
➢ A row in a table represents relationships among a set of values.
➢ A column represents the field/attributes related to the relation under which
information will be stored.
➢ For Example, If we want to store details of a student then: Roll_No, Name,
Class, Section, etc. will be the column/attributes and the collection of all the
column information will become a Row/Record.
Relation (Table):
➢ A Relation or Table is Matrix like structure arranged in Rows or Columns.
Domain:
➢ The data type of values in each column is called the Domain.
Attribute / Field:
➢ Column of a table is called Attribute or Field.
Degree:
➢ Number of columns (attributes) in a table.
Cardinallity :
➢ Number of rows (record) in a table.
Concept of Keys:
➢ In relation each record must be unique. i.e no two identical records are
allowed in the database. A key attribute identifies the record and must have
unique values. There are various types of Keys:
Primary Key:
➢ A set of one or more attribute that can identify a record uniquely in the
relation is called Primary Key
➢ 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 leave it blank.
Candidate Key:
➢ In a table there can be more than one attribute which contains unique values.
These columns are known as candidate key as they are the candidate for
primary key.
➢ Among these database analysts select one as a primary key based on
requirements like must contain unique value, compulsory entry and where
maximum searching is done etc.
Alternate Key:
Foreign Key:
➢ Used to create relationships between two tables.
➢ It is a non-key attribute whose value is derived from the Primary key of
another table.
➢ Foerign key column will be the value in the Primary key of another table, if
present then entry will be allowed otherwise data will be rejected.
➢ Primary key column table from which values will be derived is known as
Primary Table or Master Table or Parent Table.
➢ Foregin key column table will be Foreign Table or Detail Table or Child
Table.
Super Key:
➢ A superkey is a group of single or multiple keys which identifies rows in a
table. A Super key may have additional attributes that are not needed for
unique identification.
Types of Constraints:
Primary Key Constraint , Unique Constraint, Not Null Constraint, Default
Constraint, Check Constraint
➢ Ensuring unique value in any column also forces data entry mandatory. only
one primary key can be applied in one table.
Unique Contraints:
➢ also allows unique value in any column but it allows NULL values and can
be applied to n times.
Check Constraint:
➢ allows to specify a range of values that can be entered in an applied column
like salary must be greater than 2000, marks must be greater than 0 or dept
must be in a given list of values etc. Note: in mysql the database engine
will ignore the check constraints.
Default Constraint:
➢ it allows to specify any value which will be automatically inserted in applied
column if we not specify applied column at the time of data entry using
INSERT
➢ It allows you to create database objects like creating a table, view or any
other database objects.
➢ The information about created objects are stored in special file called DATA
DICTIONARY
➢ DATA DICTIONARY contains metadata i.e. data about data.
➢ While creating a table DDL allows to specify – name of table, attributes,
data types of each attribute, may define range of values that attributes can
store, etc
➢ Major commands of DDL are – CREATE, ALTER, DROP
DDL Commands: