Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 29

The databases and data warehouse , both are used to store the data, which can be used by computer

for
processing the information and give desired results to the user.
The major differences between the Databases and Data Warehouses are as follows:-

FEATURES DATABASE DATA WAREHOUSE

Characteristic It is based on Operational It is based on Informational


Processing. Processing.

Data It mainly stores the Current data  It usually stores the Historical data
which always guaranteed to be up- whose accuracy is maintained over
to-date. time.

Function It is used for day-to-day operations. It is used for long-term


informational requirements and
decision support.

User The common users are clerk, DBA, The common users are knowledge
database professional. worker (e.g., manager, executive,
analyst)
Unit of work Its work consists of short and simple The operations on it consists of
transaction. complex queries..

Focus The focus is on “Data IN” The focus is on “Information OUT”

Orientation The orientation is on Transaction. The orientation is on Analysis.

DB design The designing of database is ER The designing is done using


based and application-oriented. star/snowflake schema and its
subject-oriented.

Summarization The data is primitive and highly The data is summarized and in
detailed. consolidated form.

View The view of the data is flat The view of the data is
relational. multidimensional.

Access The most frequent type of access It mostly use the read access for the
type is read/write. stored data.

Operations The main operation is index/hash on For any operation it needs a lot of
primary key. scans.

Number of records accessed A few tens of records. A bunch of millions of records.

Number of users In order of thousands. In the order of hundreds only.

DB size 100 MB to GB. 100 GB to TB.

High performance, high availability High flexibility, end-user autonomy


Priority

Metric To measure the efficiency, To measure the efficiency, query


transaction throughput is measured. throughput and response time is
measured.

 
Based on these differences, we can say that the Database is suitable for the traditional type of data
storage technique in which the importance is given to the transactional processing, while the Data
Warehouse is a modern form of data storage technique which is used for processing huge amount of
data to extract useful information from it.

Data base
The one tool designed to make transactional systems run efficiently. Typically, this type of database is an
OLTP (online transaction processing) database. An electronic health record (EHR) system is a great
example of an application that runs on an OLTP database. In fact, an OLTP database is typically
constrained to a single application.

Data warehouse

The important fact is that a transactional database doesn’t lend itself to analytics. To effectively perform
analytics, you need a data warehouse. A data warehouse is a database of a different kind: an OLAP
(online analytical processing) database. A data warehouse exists as a layer on top of another database or
databases (usually OLTP databases). The data warehouse takes the data from all these databases and
creates a layer optimized for and dedicated to analytics.

A database designed to handle transactions isn’t designed to handle analytics. It isn’t structured to do
analytics well. A data warehouse, on the other hand, is structured to make analytics fast and easy

Similarities : Both OLTP and OLAP systems store and manage data in the form of tables, columns,
indexes, keys, views, and data types. Both use SQL to query the data.

How used : Database: Typically constrained to a single application: one application equals one
database. An EHR is a prime example of a healthcare application that runs on an OLTP database. OLTP
allows for quick real-time transactional processing. It is built for speed and to quickly record one
targeted process (ex: patient admission date and time). The database is directly linked to the front end
application.Data is available in real time to serve the here-and-now needs of the organization.

Data Warehouse: Accommodates data storage for any number of applications: one data warehouse
equals infinite applications and infinite databases.OLAP allows for one source of truth for an
organization’s data. This source of truth is used to guide analysis and decision-making within an
organization (ex: total patients over age 18 who have been readmitted, by department and by month).
Interestingly enough, complex queries like the one just described are much more difficult to handle in an
OLTP database.

With OLAP databases, SLAs are more flexible because occasional downtime for data loads is expected.
The OLAP database is separated from frontend applications, which allows it to be scalable.Data is
refreshed from source systems as needed (typically this refresh occurs every 24 hours). It serves
historical trend analysis and business decisions.

Database
Used for Online Transactional Processing (OLTP) but can be used for other purposes such as
Data Warehousing. This records the data from the user for history.
The tables and joins are complex since they are normalized (for RDMS). This is done to reduce
redundant data and to save storage space.
Entity – Relational modeling techniques are used for RDMS database design.
Optimized for write operation.
Performance is low for analysis queries.
Data Warehouse
Used for Online Analytical Processing (OLAP). This reads the historical data for the Users for
business decisions.
The Tables and joins are simple since they are de-normalized. This is done to reduce the
response time for analytical queries.
Data – Modeling techniques are used for the Data Warehouse design.
Optimized for read operations.
High performance for analytical queries.
Is usually a Database.

STRUCTURED QUERY LANGUAGE:

 SQL stands for Structured Query Language


 SQL is a standard language for accessing and manipulating databases.
 SQL lets you access and manipulate databases
 SQL is an ANSI (American National Standards Institute) standard
 SQL in collaboration with RDBMS is used to define, store, retrieve, manipulate and control
access to the data.
 SQL Server provides the structured Query Language (SQL) to access data objects from the
server.
 MS-SQL Server has added more features to the base-level syntax of SQL and has its own
SQL called Transact-SQL (TSQL).
 SQL Server 2008 makes it very easy to script out the data from one or more tables.
 SQL (where SQL stands for Structured Query Language) is an open source standard
programming language used for accessing and managing various relational databases.

Difference between DBMS and RDBMS

Although DBMS and RDBMS both are used to store information in physical database but there are some
remarkable differences between them.

The main differences between DBMS and RDBMS are given below:

No. DBMS RDBMS

1) DBMS applications store data as file. RDBMS applications store data in a tabular form.

2) In DBMS, data is generally stored in either a In RDBMS, the tables have an identifier called primary
hierarchical form or a navigational form. values are stored in the form of tables.

3) Normalization is not present in DBMS. Normalization is present in RDBMS.

4) DBMS does not apply any security with regards to RDBMS defines the integrity constraint for the purpos
data manipulation. (Atomocity, Consistency, Isolation and Durability) prop

5) DBMS uses file system to store data, so there will in RDBMS, data values are stored in the form of tables,
be no relation between the tables. arelationship between these data values will be stored
table as well.

6) DBMS has to provide some uniform methods to RDBMS system supports a tabular structure of the data
access the stored information. between them to access the stored information.

7) DBMS does not support distributed database. RDBMS supports distributed database.


8) DBMS is meant to be for small organization RDBMS is designed to handle large amount of data. it
and deal with small data. it supports single user. users.

9) Examples of DBMS are file systems, xml etc. Example of RDBMS are mysql, postgre, sql server, orac

After observing the differences between DBMS and RDBMS, you can say that RDBMS is an extension of
DBMS. There are many software products in the market today who are compatible for both DBMS and
RDBMS. Means today a RDBMS application is DBMS application and vice-versa.

Key Difference between DBMS and RDBMS

So what is the main difference between DBMS and RDBMS? The key difference is that RDBMS
(relational database management system) applications store data in a tabular form, while DBMS
applications store data as files. Does that mean there are no tables in a DBMS? There can be, but
there will be no “relation” between the tables, like in a RDBMS. In DBMS, data is generally stored in
either a hierarchical form or a navigational form. This means that a single data unit will have one
parent node and zero, one or more children nodes. It may even be stored in a graph form, which can
be seen in the network model.

In a RDBMS, the tables will have an identifier called primary key. Data values will be stored in the form
of tables. The relationships between these data values will be stored in the form of a table as well.
Every value stored in the relational database is accessible. This value can be updated by the system.
The data in this system is also physically and logically independent.

You can say that a RDBMS is an in an extension of a DBMS, even if there are many differences
between the two. Most software products in the market today are both DBMS and RDBMS compliant.
Essentially, they can maintain databases in a (relational) tabular form as well as a file form, or both.
This means that today a RDBMS application is a DBMS application, and vice versa. However, there are
still major differences between a relational database system for storing data and a plain database
system.

The Client Server Architecture


Database management systems like the ones you’ll learn about in this course (at least the pure
DBMS applications) do not support the client-server architecture, while relational database
management systems do. What is the client-server database model exactly? In a client-server
database model, data is stored in a central location on a server. This server can share the data
between one or more users, which are referred to as clients. However, this is not a distinction that is
relevant today, where a DBMS program is a RDBMS program, and vice versa.

WHAT IS MEANT BY DBMS?

Data Base Management system is a collection of software programs used to store and manage and
retrive data.

Data Retrival is based on 3 key points.

 Accuracy: Free from Errors


 Timeleness: within a stipualted time
 Relevancy: Related data

 DBMS is also called as “Database Server”.


 DBMS is a data base managment system and DBMSis not join the table.
 DBMS is an interface between user & Database.

 DBMS is mainly a storage area and it does not employ any tables for storing the data or does not
use any special function keys or foreign keys for the retrieval of the data.
 DBMS does not support client/server Architecture
 DBMS Doesnot follow the normalization.
 It requires low Software and Hardware Requirements.
 It treats Data as Files internally
 It supports Single User only
 DBMS is used for simpler business applications
 ACID properties of database must be implemented by the user or the developer.

WHAT IS MEANT BY DBMS?

Data Base Management system is a collection of software programs used to store and manage and
retrive data.

Data Retrival is based on 3 key points.

 Accuracy: Free from Errors


 Timeleness: within a stipualted time
 Relevancy: Related data

 DBMS is also called as “Database Server”.


 DBMS is a data base managment system and DBMSis not join the table.
 DBMS is an interface between user & Database.

 DBMS is mainly a storage area and it does not employ any tables for storing the data or does not
use any special function keys or foreign keys for the retrieval of the data.
 DBMS does not support client/server Architecture
 DBMS Doesnot follow the normalization.
 It requires low Software and Hardware Requirements.
 It treats Data as Files internally
 It supports Single User only
 DBMS is used for simpler business applications
 ACID properties of database must be implemented by the user or the developer.

FAQ: WHAT IS RDBMS (Relational Data base Model)?


 It was first described by E.F. Codd in 1970 and then modified by IBM.

It presents data in form of tables.

Normalization

Database normalization (or normalisation) is the process of organizing the columns (attributes)


and tables (relations) of a relational database to minimize data redundancy.

Normalization involves decomposing a table into less redundant (and smaller) tables without losing
information; defining foreign keys in the old table referencing the primary keysof the new ones. The
objective is to isolate data so that additions, deletions, and modifications of an attribute can be made in
just one table and then propagated through the rest of the database using the defined foreign keys.

The relational model separates the logical design from the physical design: DBMS performance is a


matter of physical designer using indexes, view materialization, big buffers, etc. It is not a matter of
changing the logical design.

A typical example of normalization is that an entity's unique ID is stored everywhere in the system but
its name is held in only one table. The name can be updated more easily in one row of one table. A
typical update in such an example would be the RIM company changing its name to BlackBerry. [5] That
update would be done in one place and immediately the correct "BlackBerry" name would be displayed
throughout the system.

If a database design is not perfect, it may contain anomalies, which are like a bad dream for any
database administrator. Managing a database with anomalies is next to impossible.

 Update anomalies − If data items are scattered and are not linked to each other properly, then
it could lead to strange situations. For example, when we try to update one data item having its
copies scattered over several places, a few instances get updated properly while a few others
are left with old values. Such instances leave the database in an inconsistent state.

 Deletion anomalies − We tried to delete a record, but parts of it was left undeleted because of
unawareness, the data is also saved somewhere else.

 Insert anomalies − We tried to insert data in a record that does not exist at all.

Normalization is a method to remove all these anomalies and bring the database to a consistent state.

First Normal Form


First Normal Form is defined in the definition of relations (tables) itself. This rule defines that all the
attributes in a relation must have atomic domains. The values in an atomic domain are indivisible units.

We re-arrange the relation (table) as below, to convert it to First Normal Form.

Each attribute must contain only a single value from its pre-defined domain.

Second Normal Form


Before we learn about the second normal form, we need to understand the following −

 Prime attribute − An attribute, which is a part of the prime-key, is known as a prime attribute.

 Non-prime attribute − An attribute, which is not a part of the prime-key, is said to be a non-
prime attribute.
If we follow second normal form, then every non-prime attribute should be fully functionally
dependent on prime key attribute. That is, if X → A holds, then there should not be any proper subset Y
of X, for which Y → A also holds true.

We see here in Student_Project relation that the prime key attributes are Stu_ID and Proj_ID.
According to the rule, non-key attributes, i.e. Stu_Name and Proj_Name must be dependent upon both
and not on any of the prime key attribute individually. But we find that Stu_Name can be identified by
Stu_ID and Proj_Name can be identified by Proj_ID independently. This is called partial dependency,
which is not allowed in Second Normal Form.

We broke the relation in two as depicted in the above picture. So there exists no partial dependency.

Third Normal Form


For a relation to be in Third Normal Form, it must be in Second Normal form and the following must
satisfy −

 No non-prime attribute is transitively dependent on prime key attribute.


 For any non-trivial functional dependency, X → A, then either −
o X is a superkey or,
o A is prime attribute.
We find that in the above Student_detail relation, Stu_ID is the key and only prime key attribute. We
find that City can be identified by Stu_ID as well as Zip itself. Neither Zip is a superkey nor is City a
prime attribute. Additionally, Stu_ID → Zip → City, so there existstransitive dependency.

To bring this relation into third normal form, we break the relation into two relations as follows −

Boyce-Codd Normal Form


Boyce-Codd Normal Form (BCNF) is an extension of Third Normal Form on strict terms. BCNF states
that −

 For any non-trivial functional dependency, X → A, X must be a super-key.


In the above image, Stu_ID is the super-key in the relation Student_Detail and Zip is the super-key in
the relation ZipCodes. So,

Stu_ID → Stu_Name, Zip

and

Zip → City

Which confirms that both the relations are in BCNF.

What is SQL
1. What is SQL?
2. Why SQL is required?
3. What SQL does?

o SQL stands for Structured Query Language.


o It is designed for managing data in a relational database management system (RDBMS).
o It is pronounced as S-Q-L or sometime See-Qwell.
o SQL is a database language, it is used for database creation, deletion, fetching rows and
modifying rows etc.
o SQL depends on relational algebra and tuple relational calculus.

All DBMS like MySQL, Oracle, MS Access, Sybase, Informix, Postgres and SQL Server use SQL as
standard database language.

Why SQL is required


SQL is required:

o To create new databases, tables and views


o To insert records in a database
o To update records in a database
o To delete records from a database
o To retrieve data from a database

What SQL does


o With SQL, we can query our database in a numbers of ways, using English-like statements.
o With SQL, user can access data from relational database management system.
o It allows user to describe the data.
o It allows user to define the data in database and manipulate it when needed.
o It allows user to create and drop database and table.
o It allows user to create view, stored procedure, function in a database.
o It allows user to set permission on tables, procedure and view.

Rules of Relational Data Model:

 It defines tables which contains Rows and Columns.


 It presents a set of rules to ensure the integrity of the database.
 In Relational model a table is also a relation.
 Dr. Codd modified his model by defining 12 rules (Codd’s Rules), that a DBMS must meet in
order to be considered a relational database.

http://www.packtpub.com/article/sql-query-basics-sap-business-one Basic Terms and Definitions

• The term 'database' has many interpretations – one definition is that database is a 'collection
of persistent data‘.

• A relational database is one in which the data consists of a 'collection of tables related to each
other through common values‘.

• A relational database management system (RDBMS) uses matching values in multiple tables to
relate the information in one table with the information in the other table.

• The presentation of data as tables is a logical construct – it is independent of the way


the data is physically stored on disk.

 http://1000projects.org/database-introduction-sql-server-tutorial.html
RDBMS=DBMS+Refrential Integrity
 RDBMS a relation data base management system and RDBMS is two table joining the relation
 RDBMS has the major difference of solving the queries easily, as they are stored in table format
and use many functional keys in solving the queries.
 RDBMS support client/server Architecture
 RDBMS follows the normalization
 It supports multiple users
 It treats data as Tables internally
 RDBMS allows simultaneous access of users to data tables.
 RDBMS imposes integrity constraints.
 ACID properties of the database are defined in the integrity constraints
 It is based on Relational algebra i. e. mathematical theory of relations.

 The two most prominent characteristics of a relational database are


– Data stored in tables.
– Relationships between tables.

DATA DEFINITION LANGUAGE (DDL):

 DDL is a vocabulary used to define data structures in SQL Server.

 It is used to create a database object (Ex: table), alter the structure of an object and to delete
the object from server.

 Database objects represents: Tables, views, synonyms, indexes, stored procedures, functions,
Triggers..

 Use these statements to create, alter, drop and truncate data structures in an instance of SQL
Server.

(i)CREATE: creates an object (a table, for example) in the database.

NOTE: mentioned in square bracket [ ] is optional.


 All database objects by default get associated to a schema called DBO –Data Base Owner.

 No limit for rows.


DATA MANIPULATION LANGUAGE (DML):

(i) Insert Command:


 Insert Command is used to add new rows in a table.
 Only ONE row is inserted at a time through below mentioned syntax.

Insert data into all columns:

Q: Write a Query to insert values in SALES table?


Q: Write a Query to insert values in CONTACT table?

Insert data into specified columns:

Q: Write a Query to insert values in CONTACT table?

Note: incase if we want to insert data to particular columns instead of inserting against all the
columns, we have to place single quote. In the above table we are not updated the data against
location column.
INSERTING NULL VALUES:

 A value of NULL indicates that the value is unknown.


 A value of NULL is different from an empty or zero value.
 No two null values are equal.
 Comparisons between two null values, or between a NULL and any other value, return unknown
because the value of each NULL is unknown.

Inserting Null Values Explicitly: We have specify “Null”

Insert into Contact values('abc',Null,'Anju')


Insert into Contact values('bcd','Hyderabad',Null)

Inserting Null Values Implicitly:

Insert into Contact values('abc', '','Anju')

FAQ: What is the difference between SP_Help <Tablename> and Select * from Table name?

 SP_Help displays only column values


 Select * both column and rows

This DML command is used to insert new rows into existing table in 3 ways.
 Inserting one row at a time in one table
 Inserting multiple rows at a time in one table
 Inserting multiple rows at a time in multiple tables

Insert - - - - - - 1 Row - - - 1 Table:

Insert - - - - - - Multiple Rows - - - 1 Table:


To insert multiple rows at a time into a single table, Select Query should be written as Sub-Query under
Insert Query.
When Rows are inserted from 1 Table to other table data types and columns list should be same.

 insert into d5 select * from department


 insert into d5 (ename,Sal,dept)select ename,Sal,dept from department where deptno = 25

(ii) Update Command:


 Update command is used to modify the data in the table.
 It modifies a set of existing table rows.
 To execute the command we use SET as key word.
Updating without Where Clause:
Q. Write a Query to update PRICE of all the companies as 50?

Update sales set price = 50


To the above case price of all the companies updated with 50.

Updating with Where Clause:


Q. Write a Query to update PRICE of ABC Company with 50?

update sales set price = 50


where company = 'abc'

In the above case price of ABC company updated with 50 in place of 15.

Q. Write a Query to update SECTOR & QUANTITY of BCD Company with STEEL & 250

update Sales set sector = 'Steel', Quantity = 250 where company = 'BCD'
(iii) Delete Command:
 It removes existing rows from a table, the space for the records remain.
 This command is used to remove all records (or) particular records from existing table
object.
 User can rollback (undo) these records

Deleting with Where Clause:


Q. Write a Query to DELETE Company of GHI from the CONTACT table?
Delete from Contact where company = 'ghi'
1 Row(GHI) has been deleted.

Deleting without Where Clause:


Q. Write a Query to DELETE all records from the CONTACT table
Delete from Contact
Note: All records have been deleted.

Q. Write a Query to DELETE column date of ORGANIZOR from CONTACT table


It is not a validate Query.
Note: Delete command is applicable to only for Columns.

You might also like