Database Notes
Database Notes
The conceptual data model describes the database at a very high level and is
useful to understand the needs or requirements of the database. It is this
model, that is used in the requirement-gathering process i.e. before the
Database Designers start making a particular database. One such popular
model is the entity/relationship model (ER model) . The E/R model specializes in
entities, relationships, and even attributes that are used by database designers.
In terms of this concept, a discussion can be made even with non-computer
science(non-technical) users and stakeholders, and their requirements can be
understood.
Entity-Relationship Model( ER Model): It is a high-level data model which is
used to define the data and the relationships between them. It is basically a
conceptual design of any database which is easy to design the view of data.
Components of ER Model:
1. Entity: An entity is referred to as a real-world object. It can be a name,
place, object, class, etc. These are represented by a rectangle in an ER
Diagram.
2. Attributes: An attribute can be defined as the description of the entity.
These are represented by Eclipse in an ER Diagram. It can be Age, Roll
Number, or Marks for a Student.
3. Relationship: Relationships are used to define relations among different
entities. Diamonds and Rhombus are used to show Relationships.
The physical data model describes data need for a single project or
application though it maybe integrated with other physical data models
based on project scope.
Data Model contains relationships between tables that which addresses
cardinality and nullability of the relationships.
Developed for a specific version of a DBMS, location, data storage or
technology to be used in the project.
Columns should have exact datatypes, lengths assigned and default values.
Primary and Foreign keys, views, indexes, access profiles, and
authorizations, etc. are defined
Some Data Models
1. Hierarchical Model
The hierarchical Model is one of the oldest models in the data model which was
developed by IBM, in the 1950s. In a hierarchical model, data are viewed as a
collection of tables, or we can say segments that form a hierarchical relation. In
this, the data is organized into a tree-like structure where each record consists
of one parent record and many children. Even if the segments are connected as
a chain-like structure by logical associations, then the instant structure can be a
fan structure with multiple branches. We call the illogical associations as
directional associations.
2. Network Model
The Network Model was formalized by the Database Task group in the 1960s.
This model is the generalization of the hierarchical model. This model can
consist of multiple parent segments and these segments are grouped as levels
but there exists a logical association between the segments belonging to any
level. Mostly, there exists a many-to-many logical association between any of
the two segments.
Structured Query Language is a standard Database language that is used to
create, maintain, and retrieve the relational database. In this article, we will
discuss this in detail about SQL. Following are some interesting facts about
SQL. Let’s focus on that.
SQL is case insensitive. But it is a recommended practice to use keywords (like
SELECT, UPDATE, CREATE, etc.) in capital letters and use user-defined
things (like table name, column name, etc.) in small letters.
We can write comments in SQL using “–” (double hyphen) at the beginning of
any line. SQL is the programming language for relational databases (explained
below) like MySQL, Oracle, Sybase, SQL Server, Postgre, etc. Other non-
relational databases (also called NoSQL) databases like MongoDB,
DynamoDB, etc. do not use SQL.
Although there is an ISO standard for SQL, most of the implementations slightly
vary in syntax. So we may encounter queries that work in SQL Server but do
not work in MySQL.
What is Relational Database?
A relational database means the data is stored as well as retrieved in the form
of relations (tables). Table 1 shows the relational database with only one
relation called STUDENT which
stores ROLL_NO, NAME, ADDRESS, PHONE, and AGE of students.
STUDENT Table
ROLL_NO NAME ADDRESS PHONE AGE
Important Terminologies
These are some important terminologies that are used in terms of relation.
Attribute:Attributes are the properties that define a relation.
e.g.; ROLL_NO, NAME etc.
Tuple:Each row in the relation is known as tuple. The above relation
contains 4 tuples, one of which is shown as:
1 RAM DELHI 9455123451 18
Degree:The number of attributes in the relation is known as degree of the
relation. The STUDENT relation defined above has degree 5.
Cardinality:The number of tuples in a relation is known as cardinality.
The STUDENTrelation defined above has cardinality 4.
How Queries can be Categorized in Relational
Database?
The queries to deal with relational database can be categorized as:
Data Definition Language:It is used to define the structure of the database.
e.g; CREATE TABLE, ADD COLUMN, DROP COLUMN and so on.
Data Manipulation Language:It is used to manipulate data in the relations.
e.g.; INSERT, DELETE, UPDATE and so on.