11th
11th
DBMS essentially serves as an interface between the database and end users or application programs. It ensures that data is
easily accessed by potential users. The reason for creating the database management system was to store large data and
these data can be of any form image, text, audio, or video files, etc. DBMS allows the users to store and access the data of
any format.
Types of Database
1) Centralized 5) Cloud
2) Distributed 6) Object-oriented
3) Relational 7) Hierarchical
4) NoSQL 8) Network
Relational databases are the most popular databases have been widely used for more than four decades. Examples of
popular RDBMs include Microsoft Access, Oracle, Microsoft SQL Server, MySQL, SQLite, IBM DB2, and PostgreSQL.
MySQL, Microsoft Access, IBM DB2 are database management systems while Google is a search engine. MySQL is a
Linux-based database management system, Microsoft Access is a tool that is a part of Microsoft Office used to store data,
IBM DB2 is a database management system developed by IBM. Google‟s Bigtable is the database that runs Google‟s
Internet search, Google Maps, YouTube, Gmail, and other products.
The components of DBMS are as follows:
All Database Management System (DBMS) provide data types from which to select and use to define the data type for
fields of a table. For example, in MS Access, when you create a new database table, you specify what type of data is to be
stored in each field. The data types include text, integer, real numbers, dates, currency and yes or no fields. MS Access
(MS Office Access ) is a database management tool that enables one to store relevant data. This also has the capabilities to
retrieve, sort, summarize report and result immediately and effectively. It can combine data from various files (tables)
through creating relationships and can make data entry more efficient and accurate through the use of forms.
Microsoft Access (MS Access) enables to manage all important information from a single database file, With in the file can
use the different objects/items:
Design process
Determine the purpose of your database. This helps prepare you for the remaining steps.
Find and organize the information required. Gather all of the types of information you might want to record in the database,
such as product name and order number. Divide the information into tables. Divide your information items into major
entities or subjects, such as Products or Orders. Each subject then becomes a table. Turn information items into columns.
Decide what information you want to store in each table. Each item becomes a field, and is displayed as a column in the
table. For example, an Employees table might include fields such as Last Name and Hire Date.
Specify primary keys. Choose each table‟s primary key. The primary key is a column that is used to uniquely identify each
row. An example might be Product ID or Order ID. Set up the table relationships. Look at each table and decide how the
data in one table is related to the data in other tables. Add fields to tables or create new tables to clarify the relationships, as
necessary. Refine your design. Analyze your design for errors. Create the tables and add a few records of sample data. See
if you can get the results you want from your tables. Make adjustments to the design, as needed.
Apply the normalization rules. Apply the data normalization rules to see if your tables are structured correctly. Make
adjustments to the tables, as needed.
Database Objet
A database object is any defined object in a database that is used to store or reference data. Anything which we make from
create command is known as Database Object. It can be used to hold and manipulate the data. A database object in a
relational database is a data structure used to either store or reference data. When a database object is created, a new object
type cannot be created because all the various object types created are restricted by the very nature, or source code, of the
relational database model being used, such as Oracle, SQL Server or Access. What are being created is instances of the
objects, such as a new table, an index on that table or a view on the same table.
The most common object that people interact with is the table. Other objects are indexes, stored procedures, sequences,
views and many more. Anything which we make from create command is known as Database Object. It can be used to
hold and manipulate the data. Before we proceed to creating your first table, you need to know the basic components of a
table:
Meta Data – Database Structure
Field ( Column) – Data
Fieldname
Record (Row) – Information
Queries –Queries used to view, change, and analyze data in different ways. You can also use them as a source of records
for forms, reports.
Forms - A form is a type of a database object that is primarily used to enter or display data in a database. You can also use
a form as a switchboard that opens other forms and reports in the database, or as a custom dialog box that accepts user
input and carries out an action based on the input.
Reports - A report is an effective way to present your data in a printed format.
Types of Database Relationships
One-to-one relationships: occur when each entry in the first table has one, and only one, counterpart in the second
table.
One-to-many relationships: Is the most common type of database relationship.
Many-to-many relationships: occur when each record in the first table corresponds to one or more records in the
second table and each record in the second table corresponds to one or more records in the first table.
Are associations between tables that are created using join statements to retrieve data? Each primary key value relates to
none or only one record in the related table. Most one-to-one relationships are forced by business rules and do not flow
naturally from the data. New comers to the world of databases often have a hard time seeing the differences between a
database and a spreadsheet.
One of the huge advantages of a relational database is that, once you have your data held in clearly defined, compact tables,
you can connect or relate the data held in different tables.
Types of key
Keys are fields that are part of a table relationship. There are two kinds of keys
Primary key
A primary key is used to identify each record that you store in the table.
It will not allow a duplication of the Primary Key thus make it unique.
A table can have only one primary key.
Primary Key is the unique identification of one record. There is a uniquely identification number, such as: ID
number, serial number and code that serves as a primary key
Foreign Key
A table can also have one or more foreign key. A foreign key contains values that correspondent to values in the primary
key of another table use table relationship to combine data from related table.
ERD (Entity Relationship Diagram)
An Entity Relationship Diagram (ERD) is a visual representation of different data using conventions that describe how
these data are related to each other.
Elements In ER Diagram
Entity
An entity can be a person, place, event, or object that is relevant to a given system. For example, a school system may
include students, teachers, major courses, subjects, fees, and other items. Entities are represented in ER diagrams by a
rectangle and named using singular nouns.
Attribute
An attribute is a property, trait, or characteristic of an entity, relationship, or another attribute. For example, the attribute
Inventory Item Name is an attribute of the entity Inventory Item. An entity can have as many attributes as necessary.
Meanwhile, attributes can also have their own specific attributes. For example, the attribute “customer address” can have
the attributes number, street, city, and state. These are called composite attributes. Note that some top level ER diagrams do
not show attributes for the sake of simplicity. In those that do, however, attributes are represented by oval shapes.
UNIT-6
PROGRAMMING LANGUAGE
A computer program is a set of instructions that commands a computer what to do. Computers do whatever task they do by
simply following the instructions stated in programs. A program is a sequence of instructions that can be executed by a
computer. Every program is written in some programming language.
A programming language is a system of notation for writing computer programs. Most programming languages are text-
based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming language is usually split into the two components of syntax (form) and semantics (meaning),
which are usually defined by a formal language.
Programming language can be divided into three categories based on the levels of abstraction:
Low-level Language
High-level Language
Medium Level Language
Machine language provides no abstraction, assembly language provides less abstraction, and high-level language
gives a higher amount of abstraction.
Low-level Language:
The low-level language is a programming language that provides no abstraction from the hardware and is represented
by machine instructions in 0 and 1 forms.
There are two types of Low-level programming language. The Machine level language and Assembly language are
two languages that fall into this category.
Machine Language
A machine-level language is one that consists of a set of binary instructions that are either 0 or 1. Because computers
can only read machine instructions in binary digits, i.e., 0 and 1, the instructions sent to the computer must be in
binary codes.
It is difficult for programmers to write programs in machine instructions, hence creating a program in a
machine-level language is a challenging undertaking.
Assembly Language
Some commands in the assembly language are human-readable, such as move, add, sub, and so on. The challenges we
had with machine-level language are mitigated to some extent by using assembly language, which is an expanded
form of machine-level language.
Assembly language instructions are easier to write and understand since they use English words like move,
add, and sub.
We need a translator that transforms assembly language into machine code since computers can only
understand machine-level instructions.
Assemblers are the translators that are utilized to translate the code.
Because the data is stored in computer registers, and the computer must be aware of the varied sets of registers, the
assembly language code is not portable.
Because assembly code is higher in the hierarchy than machine code, it is slower. This indicates that assembly code
has some abstraction from the hardware, but machine code has none.
High-Level Language:
A high-level language is a programming language that allows a programmer to create programs that are not dependent
on the type of computer they are running on.
High-level languages are distinguished from machine-level languages by their resemblance to human languages.
Programming languages with features of both Low Level and High-Level programming languages are referred to as
“Middle Level” programming languages.
C, C++, and JAVA programming languages are the best example of Middle-Level Programming languages since they
combine low-level and high-level characteristics.
C++ (pronounced “see-plus-plus”) is one of the most powerful programming languages available. It gives the programmer
the power to write efficient, structured, object-oriented programs. To write and run C++ programs, you need to have a text
editor and a C++ compiler installed on your computer. A text editor is a software system that allows you to create and edit
text files on your computer. Programmers use text editors to write programs in a programming language such as C++. A
compiler is a software system that translates programs into the machine language (called binary code) that the computer‟s
operating system can then run. That translation process is called compiling the program. A C++ compiler compiles C++
programs into machine language. C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form
programming language that supports procedural, object-oriented, and generic programming.
Each programming language has its own collection of keywords and syntax for constructing a set of instructions.
Thousands of programming languages have been created to date, yet each one serves a distinct function. However,
there is no such thing as a programming language category. But to differentiate their function and abstraction we
classified the types of programming language based on their level of function.
Standard Libraries
C++ is being highly used to write device drivers and other software that rely on direct manipulation of hardware under
real-time constraints.
#include <iostream>
using namespace std;
// main() is where program execution begins.
int main(){
cout << "Hello World"; // prints Hello World
return 0;
}
Let us look at the various parts of the above program:
The C++ language defines several headers, which contain information that is either necessary or useful to your
program. For this program, the header <iostream> is needed.
The line using namespace std; tells the compiler to use the std namespace. Namespaces are a relatively recent
addition to C++.
The next line „// main() is where program execution begins.’ is a single-line comment available in C++. Single-
line comments begin with // and stop at the end of the line.
The line int main() is the main function where program execution begins.
The next line cout << "This is my first C++ program."; causes the message "This is my first C++ program" to
be displayed on the screen.
The next line return 0; terminates main() function and causes it to return the value 0 to the calling process.
Comments in C++
A comment is text that the compiler ignores but that is useful for programmers. These comments help anyone reading the
source code. All programming languages allow for some form of comments. C++ supports single-line and multi-line
comments. All characters available inside any comment are ignored by C++ compiler.
Multiline comments are used for large text descriptions of code or to comment out chunks of code while
debugging applications. Comments are ignored by the compiler. start with /* and end with */.
For example: /* This is a comment */
Single-line comments start with two forward slashes ( // ). Any text between // and the end of the line is ignored
by the compiler (will not be executed). Single-line comment can also start with //, extending to the end of the line.
For example:
#include <iostream>
using namespace std;
main() {
cout << "Hello World"; // prints Hello World
return 0;
}
When the above code is compiled, it will ignore // prints Hello World and final executable will produce the
following result − Hello World
Variable
A variable provides us with named storage that our programs can manipulate. Each variable in C++ has a specific type,
which determines the size and layout of the variable's memory; the range of values that can be stored within that memory;
and the set of operations that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or
an underscore. Upper and lowercase letters are distinct because C++ is case-sensitive −
Increment Operator is used to increase the value of the operand by 1 whereas the Decrement Operator is used
to decrease the value of the operand by 1.
In C++, the value of the variable is increased or decreased by 1 with the help of the Increment operator and
the Decrement Operator
Increment and Decrement Operators are used only with Integer Variables and Operands having Numerical values. They
cannot be used with a Variable containing the values of a Character or String.
The Increment Operator and Decrement Operator can be used in both the Prefix and the Postfix position of the
operand. The Position used by the Increment/Decrement Operator in the program statement decides how the operator
will function.
The Postfix Operator position has a higher precedence level than the Prefix Operator position. Postfix Operators are
evaluated from left-to-right associativity and the Prefix Operators are evaluated from right-to-left associativity.
Increment Operator
The main function of Increment Operators is to increase the numerical count of the variable by a value of 1. In a
programming language, Increment Operators are denoted by the sign ‘++’.
Syntax
Pre-Increment Operator:
++ variable_name ;
Post-Increment Operator:
variable_name ++ ;
Decrement Operator
The main function of the Decrement Operator is to decrease the numerical count of the variable by a value of 1.
Inprogramming language, Decrement Operator is denoted by the sign ‘– –’.
Syntax
Pre-Increment Operator:
— — variable_name ;
Post-Increment Operator:
variable_name — — ;
C++ programming language provides the following type of loops to handle looping requirements.
1. While loop- Repeats a statement or group of statements while a given condition is true. It tests the condition
before executing the loop body.
2. For loop- Execute a sequence of statements multiple times and abbreviates the code that manages the loop
variable.
3. do...while loop-Like a „while‟ statement, except that it tests the condition at the end of the loop body.
Programming languages provide various control structures that allow for more complicated execution paths. In
general, statements are executed sequentially: The first statement in a function is executed first, followed by the
second, and so on.
A loop statement allows us to execute a statement or group of statements multiple times and following is the
general from of a loop statement in most of the programming languages
C++ programming language provides the following type of loops to handle looping requirements.
C++ Arrays
C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An
array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the
same type.
Instead of declaring individual variables, such as number0, number1, ..., and number99, you declare one array variable
such as numbers and use numbers[0], numbers[1], and ..., numbers[99] to represent individual variables. A specific
element in an array is accessed by an index.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest
address to the last element.
Declaring Arrays
To declare an array in C++, the programmer specifies the type of the elements and the number of elements required by an
array as follows :
type arrayName [ arraySize ];
This is called a single-dimension array. The arraySize must be an integer constant greater than zero and type can be any
valid C++ data type. For example, to declare a 10-element array called balance of type double, use this statement −
double balance[10];
Initializing Arrays
You can initialize C++ array elements either one by one or using a single statement as follows −
double balance[5] = {1000.0, 2.0, 3.4, 17.0, 50.0};
The number of values between braces { } cannot be larger than the number of elements that we declare for the array
between square brackets [ ]. Following is an example to assign a single element of the array −
If you omit the size of the array, an array just big enough to hold the initialization is created. Therefore, if you write −
double balance[] = {1000.0, 2.0, 3.4, 17.0, 50.0};
You will create exactly the same array as you did in the previous example.
balance[4] = 50.0;
The above statement assigns element number 5th in the array a value of 50.0. Array with 4th index will be 5th, i.e., last
element because all arrays have 0 as the index of their first element which is also called base index. Following is the
pictorial representaion of the same array we discussed above −
An element is accessed by indexing the array name. This is done by placing the index of the element within square brackets
after the name of the array. For example −
double salary = balance[9];
The above statement will take 10th element from the array and assign the value to salary variable. Following is an example,
which will use all the above-mentioned three concepts viz. declaration, assignment and accessing arrays –
#include <iostream>
using namespace std;
#include <iomanip>
using std::setw;
int main () {
return 0;
}
This program makes use of setw() function to format the output. When the above code is compiled and executed, it
produces the following result −
Element Value
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109