0% found this document useful (0 votes)
57 views

4th Assignment

The document discusses various database concepts including: 1. The ACID principles which ensure reliability in databases through atomicity, consistency, isolation, and durability. 2. Temporary tables which are visible only to the current session and are automatically dropped when the session ends, making them useful for testing. 3. Normalization which organizes data to minimize redundancy and eliminate anomalies through various normal forms up to 5NF. 4. Additional concepts covered include testing databases, entity relationship diagrams, class diagrams, data flow diagrams, different types of joins, try/catch error handling, and the differences between stored procedures and functions.

Uploaded by

Vim Sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

4th Assignment

The document discusses various database concepts including: 1. The ACID principles which ensure reliability in databases through atomicity, consistency, isolation, and durability. 2. Temporary tables which are visible only to the current session and are automatically dropped when the session ends, making them useful for testing. 3. Normalization which organizes data to minimize redundancy and eliminate anomalies through various normal forms up to 5NF. 4. Additional concepts covered include testing databases, entity relationship diagrams, class diagrams, data flow diagrams, different types of joins, try/catch error handling, and the differences between stored procedures and functions.

Uploaded by

Vim Sam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Name: Rahim Suwal Roll No.

: 30 Database Development and


Design

1. ACID principle
ACID is an acronym for (Atomicity Consistency Isolation Durability). It a concept
used to evaluate databases and application architectures. For a reliable database all
these four attributes should be achieved.
Atomicity is all-or-none proposition.
Consistency guarantees that a transaction never leaves your database in a half-
finished state.
Isolation keeps the transactions separated from each other until they’re finished.
Durability guarantees that a database will keep track of pending changes in such a
way that the server can recover from an abnormal termination.
All these four rules are very important for any developers dealing in database.

2. Temporary table
A temporary table is that type of table that is visible only to the current session, and is
dropped automatically when the session in which it was created is closed. They are
not stored in the database permanently so it would be useful in situation where you
need table for a short time to perform some kind of testing after which you want it to
disappear.

The syntax of to create temporary table is:


CREATE TEMPORARY TABLE table_name (column definations);

Creating a temporary table of an existing table


Temporary table can be used in such situations where you just want to test SQL
queries without affecting the database.
The following command creates it
CREATE TEMPORARY TABLE persons SELECT * FROM persons;
The above statement creates a temporary table named persons on top of result set of
an existing base table persons. Since it is a temporary copy of the persons table, we
can perform any operations like INSERT, DELETE and UPDATE without affecting
the original persons table.

Dropping Temporary tables


Temporary tables are automatically dropped whenever the session in which they are
created is over. If we want to delete the temporary table before the end of the session,
we use the following syntax.
DROP TEMPORARY TABLE persons;
3. Normalization
Normalization is the process of organizing the data in the database. It is used to
minimize the redundancy from a relation or set of relations. It is also used to eliminate
the unwanted characteristics like insertion, update and deletion anomalies.

There are four types of normal forms:


1NF
A relation is in 1NF if it contains an atomic value.

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.

3NF
A relation will be in 3NF if it is in 2NF and no transition dependency exists.

4NF
A relation will be in 4NF if it is in Boyce Codd normal form and has no multi-valued
dependency.

5NF
A relation is in 5NF if it is in 4NF and not contains any joins dependency and joining
should be lossless.

4. Testing
Database Testing is checking the schema, tables, triggers, etc. of the database under
test. It may involve creating complex queries to load/stress test the database and check
its responsiveness. It Checks data integrity and consistency.

5. ER diagram
Entity relationship diagram displays the relationships of entity set stored in a
database. In other words, we can say that ER diagrams help you to explain the logical
structure of databases. At first look, an ER diagram looks very similar to the
flowchart. However, ER Diagram includes many specialized symbols, and its
meanings make this model unique.

Uses of ER diagram

 Helps you to define terms related to entity relationship modeling


 Provide a preview of how all your tables should connect, what fields are going to be
on each table
 Helps to describe entities, attributes, relationships
 ER diagrams are translatable into relational tables which allows you to build
databases quickly
 ER diagrams can be used by database designers as a blueprint for implementing data
in specific software applications

This model is based on three basic concepts:

 Entities
 Attributes
 Relationships
6. Class Diagram
Class Diagram gives the static perspective on an application. A class diagram depicts
the kinds of items in the framework and the various sorts of connections that exist
among them. This displaying strategy can run with practically all Object-Oriented
Methods. A class can allude to another class. A class can have its items or may
acquire from different classes.

UML Class Diagram gives an outline of a product framework by showing classes,


traits, activities, and their connections. This Diagram incorporates the class name,
properties, and activity in isolated assigned compartments.

Class Diagram helps build the code for the product application advancement.

7. DF Diagram
Words usually can't do a picture justice. A Data Flow Diagram (DFD) is a customary
method to picture the data streams inside a framework. A slick and clear DFD can
delineate a decent measure of the framework necessities graphically. It very well may
be manual, mechanized, or a mix of both.

It shows how data enters and leaves the framework, what changes the data and where
data is put away. The reason for a DFD is to show the extension and limits of a
framework all in all. It might be utilized as a specialized instrument between a
frameworks expert and any individual who has an impact in the framework that goes
about as the beginning stage for overhauling a framework.

It is generally starting with a setting graph as level 0 of the DFD outline, a


straightforward portrayal of the entire framework. To expound further from that, we
drill down to a level 1 outline with lower-level capacities deteriorated from the
significant elements of the framework. This could keep on advancing to turn into a
level 2 outline when further examination is required. Movement to levels 3, 4, etc is
conceivable yet anything past level 3 isn't exceptionally normal. It would be ideal if
you remember that the degree of detail for deteriorating a specific capacity relying
upon the intricacy that capacity.

8. Join
There are four fundamental sorts of SQL joins: inner, left, right, and full. The simplest
and most natural approach to clarify the distinction between these four kinds is by
utilizing a Venn chart, which shows all conceivable consistent relations between
informational collections.

Once more, it's critical to stretch that before you can start utilizing any join type,
you'll have to separate the information and burden it into a RDBMS like Amazon
Redshift, where you can inquiry tables from numerous sources. You fabricate that
procedure physically, or you can utilize an ETL administration like Stitch, which
mechanizes that procedure for you.

Suppose we have two arrangements of information in our social database: table An


and table B, with a connection indicated by essential and remote keys. The aftereffect
of consolidating these tables can be outwardly spoken to by the accompanying graph:

The degree of the overlap, assuming any, is controlled by what number of records in
Table A match the records in Table B. Contingent upon what subset of information
we might want to choose from the two tables, the four join types can be imagined by
featuring the comparing areas of the Venn outline:
Select all records from Table A and Table B, where the join condition is met.

Select all records from Table A, along with records from Table B for which the join
condition is met (if at all).

Select all records from Table B, along with records from Table A for which the join
condition is met (if at all).

Select all records from Table A and Table B, regardless of whether the join condition
is met or not.
9. Try catch
The SQL Try Catch helps you to handle the errors in query effectively. For example,
we write a series of statements inside the TRY block. If the SQL Server finds an error,
then it exits from the TRY block and enters into the CATCH block, it executes the
statements inside the CATCH block. And lastly, it will return the corresponding error
description.
Things to remember:
Coming up next are the rundown of things that you need to recollect before you begin
working with the SQL Try get

The CATCH square should promptly follow each TRY square. You are not permitted
to incorporate any announcements between the END TRY, and BEGIN CATCH

On the off chance that there are no mistakes in a TRY hinder, the control won't go
into the CATCH square. It implies the controller will execute articulations after the
END CATCH.

On the off chance that there is a mistake in the TRY square, it quickly exits from the
Try square and goes into the Catch square.

The SQL TRY CATCH will get all the mistakes whose seriousness is higher than the
10, and lower than 20.

SQL permits you to utilize the Nested TRY squares (TRY CATCH inside another).

Be that as it may, CATCH square cannot deal with the gather blunders like Syntax
mistakes

Try Catch syntax


BEGIN TRY
-- SQL Statements;
END TRY
BEGIN CATCH
--SQL Statements;
END CATCH
SQL try catch example

-- Example for SQL Server TRY CATCH Block


BEGIN TRY
SELECT 10/0 AS Result;
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS [Error Message]
,ERROR_LINE() AS ErrorLine
,ERROR_NUMBER() AS [Error Number]
,ERROR_SEVERITY() AS [Error Severity]
,ERROR_STATE() AS [Error State]
END CATCH

Output
10. Difference between SP and function

Function Stored Procedure

        The function always returns a value. Stored Procedure will not return a value, but the
procedure can return “0” or n values.

        Functions have only input parameters for it. Whereas, Procedures can have output or input
parameters.

       You can call Functions can be from Procedure. But the vice-versa is not correct. As you can’t call
Procedures from a Function.
References

https://intellipaat.com/community/3394/function-vs-stored-procedure-in-sql-server
https://www.guru99.com/
https://www.tutorialspoint.com/sql/index.htm

You might also like