Computer Programming & Database
Table of Contents
What is a Programming Language? --------------------------------------------------------------------------------- 2
How does this work? --------------------------------------------------------------------------------------------------- 4
Basic Concepts of Programming Language ------------------------------------------------------------------------------- 5
Definition of Programming Language ------------------------------------------------------------------------------- 5
Types of Programming Languages -------------------------------------------------------------------------------------- 6
History of Programming Languages ------------------------------------------------------------------------------------ 8
Future of Programming Languages ------------------------------------------------------------------------------------- 9
Basic Concepts of Programming ----------------------------------------------------------------------------------------- 9
Importance of Programming ------------------------------------------------------------------------------------------- 11
Advantages, Disadvantages, and Challenges of Programming: --------------------------------------------------- 11
What is Python? Types of Python ------------------------------------------------------------------------------------ 12
Lesson-2 ----------------------------------------------------------------------------------------------------------------------- 15
Database ----------------------------------------------------------------------------------------------------------------------- 15
Concept of Database ----------------------------------------------------------------------------------------------------- 15
Necessity of Database ------------------------------------------------------------------------------------------------ 16
Goals and Objectives of a Database ----------------------------------------------------------------------------------- 17
Goals of a Database ------------------------------------------------------------------------------------------------------ 18
Objectives of a Database ------------------------------------------------------------------------------------------------ 19
File System vs. Database System ----------------------------------------------------------------------------------------- 19
Database System ------------------------------------------------------------------------------------------------------------- 20
Database Design -------------------------------------------------------------------------------------------------------------- 21
Characteristics of Good Database Design ------------------------------------------------------------------------- 22
Relational Database Management System (RDBMS) ---------------------------------------------------------------- 22
Features of RDBMS---------------------------------------------------------------------------------------------------- 22
Key in Database ------------------------------------------------------------------------------------------------------- 23
Primary Key ------------------------------------------------------------------------------------------------------------ 23
Foreign Key------------------------------------------------------------------------------------------------------------- 24
Popular Examples of RDBMS ---------------------------------------------------------------------------------------- 26
Lesson-1
What is a Programming Language?
A computer cannot perform any task on its own. Until a computer is
commanded, it will not do anything. The medium through which a computer
operates based on user commands is called a "Programming Language." We
use some language to talk to someone, but that is human spoken language
that people can understand. However, computers cannot understand human
language. To perform various tasks, a computer needs a special type of
language, which we call a Programming Language. There is software for
various computer tasks, which is built using different programming
languages.
A programming language is a type of language that tells a computer what
tasks to perform. For example, just as we speak in Bengali, a computer
understands a programming language.
When you tell a computer to do something—like display an image, play
music, or run a game—you need to give it instructions. These instructions
are written in a programming language.
Page 2 of 27
That is, a Programming Language is a language through which humans can
instruct a computer to perform specific tasks. Simply put:
A programming language is a medium of communication between
humans and computers.
With it, we tell the computer:
● What to do (e.g., perform calculations, store information, display images)
● When to do it
● How to do it
Think of it like a cooking recipe.
● A cooking recipe has step-by-step instructions on what ingredients are
needed and when to add them.
● Similarly, a programming language contains step-by-step instructions.
● The computer reads that recipe (instructions) and performs the task.
How Does It Work?
1. Writing Code: Programmers write code using a programming language
(software). This code
generally specifies a
particular task or solution.
Page 3 of 27
2. Compiling or Interpreting: Although the code is written for humans, the
computer cannot directly understand it. Code written in a programming
language must be converted into machine language for the computer.
Compilers or interpreters (which are translators or interpreters)
translate the code into the
computer's language. The
compiler or interpreter performs
this task itself; the user
generally does not see it.
3. Computer Execution: After
translation, the computer
executes those instructions and
displays the result on the monitor.
Example:
Suppose we want to write a
program that displays "Hello, little
friends!" on the computer. We will
use a programming language
called Python.
print("Hello, little friends!")
How does this work?
● Writing Code: The programmer writes this code using the Python
Page 4 of 27
programming language.
● Compile or Interpret: The Python interpreter reads the code and
translates it into computer language.
● Result: The text "Hello, little friends!" will be displayed on the screen.
Another Simple Example:
Imagine a computer is a robot. You tell it, "Go, bring the red ball." If the
robot understands this instruction, it will perform your task. A programming
language is the language you use to tell the robot what to do.
All types of instructions can be given to a computer using a programming
language, and the type of work a computer will do is controlled by the
programming language. Everything you see or do on computers, mobile
phones, tablets, or other devices is created using some programming
language. Additionally, computer languages are used to build or program
apps, websites, software, and more.
Programming language and programming are among the most important
components of modern computer science. A programming language is a
medium through which programmers communicate with computers and
provide various instructions. A program is a collection of instructions
written in a specific programming language, used by a computer to
accomplish specific tasks.
Basic Concepts of Programming Language
A programming language is a way to talk to computers. We use this language
to give instructions to the computer—what it will do, how it will do it, and
when it will do it.
Definition of Programming Language
Page 5 of 27
A programming language is a special kind of language used to tell a
computer what tasks to perform, when to perform them, and how to
perform them.
● It includes some rules and special words (syntax).
● A programming language is a bridge between human language and
computer language.
● We write instructions in a programming language, and then the
computer executes those instructions.
Types of Programming Languages
Programming languages can be primarily divided into two categories:
1. Low-level Language:
A low-level language is a programming language that works directly
with the computer's hardware. Code is written in machine code or
assembly language (a special type of programming), which runs
quickly and uses less memory. However, it is comparatively difficult or
Page 6 of 27
arduous for general users to understand and use.
○ "Low" means downwards, meaning very close to the computer.
○ This language works directly with the computer's memory and
components.
○ This language is difficult for humans but very easy for computers to
understand.
○ It is written using 1 (one) and 0 (zero).
Low-level programming languages are early computer languages. They do
not require a compiler or interpreter to run on the computer. Because of
this, programs written in low-level programming do not take much time to
run.
2. High-level Language:
A high-level language is a language that is easy for humans to
understand and write.
○ "High" means superior, because this language is closer to human
language.
○ This language is quite similar to human language. This language is
easy to write and read.
○ The computer cannot understand it directly, so a translator
(compiler or interpreter) is needed.
○ Examples: Python, Java.
High-level programming languages are not hardware-dependent. They
require a compiler or interpreter to run on the computer. Some high-level
languages are:
○ Python: A high-level language known for its simple syntax and
versatility. It is used in data science, web development, automation,
Page 7 of 27
and many other fields.
○ Java: A general-purpose programming language used to create
various types of applications. It is famous for platform independence
and security.
○ C: A highly efficient language widely used in operating systems and
embedded systems.
○ Scripting Languages: Such as JavaScript, Perl, and PHP, which are
commonly used in web development and automation scripting.
History of Programming Languages
The history of programming languages began in the 1950s. Initially,
"machine language" was used, which was in binary code. Then came "low-
level" languages, such as Assembly. In 1957, "Fortran" marked the beginning
of "high-level" languages, which were used for scientific work. After that,
languages like C, C++, and Java emerged, making software development
easier. In the 1990s, modern languages like Python and JavaScript made
programming even more popular.
In the current era, programming languages are rapidly evolving to meet the
demands of artificial intelligence, blockchain, data science, cloud computing,
machine learning, and other technological fields. Examples of modern
languages include Rust and Kotlin. This evolution of programming languages
has opened new horizons for solving various technological problems and
improving human life.
Page 8 of 27
Future of Programming Languages
The future of programming languages is moving towards making human-
computer interaction more advanced, easier, and more effective. With the
development of technologies like artificial intelligence, machine learning,
and natural language processing, programming languages are also becoming
more intelligent, automated, and accessible.
The concept of programs and programming languages has become an
indispensable part of our daily lives. Knowledge of programming languages
is extremely important for solving various problems, conducting business
operations, and innovating new technologies. In the future, these
technologies will make our lives easier, more efficient, and richer.
Basic Concepts of Programming
The basic concepts of programming are a collection of various rules,
principles, and ideas that help the computer perform tasks using
programming languages. Knowing the basic concepts of programming makes
programming much easier. Let's learn about some important basic concepts
of programming:
1. Variable:
A variable is a name used to store data or a value in memory. It is a
container that can hold various information, such as numbers, text, etc.
2. Data Type:
A data type indicates what kind of data a variable will hold. Some
common data types are:
○ Integer: Whole numbers (e.g., 5, 10, -3)
Page 9 of 27
○ Float: Decimal numbers (e.g., 5.75, 3.14)
○ String: Text (e.g., "Hello", "Programming")
○ Boolean: True or False (e.g., True/False)
3. Operator:
Operators are symbols used to perform calculations, comparisons, and
logical operations. Examples of operators:
○ Arithmetic Operators: +, -, *, /, % (addition, subtraction,
multiplication, division, remainder)
○ Comparison Operators: ==, !=, >, <, >=, <= (equal to, not equal to,
greater than, less than, etc.)
○ Logical Operators: AND, OR, NOT
4. Conditional Statement:
Conditional statements (e.g., if, else) are used to perform different
tasks in a program based on conditions.
For example:
if (age >= 18)
print("You are an adult")
else
print("You are a minor")
end if
5. Algorithm:
An algorithm is a step-by-step plan or set of steps for solving a problem.
By thoroughly understanding and practicing these basic concepts,
Page 10 of 27
programming in any programming language becomes much easier.
In the example above, the algorithm's task is to identify the user as "adult"
or "minor" based on age. Here, the algorithm checks if the age is 18 or
more, then it prints "You are an adult." Otherwise, it prints that the user
is "a minor."
Example:
● If age = 20, the output will be: You are an adult
● If age = 16, the output will be: You are a minor
This is a simple conditional logic written with an if-else statement.
Importance of Programming
The importance of programming lies in its ability to help create software,
apps, and websites for computers and mobile devices. It simplifies all our
daily tasks, such as banking, communication, business, education, medicine,
information exchange, and shopping. With programming skills, one can
develop technology, create new solutions, and automate tasks, saving time
and effort. Moreover, programming skills enable the creation of new
technologies and provide modern solutions for all kinds of problems, which
will further improve our lives in the future.
Advantages, Disadvantages, and Challenges of Programming:
A brief overview of the advantages, disadvantages, and challenges of
programming is provided below:
Advantages of Programming:
● Problem Solving: Complex tasks can be solved easily and quickly.
Page 11 of 27
● Automation: Various processes are automated, saving time and effort.
● Creation of New Technology: Opportunities for innovation exist through
the creation of software, apps, and websites.
Disadvantages:
● Complexity: Some languages are difficult to learn and apply.
● Bugs and Errors: Mistakes in code can lead to system problems or
security risks.
● Regular Updates Required: Languages and code need to be updated to
keep pace with new technologies.
Challenges:
● Cybersecurity: Creating secure code to combat security risks.
● Learning New Technologies: New languages and frameworks are
constantly emerging.
● Logical Thinking: Applying strong logic to create effective and accurate
solutions.
What is Python? Types of Python
To make a computer work, it needs to be given instructions in a language
it understands. This is a programming language. There are many
programming languages, and new ones are constantly being created.
However, only a few languages have become popular among programmers.
Python is one such programming language. Its creator is Guido van Rossum.
He started developing Python in December 1989 during his Christmas
holiday. However, Python became more popular in 2000 after the release of
version 2.0. Currently, Python versions 2.7 and 3.4 are in use.
A recent survey shows that Python ranks fourth in popularity worldwide
Page 12 of 27
(the top three being Java, C, C++), and 69% of students in top US universities
are introduced to programming using Python. Additionally, Python is one
of the three official programming languages of the world-renowned
company Google.
What makes Python so popular? Python programmers consider the following
to be the main reasons:
1. Python code is easy to read.
2. Code is comparatively much shorter than C or Java.
3. Python can be used on various operating systems.
4. It has a vast and effective standard library.
5. Strong online community.
6. Excellent web frameworks (Django, Flask, etc.).
The use of Python has also begun in Bangladesh. Several domestic software
development companies are using Python. There are official Python tutorials
for learning Python. Additionally, various books and online courses are
available online. There are also opportunities to learn Python in Bengali
online.
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
● [Link]
Useful web addresses where you can browse and learn about Python.
Page 13 of 27
Types of Python:
1. Python 2: This is an older version, released in 2000. It is used in some
old projects, but no new development is happening now.
2. Python 3: This is the new and current version of Python. It comes with
improved features and libraries and is currently used in most new
projects.
3. MicroPython: This is a lightweight version of Python, designed for small
devices and microcontrollers.
4. Pandas: This is a Python library used for data analysis.
Page 14 of 27
Lesson-2
Database
A database is like a large diary or cabinet where a lot of information (Data)
is neatly organized. It is an organized information storage method where
various types of information are stored in a specific structure. This
information is designed for easy use by various applications, users, and
organizations. The main goal of a database is to store information in such
a way that it can be quickly retrieved, modified, and used.
Concept of Database
A database is a structure of data where various information is systematically
stored. In a database, information is stored in tables, where each table has
one or more columns and rows. This allows data to be easily organized,
searched, and used.
Page 15 of 27
In the table in the image above, we have a total of four columns/fields (ID,
NAME, AGE, COURSE) and four rows/records.
A Database Management System (DBMS) is a software system that allows
users to create, maintain, and effectively manage databases. It simplifies the
tasks of storing, updating, deleting, and retrieving data. A DBMS ensures the
security, consistency, and integrity of various types of data. Databases are
managed using DBMS software, such as MySQL, Oracle, and Microsoft SQL
Server. A DBMS is an essential tool for developers and organizations, making
their data management more efficient and secure.
DBMS Table
Store
Row Column
Necessity of Database
The necessity of a database primarily stems from the need for managing
large amounts of data, quick access to information, and secure usage. Below
are some of its important necessities:
● Organized Data Storage: Data in a database is systematically categorized
and stored, which simplifies data management.
Page 16 of 27
● Fast Information Retrieval: A database works in such a way that
necessary information can be retrieved
quickly and accurately.
● Multi-User Access: Database systems
allow many users to access multiple
data simultaneously, which is
extremely important for large
organizations.
● Data Protection: Security rules and
regulations can be set for data stored
in a database. Unauthorized users
cannot access the database, which ensures the security of confidential
information.
● Maintaining Data Consistency: A database management system helps
eliminate data duplication and inconsistency, ensuring accurate data
storage.
● Easy Data Update and Modification: Information can be easily updated
or modified through a database, which simplifies operations and saves
time.
● Reporting and Analysis: Various types of reports and analyses can be
easily generated from necessary data through a database, which aids in
decision-making.
Therefore, a database management system is necessary for controlling large-
scale data, quick information retrieval, and secure usage.
Goals and Objectives of a Database
The goals and objectives of a database are to correctly store, manage, and
Page 17 of 27
make information usable. It provides an easier and more effective solution
for information retrieval and analysis for various organizations, institutions,
and users. Using a database makes data management, security, and analysis
tasks easier. Here are some of the main goals and objectives of a database:
Goals of a Database
1. Information Storage and Proper
Management: One of the main goals of a
database is to systematically store
data so that it is easily
manageable.
2. Fast Access and Retrieval of
Information: It provides the facility for
quick information retrieval and searching
for necessary information, which
increases efficiency during decision-making.
Page 18 of 27
3. Ensuring Information Security: A database system includes security
measures that limit information access to authorized users and ensure
confidentiality in data storage.
4. Information Coordination and Sharing: Multiple users can use the same
database, which provides the advantage of using the same data in
multiple places.
Objectives of a Database
1. Fast and Accurate Information Delivery: The objective of a database is
to provide fast and accurate information to users.
2. Updating and Managing Information: Information can be easily added,
deleted, or updated in a database, making data management more
effective.
3. Data Analysis and Report Generation: In business and research, data can
be analyzed to easily generate reports.
4. Ease of Modification and Maintenance: Data can be easily changed,
modified, and maintained through a database.
By using a database, any organization can properly store and analyze their
data, which aids in improved management and decision-making in the long
run.
File System vs. Database System
Both file systems and database systems are methods for storing and
managing information, but they have several fundamental differences. These
differences are mainly visible in their structure, data access methods,
Page 19 of 27
security measures, and usage.
File System
A file system is a primary method of data storage that is usually part of an
operating system. It stores information in files within various folders and
sub-folders.
Advantages of File System:
● Easy to use and less complex.
● Suitable for small and simple data management.
● Can be operated at a lower cost.
Database System
A database system is an advanced information storage system where
information is stored in a specific structure, such as tables, records, and
relations. A Database Management System (DBMS) manages this database
system.
Advantages of Database System:
● Large amounts of data can be retrieved easily and quickly.
● Data analysis and management become more effective.
● Multiple users can access data simultaneously.
Comparative Differences
Feature File System Database System
Structure Simple files and folders Tables and relations
Page 20 of 27
Security Limited security Advanced security
measures
Data Retrieval Slow and limited Fast and effective
Multiple Users Issues with multiple Coordinated access
access
Data Consistency Lack of consistency Ensures data integrity and
consistency
A file system is generally simple and suitable for small data, but a database
system is more effective and secure for managing large databases.
Database Design
Database design is the process of creating a structure necessary for database
creation, storage, and management. It is extremely important for data
classification, proper storage, and easy access. Good database design ensures
that the database remains effective, accurate, and securely usable.
Page 21 of 27
Characteristics of Good Database Design
● Data Consistency and Reliability: Ensures correct and reliable data is
stored and used.
● Minimizing Redundant Data: Reduces data duplication and removes
unnecessary data.
● Scalability: New data can be easily added and managed.
● Easy Modification and Maintenance: New changes can be implemented
easily.
● Security: Ensures data access and security.
Relational Database Management System (RDBMS)
A Relational Database Management System (RDBMS) is a database
management system that operates based on the relational model. Here, data
is stored in tables, and the data is systematically organized through the
columns and rows of each table. Using an RDBMS simplifies database
management and facilitates structured analysis by defining relationships
between data.
Features of RDBMS
● Data Storage via Tables: In an RDBMS, data is stored in tables, where
each table represents a specific entity.
● Relational Integrity Rules: RDBMS maintains the consistency of related
data and establishes relationships between tables through Primary Keys
and Foreign Keys.
● Data Manipulation via SQL: Structured Query Language (SQL) is used to
Page 22 of 27
store, update, delete, and retrieve data.
● ACID Properties: It adheres to Atomicity, Consistency, Isolation, and
Durability (ACID) properties, which make database transactions secure
and reliable.
● Multi-User Access: Allows multiple users to work on the same database
simultaneously, which is important for large organizations.
● Data Consistency and Security: In an RDBMS, data consistency is
maintained, and data security is ensured by defining security measures
at various levels.
Key in Database
In a database, a Key refers to special properties or attributes that help
uniquely identify each record. Primary Key and Foreign Key are two
important keys that ensure data integrity and relationships within a
database.
Primary Key
A Primary Key is a unique key formed by one or more attributes that
uniquely identifies each record in a table. It cannot be duplicated, and its
value cannot be null (NULL).
Characteristics:
● Uniqueness: Each primary key is unique, meaning no two records in the
table can have the same primary key.
● Does not accept null values: A primary key cannot accept any null or
empty (NULL) values.
● One primary key per table: A table cannot have multiple primary keys,
but it can have a composite primary key, which is formed by a
Page 23 of 27
combination of multiple columns.
Example:
Suppose there is a "Student" table where each student is uniquely identified
by a "Student_ID." This "Student_ID" is the Primary Key because it uniquely
identifies each student's record.
Student_ID (Primary Key) Name Age
101 Salma 20
102 Toufiq 22
103 Tanvir 21
Foreign Key
A Foreign Key is a key that establishes a relationship with another table
where it is defined as a Primary Key. It is used to establish relationships
between two tables, and its value must match a value present in the Primary
Key or Unique Key of the related table.
Characteristics:
● Establishes Relationships: A foreign key primarily creates a relationship
between two tables, linking data in one table to data in another.
● Can accept null values: A foreign key can generally accept null (NULL)
values, but this depends on the table's design.
● Multiple foreign keys can exist: A table can have multiple foreign keys,
establishing relationships with different tables.
Example:
Page 24 of 27
Suppose there is a "Student" table and an "Enrollment" table. In the
"Enrollment" table, "Student_ID" is used as a Foreign Key, which establishes
a relationship with the "Student_ID" Primary Key in the "Student" table.
Student Table:
Student_ID (Primary Key) Name
101 Salma
102 Toufiq
103 Tanvir
Enrollment Table:
Enrollment_ID Student_ID (Foreign Course
Key)
1 101 Math
2 102 Science
3 103 Literature
4 101 BGS
Page 25 of 27
Here, "Student_ID" in the "Enrollment" table is a Foreign Key related to the
"Student_ID" Primary Key in the "Student" table.
Key Differences
Feature Primary Key Foreign Key
Purpose Uniquely identifies each Establishes relationships
record in a table between two tables
Uniqueness Always unique Matches values in another
table's key
Null Value Cannot accept null values Can accept null values
Number Only one per table Can have multiple in a
table
By using Primary Keys and Foreign Keys, data relationships and accuracy
can be maintained within a database. This provides an effective solution for
data management.
Popular Examples of RDBMS
● MySQL: An open-source and widely used RDBMS employed in various
applications.
● Oracle Database: A highly powerful and reliable RDBMS widely used by
large organizations and in the banking sector.
● Microsoft SQL Server: An RDBMS developed by Microsoft, primarily used
Page 26 of 27
for Windows platforms.
● PostgreSQL: An open-source RDBMS known for its advanced features and
scalability.
● IBM DB2: An RDBMS developed by IBM, primarily used in large corporate
and banking sectors.
Therefore, a Relational Database Management System (RDBMS) is a powerful,
effective, and reliable database management system suitable for managing
and storing various types of data.
Page 27 of 27