Ddbmss
Ddbmss
The database is a collection of inter-related data which is used to retrieve, insert and delete
the data efficiently. It is also used to organize the data in the form of a table, schema,
views, and reports, etc.
Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used in
different applications.
DBMS provides an interface to perform various operations like database creation, storing
data in it, updating data, creating a table in the database and a lot more.
It provides protection and security to the database. In the case of multiple users, it also
maintains data consistency
Advantages of DBMS
Controls database redundancy: It can control data redundancy because it stores all the data
in one single database file and that recorded data is placed in the database.
Data sharing: In DBMS, the authorized users of an organization can share the data among
multiple users.
Easily Maintenance: It can be easily maintainable due to the centralized nature of the
database system.
Backup: It provides backup and recovery subsystems which create automatic backup of
data from hardware and software failures and restores the data if required.
multiple user interface: It provides different types of user interfaces like graphical user
interfaces, application program interfaces
Disadvantages of DBMS
Cost of Hardware and Software: It requires a high speed of data processor and large
memory size to run DBMS software.
Size: It occupies a large space of disks and large memory to run them efficiently.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Data Models
Data Model is the modeling of the data description, data semantics, and consistency
constraints of the data. It provides the conceptual tools for describing the design of a
database at each level of data abstraction. Therefore, there are following four data models
used for understanding the structure of the database:
1) Relational Data Model: This type of model designs the data in the form of rows and
columns within a table. Thus, a relational model uses tables for representing data and in-
between relationships. Tables are also called relations. This model was initially described by
Edgar F. Codd, in 1969. The relational data model is the widely used model which is
primarily used by commercial data processing applications.
4) Semistructured Data Model: This type of data model is different from the other three
data models (explained above). The semistructured data model allows the data
specifications at places where the individual data items of the same type may have
different attributes sets. The Extensible Markup Language, also known as XML, is widely
used for representing the semistructured data. Although XML was initially designed for
including the markup information to the text document, it gains importance because of its
application in the exchange of data
>>>>>>>>>>>>>>>>>>>>>>>>>>>
sql? data type in sql?
SQL stands for Structured Query Language. It is used for storing and managing data in
relational database management system (RDMS).
It is a standard language for Relational Database System. It enables a user to create, read,
update and delete relational databases and tables.
All the RDBMS like MySQL, Informix, Oracle, MS Access and SQL Server use SQL as their
standard database language.
SQL allows users to query the database in a number of ways, using English-like statements.
SQL process:
When an SQL command is executing for any RDBMS, then the system figure out the best
way to carry out the request and the SQL engine determines that how to interpret the task.
In the process, various components are included. These components can be optimization
Engine, Query engine, Query dispatcher, classic, etc.
All the non-SQL queries are handled by the classic query engine, but SQL query engine
won't handle logical files.
Datatype of SQL
1. Binary Datatypes
binary >>It has a maximum length of 8000 bytes. It contains fixed-length binary data.
varbinary>> It has a maximum length of 8000 bytes. It contains variable-length binary data.
image >>It has a maximum length of 2,147,483,647 bytes. It contains variable-length binary
data.
float -1.79E + 308 1.79E + 308 It is used to specify a floating-point value e.g. 6.2, 2.9 etc.
timestamp It stores the year, month, day, hour, minute, and the second value.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
operators in dbms???
Arithmetic Operators:
sql
Copy code
FROM employees;
Comparison Operators:
<> or != (Not equal to): Checks if two values are not equal.
< (Less than): Checks if the left operand is less than the right operand.
> (Greater than): Checks if the left operand is greater than the right operand.
<= (Less than or equal to): Checks if the left operand is less than or equal to the right
operand.
>= (Greater than or equal to): Checks if the left operand is greater than or equal to the right
operand.
sql
Copy code
SELECT product_name
FROM products
Logical Operators:
sql
Copy code
SELECT product_name
FROM products
Concatenation Operator:
sql
Copy code
FROM employees;
IN Operator:
sql
Copy code
SELECT product_name
FROM products
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dml
The DML commands in Structured Query Language change the data present in the SQL
database. We can easily access, store, modify, update and delete the existing records from
the database using DML commands.
SELECT Command
INSERT Command
UPDATE Command
DELETE Command
DELETE is a DML command which allows SQL users to remove single or multiple existing
records from the database tables.
This command of Data Manipulation Language does not delete the stored data
permanently from the database. We use the WHERE clause with the DELETE command to
select specific rows from the table.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
acid proprties??
DBMS is the management of data that should remain integrated when any changes are
done in it. It is because if the integrity of the data is affected, whole data will get disturbed
and corrupted. Therefore, to maintain the integrity of the data, there are four properties
described in the database management system, which are known as the ACID properties.
The ACID properties are meant for the transaction that goes through a different group of
tasks, and there we come to see the role of the ACID properties.
1) Atomicity
2) Consistency
3) Isolation
4) Durability
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
define ddl?
DDL changes the structure of the table like creating a table, deleting a table, altering a
table, etc.
All the command of DDL are auto-committed that means it permanently save all the
changes in the database.
CREATE
ALTER
DROP
TRUNCATE
b. DROP: It is used to delete both the structure and record stored in the table.
c. ALTER: It is used to alter the structure of the database. This change could be either to
modify the characteristics of an existing attribute or probably to add a new attribute.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Concurrency Control
Concurrency Control is the working concept that is required for controlling and managing
the concurrent execution of database operations and thus avoiding the inconsistencies in
the database. Thus, for maintaining the concurrency of the database, we have the
concurrency control protocols.
The concurrency control protocols ensure the atomicity, consistency, isolation, durability
and serializability of the concurrent execution of the database transactions. Therefore,
these protocols are categorized as:
>>>>>>>>>>>>>>>>>>>>>>
what is trigger?
This trigger is invoked in SQL after the modification of the data in the table.
This trigger is invoked before the inserting the record in the table.
This trigger is invoked before the updating the record in the table.
This trigger is invoked before deleting the record from the table.
>>>>>>>>>>>>>
The database system contains intricate data structures and relations. The developers keep
away the complex data from the user and remove the complications so that the user can
comfortably access data in the database and can only access the data they want, which is
done with the help of data abstraction.
The main purpose of data abstraction is to hide irrelevant data and provide an abstract
view of the data. With the help of data abstraction, developers hide irrelevant data from
the user and provide them the relevant data. By doing this, users can access the data
without any hassle, and the system will also work efficiently.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The three schema architecture is also used to separate the user applications and physical
database.
The three schema architecture contains three-levels. It breaks the database down into
three different categories.
The main objective of three level architecture is to enable multiple users to access the same
data with a personalized view while storing the underlying data only once. Thus it separates
the user's view from the physical structure of the database. This separation is desirable for
the following reasons:
The approach in which a particular user needs to see the data may change over time.
The users of the database should not worry about the physical implementation and internal
workings of the database such as data compression and encryption techniques, hashing,
optimization of the internal structures etc.
All users should be able to access the same data according to their requirements.
DBA should be able to change the conceptual structure of the database without affecting
the user's
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The transaction has the four properties. These are used to maintain consistency in a
database, before and after the transaction.
Property of Transaction
Atomicity
Consistency
Isolation
Durability
Atomicity
It states that all operations of the transaction take place at once if not, the transaction is
aborted.
There is no midway, i.e., the transaction cannot occur partially. Each transaction is treated
as one unit and either run to completion or is not executed at all.
Consistency
The integrity constraints are maintained so that the database is consistent before and after
the transaction.
The execution of a transaction will leave a database in either its prior stable state or a new
stable state.
The consistent property of database states that every transaction sees a consistent
database instance.
The transaction is used to transform the database from one consistent state to another
consistent state.
Isolation
It shows that the data which is used at the time of execution of a transaction cannot be
used by the second transaction until the first one is completed.
In isolation, if the transaction T1 is being executed and using the data item X, then that data
item can't be accessed by any other transaction T2 until the transaction T1 ends.
The concurrency control subsystem of the DBMS enforced the isolation property.
Durability
The durability property is used to indicate the performance of the database's consistent
state. It states that the transaction made the permanent changes.
They cannot be lost by the erroneous operation of a faulty transaction or by the system
failure. When a transaction is completed, then the database reaches a state known as the
consistent state. That consistent state cannot be lost, even in the event of a system's
failure.
The recovery subsystem of the DBMS has the responsibility of Durability property.
>>>>>>>>>>>>>
What is Normalization?
Normalization is the process of organizing the data in the database.
Normalization divides the larger table into smaller and links them using relationships.
The normal form is used to reduce redundancy from the database table.
The main reason for normalizing the relations is removing these anomalies. Failure to
eliminate anomalies leads to data redundancy and can cause data integrity and other
problems as the database grows. Normalization consists of a series of guidelines that helps
to guide you in creating a good database structure.
Advantages of Normalization
types of normalization>
2NF A relation will be in 2NF if it is in 1NF and all non-key attributes are fully functional
dependent on the primary key.
4NF A relation will be in 4NF if it is in Boyce Codd's normal form and has no multi-valued
dependency.
5NF A relation is in 5NF. If it is in 4NF and does not contain any join dependency, joining
should be lossless.
>>>>>>>>>>>>>>>>>>>
2>>In DBMS, data is generally stored in either a hierarchical form or a navigational form
4>>DBMS does not apply any security with regards to data manipulation.
5>>DBMS uses file system to store data, so there will be no relation between the tables
6>>DBMS has to provide some uniform methods to access the stored information.
8>>DBMS is meant to be for small organization and deal with small data. it supports single
user.
RDBMS
2>>In RDBMS, the tables have an identifier called primary key and the data values are
stored in the form of tables.
4>>RDBMS defines the integrity constraint for the purpose of ACID (Atomocity,
Consistency, Isolation and Durability) property.
5>>in RDBMS, data values are stored in the form of tables, so a relationship between these
data values will be stored in the form of a table as well.
6>>RDBMS system supports a tabular structure of the data and a relationship between
them to access the stored information.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
define 3nf?
A relation will be in 3NF if it is in 2NF and not contain any transitive partial dependency.
3NF is used to reduce the data duplication. It is also used to achieve the data integrity.
If there is no transitive dependency for non-prime attributes, then the relation must be in
third normal form.
define bcnf?
A table is in BCNF if every functional dependency X ? Y, X is the super key of the table.
For BCNF, the table should be in 3NF, and for every FD, LHS is super key.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Entities are stored in the database, and they should be distinguishable, i.e., they should be
easily identifiable from the group. For example, a group of pens that are from the same
company cannot be identified, so they are only objects, but pens with different colours
become unique and will be called an entity like a red pen, green pen, blue pen, black pen,
etc.
Kinds of Entity:
1. Tangible Entity:It is an entity in DBMS, which is a physical object that we can touch or
see. In simple words, an entity that has a physical existence in the real world is called a
tangible entity.
2. Intangible Entity:
It is an entity in DBMS, which is a non-physical object that we cannot see or touch. In simple
words, an entity that does not have any physical existence in the real world is known as an
intangible entity.
1. Strong Entity Type: It is an entity that has its own existence and is independent.
The entity relationship diagram represents a strong entity type with the help of a single
rectangle
2. Weak Entity Type: It is an entity that does not have its own existence and relies on a
strong entity for its existence.
The Entity Relationship Diagram represents the weak entity type using double rectangles
>>>>>>>>>>>>>>>>>>>
DBA also monitors the recovery and backup and provide technical support.
The DBA has a DBA account in the DBMS which called a system or superuser account.
DBA is the one having privileges to perform DCL (Data Control Language) operations such as
GRANT and REVOKE, to allow/restrict a particular user from accessing the database.
Naive / Parametric End Users : Parametric End Users are the unsophisticated who don’t
have any DBMS knowledge but they frequently use the database applications in their daily
life to get the desired results. For examples, Railway’s ticket booking users are naive users.
Clerks in any bank is a naive user because they don’t have any DBMS knowledge but they
still use the database and perform their given task.
System Analyst :
System Analyst is a user who analyzes the requirements of parametric end users. They
check whether all the requirements of end users are satisfied.
Sophisticated Users : Sophisticated users can be engineers, scientists, business analyst, who
are familiar with the database. They can develop their own database applications according
to their requirement. They don’t write the program code but they interact the database by
writing SQL queries directly through the query processor.
Database Designers : Data Base Designers are the users who design the structure of
database which includes tables, indexes, views, triggers, stored procedures and constraints
which are usually enforced before the database is created or populated with data. He/she
controls what data must be stored and how the data items to be related. It is responsibility
of Database Designers to understand the requirements of different user groups and then
create a design which satisfies the need of all the user groups.
Casual Users / Temporary Users : Casual Users are the users who occasionally use/access
the database but each time when they access the database they require the new
information, for example, Middle or higher level manager.
specialized database application that does not fit into the traditional data-
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
1. Select Operation:The select operation selects tuples that satisfy a given predicate.
2. Project Operation:
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 ?.
3. Union Operation:
Suppose there are two tuples R and S. The union operation contains all the tuples that are
either in R or S or both in R & S.
4. Set Intersection:
Suppose there are two tuples R and S. The set intersection operation contains all tuples
that are in both R & S.
It is denoted by intersection n.
5. Set Difference:
Suppose there are two tuples R and S. The set intersection operation contains all tuples
that are in R but not in S.
6. Cartesian product
The Cartesian product is used to combine each row in one table with each row in the other
table. It is also known as a cross product.
It is denoted by X.
7. Rename Operation:
The rename operation is used to rename the output relation. It is denoted by rho (?).
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
dynamic sql?
Dynamic SQL is a programming technique that could be used to write SQL queries during
runtime. Dynamic SQL could be used to create general and flexible SQL queries.
'SELECT statement';
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Types of keys:
1. Primary key
It is the first key used to identify one and only one instance of an entity uniquely. An entity
can contain multiple keys, as we saw in the PERSON table. The key which is most suitable
from those lists becomes a primary key.
2. Candidate key
A candidate key is an attribute or set of attributes that can uniquely identify a tuple.
Except for the primary key, the remaining attributes are considered a candidate key. The
candidate keys are as strong as the primary key.
3. Super Key
Super key is an attribute set that can uniquely identify a tuple. A super key is a superset of a
candidate key.
4. Foreign key
Foreign keys are the column of the table used to point to the primary key of another table.
5. Alternate key
There may be one or more attributes or a combination of attributes that uniquely identify
each tuple in a relation. These attributes or combinations of the attributes are called the
candidate keys. One key is chosen as the primary key from these candidate keys, and the
remaining candidate key, if it exists, is termed the alternate key. In other words, the total
number of the alternate keys is the total number of candidate keys minus the primary key.
The alternate key may or may not exist. If there is only one candidate key in a relation, it
does not have an alternate key.
6. Composite key
Whenever a primary key consists of more than one attribute, it is known as a composite
key. This key is also known as Concatenated Key.
7. Artificial key
The key created using arbitrarily assigned data are known as artificial keys. These keys are
created when a primary key is large and complex and has no relationship with many other
relations. The data values of the artificial keys are usually numbered in a serial order.
>>>>>>>>>>>>>>>>>>>>>>>
DDL stands for Data Definition Language. It is used to define database structure or pattern.
Using the DDL statements, you can create the skeleton of the database.
DML stands for Data Manipulation Language. It is used for accessing and manipulating data
in a database. It handles user requests.
Types of Database Languages
DCL stands for Data Control Language. It is used to retrieve the stored or saved data.
(But in Oracle database, the execution of data control language does not have the feature
of rolling back.)
TCL is used to run the changes made by the DML statement. TCL can be grouped into a
logical transaction.
Rollback: It is used to restore the database to original since the last Commit.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Cardinality
Cardinality means how the entities are arranged to each other or what is the relationship
structure between entities in a relationship set. In a Database Management System,
Cardinality represents a number that denotes how many times an entity is participating
with another entity in a relationship set. The Cardinality of DBMS is a very important
attribute in representing the structure of a Database. In a table, the number of rows or
tuples represents the Cardinality.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
er model??
ER model stands for an Entity-Relationship model. It is a high-level data model. This model
is used to define the data elements and relationship for a specified system.
It develops a conceptual design for the database. It also develops a very simple and easy to
design view of data.