DATABSE
DATABSE
1. Data In simple words data can be facts related to any object in consideration. For example your name, age, height, weight, etc are
some data related to you. A picture , image , file , pdf etc can also be considered data.
2. Database is a systematic collection of data. Databases support storage and manipulation of data. Databases make data
management easy. Let's discuss few examples. Student Record maintain by Class Teacher and Teachers Data Maintain by Principal
3. Database Management System (DBMS) is a collection of programs which enables its users to access database, manipulate data,
reporting / representation of data.It also helps to control access to the database.
DBMS - Data Models: A Database model defines the logical design and structure of a database and defines how data will be stored,
accessed and updated in a database management system. While the Relational Model is the most widely used database model it is
only read in our course , there are other models too.
(i) Hierarchical Model: This database model organises data into a tree-like-structure, with a single root, to which all the other data is
linked. The hierarchy starts from the Root data, and expands like a tree, adding child nodes to the parent nodes.
(ii) Network Model : This is an extension of the Hierarchical model. In this model data is organized more like a graph, and are allowed
to have more than one parent node.
(iii) Relational Model: In this model, data is organized in two-dimensional tables and the relationship is maintained by storing a
common field. It has been the most widely used database model, infect, we can say the only database model used around the
world.The basic structure of data in the relational model is tables. All the information related to a particular type is stored in rows of
that table.Hence, tables are also known as relations in relational model. In Class XII we will learn how to design tables and how to use
Structured Query language to access data from tables.
Domains – All the possible allowable values for an attribute. This is slightly different to the data type of the attribute.
Primary Key-A Uniquely Indentify attribute in relation is called Primary Key.(Ex. Roll No in Student Record Register)
Candidate Key -Is an attribute or set of attributes that uniquely identifies a record. Among the set of candidate, one candidate key is
chosen as Primary Key (i.e. candidate of Primary Key) .(Ex. Roll No and SRNO in Student Record Register)
Alternate Keys- Are candidate keys that are not selected as primary key. Alternate key is also called “Secondary Key”.
Composite key-Iis a combination of more than one attributes that can be used to uniquely identity each record. It is also known as
“Compound” key. (Ex: Roll,Class, Sec in a school Assembly)
Foreign key -Is used to generate the relationship between the tables. Foreign Key is a field in database table that is Primary key in
another table. A foreign key can accept null and duplicate value.
SQL Provides many different types of commands used for different purpose. SQL commands can be mainly divided into following
categories
Data Definition Language (DDL) refers to the CREATE, ALTER and DROP statements.
DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema. DDL allows
to add / modify / delete the logical structures which contain the data or which allow users to access / maintain the data (databases,
tables).
Data Manipulation Language (DML) refers to the INSERT, UPDATE and DELETE statements
Data Query Language (DQL) refers to the SELECT, DESCRIBE and HELP statements (queries)
6. Relational Algebra:
Relational algebra is a procedural query language. It gives a step by step process to obtain the result of the query. It uses operators to
perform queries.
(i) Selection(σ) (ii) Projection (∏) (iii) Union(U) (iv) Intersection(∩) (v) Difference(-) (vi) Cartesian Product(X) (vii) Join(⋈)
Selection(σ): The select operation Selects tuples that satisfy a given predicate. It is denoted by sigma (σ).
Syntax : σ p(r)
Projection (∏):This operation shows the list of those attributes that we wish to appear in the result. Rest of the attributes are
eliminated from the table.It is denoted by ∏.
Union(U):When two or more relation are same domain and same degree then they can called Union Compatible.The union operation
performs the same function as the union operation in the set theory. It is represented by U symbol. If we perform an operation A U B
on table A and B, then the result would include all the tuples that are in table A as well as in table B. This operation removes the
duplicate tuples.
Intersection(∩):When two or more relation are same domain and same degree then they can participate in Intersection operation .The
intersect operation performs the same function as the intersect operation in the set theory. It is represented by ∩ symbol. This
operation selects all those tuples from the relation which are common in both the relation.
Difference(-):When two or more relation are same domain and same degree then they can participate in difference operation.The set
difference operation performs the same function as the set difference operation in the set theory. It is represented by -(minus)
symbol. If we perform an operation A-B on table A and B, then the result would include only those tuples that are in table A but not in
B. This operation removes all those tuples which are common in both table A and B, from A and gives output.
Cartesian Product(X):The Cartesian Product is also an operator which works on two sets. It is sometimes called the CROSS PRODUCT or
C.P.It combines the tuples of one relation with all the tuples of the other relation.
Join (⋈): Join can only be performed if there is a common attribute (column) between the relations. The name and type of the
attribute must be same.