DBMS Modified 1
DBMS Modified 1
Entity − An entity in an ER Model is a real-world The main highlights of this model are −
entity having properties called attributes. Data is stored in tables called relations.
Metadata itself follows a layered architecture, so that when we Data Definition Language (DDL)
change data at one layer, it does not affect the data at another It is a language that allows the users to define data and their
level. This data is independent but mapped to each other. relationship to other types of data. It is mainly used to create
Logical Data Independence files, databases, data dictionary and tables within databases.
Logical data is data about database, that is, it stores
information about how data is managed inside. For example, a It is also used to specify the structure of each table, set of
table (relation) stored in the database and all its constraints, associated values with each attribute, integrity constraints,
applied on that relation. security and authorization informationfor each table and
Logical data independence is a kind of mechanism, which physical storage structure of each table on disk.
liberalizes itself from actual data stored on the disk. If we do The following table gives an overview about usage of DDL
statements in SQL
ER Diagram Representation
Let us now learn how the ER Model is represented by means
of an ER diagram. Any object, for example, entities, attributes
of an entity, relationship sets, and attributes of relationship
sets, can be represented with the help of an ER diagram.
Entity Multivalued attributes are depicted by double ellipse.
Entities are represented by means of rectangles. Rectangles
are named with the entity set they represent.
Attributes
Attributes are the properties of entities. Attributes are
represented by means of ellipses. Every ellipse represents one
attribute and is directly connected to its entity (rectangle). Derived attributes are depicted by dashed ellipse.
Specialization
Specialization is the opposite of generalization. In For example, the attributes of a Person class such as name,
specialization, a group of entities is divided into sub-groups age, and gender can be inherited by lower-level entities such
based on their characteristics. Take a group ‘Person’ for as Student or Teacher.
example. A person has name, date of birth, gender, etc. These
properties are common in all persons, human beings. But in a 2.6 Data Dictionary
company, persons can be identified as employee, employer,
customer, or vendor, based on what role they play in the A data dictionary is a file or a set of files that contains a database's
company. metadata. The data dictionary contains records about other objects in
the database, such as data ownership, data relationships to other
objects, and other data.
Notation − r U s
Where r and s are either database relations or relation result Output − Yields a relation, which shows all the books and
set (temporary relation). articles written by tutorialspoint.
For a union operation to be valid, the following conditions Rename Operation (ρ)
must hold − The results of relational algebra are also relations but without
r, and s must have the same number of attributes. any name. The rename operation allows us to rename the
Attribute domains must be compatible. output relation. 'rename' operation is denoted with small
Duplicate tuples are automatically eliminated. Greek letter rho ρ.
∏ author (Books) ∪ ∏ author (Articles) Notation − ρ x (E)
Where the result of expression E is saved with name of x.
Output − Projects the names of the authors who have either Division (÷)
written a book or an article or both. The division is a binary operation that is written as R ÷ S. Division is
Set Difference (−) not implemented directly in SQL. The result consists of the
The result of set difference operation is tuples, which are restrictions of tuples in R to the attribute names unique to R, i.e., in
present in one relation but are not in the second relation. the header of R but not in the header of S, for which it holds that all
Notation − r − s their combinations with tuples in S are present in R. For an example
Finds all the tuples that are present in r but not in s. see the tables Completed, DBProject and their division:
∏ author (Books) − ∏ author (Articles)
Completed DBProject Completed÷ DBProject
Fred Compiler1
DBMS - Joins
We understand the benefits of taking a Cartesian product of
two relations, which gives us all the possible tuples that are
Eugene Database1
paired together. But it might not be feasible for us in certain
cases to take a Cartesian product where we encounter huge
relations with thousands of tuples having a considerable large
Eugene Compiler1
number of attributes.
Join is a combination of a Cartesian product followed by a
selection process. A Join operation pairs two tuples from
Sarah Database1
different relations, if and only if a given join condition is
satisfied.
We will briefly describe various join types in the following
Sarah Database2
sections.
Theta (θ) Join
If DBProject contains all the tasks of the Database project, then the Theta join combines tuples from different relations provided
result of the division above contains exactly the students who have they satisfy the theta condition. The join condition is denoted
completed both of the tasks in the Database project. by the symbol θ.
The Assignment Operation Notation
Sometimes it is useful to be able to write a relational algebra R1 ⋈θ R2
expression in parts using a temporary relation variable (as we did R1 and R2 are relations having attributes (A1, A2, .., An) and
with and in the division example). (B1, B2,.. ,Bn) such that the attributes don’t have anything in
The assignment operation, denoted , works like assignment in a common, that is R1 ∩ R2 = Φ.
programming language. Theta join can use all kinds of comparison operators.
We could rewrite our division definition as Student
101 Alex 10
Student_detail HoD
100 Database A B C D
A B C D
∏designation, salary (Employee)
Find the eno and salary of all employees whose salary is
10 Database 10 Alex more than 5000.
0 0
∏eno, salary σsalary>5000(Employee)
10 Mechanics --- --- 2. Consider the following relation given below. (2007)
1
REVOKE
ALTER 2
Takes back privileges granted from user.
2 Modifies an existing database What is a NULL value?
object, such as a table. A NULL value in a table is a value in a field that appears to be
blank, which means a field with a NULL value is a field with no
value.
DROP It is very important to understand that a NULL value is different
than a zero value or a field that contains spaces. A field with a
Deletes an entire table, a view of a NULL value is the one that has been left blank during a record
3 creation.
table or other objects in the 4.2 Basic structure of SQL - Syntax
database. SQL is followed by a unique set of rules and guidelines called
Syntax. This tutorial gives you a quick start with SQL by listing all
DML - Data Manipulation Language the basic SQL Syntax.
All the SQL statements start with any of the keywords like
Sr.No. Command & Description SELECT, INSERT, UPDATE, DELETE, ALTER, DROP,
CREATE, USE, SHOW and all the statements end with a
SELECT semicolon (;).
1
Retrieves certain records from one or more tables. The most important point to be noted here is that SQL is case
insensitive, which means SELECT and select have same meaning in
ALL OR
1 The ALL operator is used to compare a value to all 9 The OR operator is used to combine multiple
values in another value set. conditions in an SQL statement's WHERE clause.
AND IS NULL
2 The AND operator allows the existence of multiple 10 The NULL operator is used to compare a value with a
conditions in an SQL statement's WHERE clause. NULL value.
ANY UNIQUE
3 The ANY operator is used to compare a value to any 11 The UNIQUE operator searches every row of a
applicable value in the list as per the condition. specified table for uniqueness (no duplicates).
SQL - Expressions
+----+----------+-----+-----------+----------+ or
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+ SELECT FROM table_name
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 | WHERE column LIKE 'XXXX_'
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | kaushik | 23 | Kota | 2000.00 | or
+----+----------+-----+-----------+----------+ This would produce the following result where we do not have any
| ID | NAME | AGE | ADDRESS | SALARY | duplicate entry.
+----+----------+-----+-----------+----------+ +----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 | | SALARY |
| 2 | Khilan | 25 | Delhi | 1500.00 | +----------+
| 3 | kaushik | 23 | Kota | 2000.00 | | 1500.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 | | 2000.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 | | 4500.00 |
| 6 | Komal | 22 | MP | 4500.00 | | 6500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 | | 8500.00 |
+----+----------+-----+-----------+----------+ | 10000.00 |
First, let us see how the following SELECT query returns the +----------+
duplicate salary records. SQL - SORTING Results
SQL> SELECT SALARY FROM CUSTOMERS The SQL ORDER BY clause is used to sort the data in ascending
ORDER BY SALARY; or descending order, based on one or more columns. Some
databases sort the query results in an ascending order by default.
This would produce the following result, where the salary (2000) is Syntax
coming twice which is a duplicate record from the original table. The basic syntax of the ORDER BY clause which would be used to
+----------+ sort the result in an ascending or descending order is as follows −
| SALARY | SELECT column-list
+----------+ FROM table_name
| 1500.00 | [WHERE condition]
| 2000.00 | [ORDER BY column1, column2, .. columnN] [ASC | DESC];
| 2000.00 |
| 4500.00 | You can use more than one column in the ORDER BY clause.
| 6500.00 | Make sure that whatever column you are using to sort, that column
| 8500.00 | should be in the column-list.
| 10000.00 | Example
+----------+ Consider the CUSTOMERS table having the following records −
+----+----------+-----+-----------+----------+
According to E. F. Codd the objectives of normalization Each attribute must contain only a single value from its pre-
were stated as follows: defined domain.
1. To free the collection of relations from undesirable Second Normal Form
insertion, update and deletion dependencies. Before we learn about the second normal form, we need to
2. To reduce the need for restructuring the collection of understand the following −
relations as new types of data are introduced, and thus Prime attribute − An attribute, which is a part of the
increase the life span of application programs. candidate-key, is known as a prime attribute.
3. To make the relational model more informative to users. Non-prime attribute − An attribute, which is not a
4. To make the collection of relations neutral to the query part of the prime-key, is said to be a non-prime
statistics, where these statistics are liable to change as time attribute.
goes by. If we follow second normal form, then every non-prime
attribute should be fully functionally dependent on prime key
As of now there are total 8 normal forms, but to keep our data attribute. That is, if X → A holds, then there should not be
consistent & non-redundant the first 3 Normal Forms are any proper subset Y of X, for which Y → A also holds true.
sufficient.
Note that all three attributes make up the Primary Key. Unit-7
Firewall
There are two types of Firewall system: One works by using filters at Unit-8
the network layer and the other works by using proxy servers at the
Transaction management, Recovery and Query processing
user, application, or network layer.
Key Points
Firewall management must be addressed by both system 8.1 Introduction to transaction
managers and the network managers.
The amount of filtering a firewall varies. For the same A transaction can be defined as a group of tasks. A single task
firewall, the amount of filtering may be different in is the minimum processing unit which cannot be divided
different directions. further.
Let’s take an example of a simple transaction. Suppose a bank
employee transfers Rs 500 from A's account to B's account.
This very simple and small transaction involves several low-
level tasks.
A’s Account
Open_Account(A)