You are on page 1of 13

Unit 4: MS-Access

Data: -
• The origin of the word ‘Data’ dates back to 1640’s, where it was first used as an English word. The origin and
usage of the word data processing was first done in 1954. It is originated from the Latin word ‘data’(plural of
datum).
• Data refers to any piece of information that can be stored and processed by a computer or other electronic
device. This information can take many forms, including text, numbers, images, audio, and video. Data is a
raw and unorganized fact that is required to be processed to make it meaningful. It can be considered as
facts and statistics collected together for reference or analysis. Data are individual units of information. Data
is always interpreted, by a human or machine, to derive meaning.
• Data can be collected from a variety of sources, such as sensors, surveys, or user input. Once collected, data
can be analysed, organized, and manipulated in a variety of ways to extract insights and knowledge. This
process often involves using specialized tools and techniques, such as statistical analysis, machine learning,
or data visualization.
• Here are a few examples of data:-
i. Sales data: A company might collect data on the number of products sold, the revenue generated, and
customer feedback to make informed business decisions.
ii. Education data: Schools and universities collect data on students' academic performance, attendance, and
behaviour to improve teaching methods and provide individualized support.
iii. Financial data: Banks and financial institutions collect data on transactions, account balances, and investment
trends to inform investment decisions and manage risk.

Information:-
• Information is the structured, organized, and processed data, that makes it relevant and helpful to the one
who desires it. Information is known to be processed data which can be utilized for effective decision making.
When the data is transformed through processing, it is termed as Information.
• Information refers to any knowledge or data that provides insight, understanding, or meaning about a
particular subject or topic. Information is a fundamental concept that refers to any knowledge, data, or
communication that can be represented in digital form and stored, processed, and transmitted by computer
systems. This can include text, images, audio, video, or any other type of digital content that can be
transmitted, stored, and manipulated by computer systems.
• For example, let's say you're reading a news article about a new technology startup that just raised $10
million in funding. The article contains information about the company's founders, their vision for the
company, and how they plan to use the funding. As you read the article, you process the information and
gain a deeper understanding of the startup, its goals, and its potential impact on the industry.
• Another example could be a weather forecast that provides information about the temperature, wind speed,
and precipitation for a specific location. This information can help people plan their activities and make
decisions about what to wear, whether to bring an umbrella, or whether to cancel outdoor plans.
Parameters Data Information

Description Quantitative or Qualitative variables Information is a set of data that carries


1 that are useful to generate ideas or news and meaning.
conclusions.

2 Format Data comes in the form of letters, Information is in the form of ideas and
numbers, or a character set. inferences.

Represented We can represent the data in the form We can represent the Information in the
3 of a graph, data tree, tabular data, etc. form of languages, thoughts on the
basis of the given data.

Meaning Data has no particular purpose. Information carries the meaning


4
assigned by the data interpretation.

5 Interrelation Information which is gathered. Information which is processed.

6 Dependence Data never depends on knowledge. Information depends on Data.

7 Knowledge Data is a low-level Knowledge. Information is the second level of


Level knowledge.

Contains Data contains unprocessed raw factors. The information is processed in a


8
meaningful way.

9 Dependency The data depends on the sources to be Information depends on the data.
collected.

Significance Data alone does not have any Information by itself is significant.
10 significance.

Meaning Data is based on the observations and Information is more reliable as


11
records, and is stored in computer and compared to the data. It enables the
remembered by an individual. researcher to conduct a proper study.

Usefulness The data which is gathered by the Information is useful and valuable
12 researcher can or cannot be useful. because it is easily accessible for the
researcher to use.

Database: -
• In its simplest form, a database is a collection of information organized into a list. Whenever a user makes a
list of information, such as names, addresses, products, or invoices, you are, in fact, creating a database.
Technically speaking, user don’t even have to use a database program to create a database. One can make a
list of information in all kinds of programs, such as Microsoft Excel or Word. A database program, however, is
much more powerful than a simple list you keep on paper or in a Microsoft Word document.
• A database program lets you to store information related to a particular subject or purpose such as a list of
business information; can easily and instantly locate information stored in a database; can perform
calculations on information in a database; make it easy to work with and manage huge amounts of
information; allow more than one user to view and work with the same information at once(such databases
are called multi-user databases).
store
locate
• A database also makes it easy to add, update, organize, and delete information.
huge info
multiuser
modify
DBMS: -
• Database Management Systems (DBMS) are software systems used to store, retrieve, and run queries on
data. A DBMS serves as an interface between an end-user and a database, allowing users to create, read,
update, and delete data in the database.
• It enables end users and application programmers to share data, and data to be shared among multiple
applications rather than propagated and stored in new files for every new application. MS-Access is one of
the popular DBMS known, that facilitates designing and maintaining a database of any size.
• DBMS manage the data, the database engine, and the database schema, allowing for data to be manipulated
or extracted by users and other programs. This helps provide data security, data integrity, concurrency, and
uniform data administration procedures.it also offer many benefits over traditional file systems, including
flexibility and a more complex backup system.
• Database is a collection of interrelated data which helps in the efficient retrieval, insertion, and deletion of
data from the database and organizes the data in the form of tables, views, schemas, reports, etc.
• DBMS can be classified into two types: -
i. Relational Database Management System (RDBMS)- Data is organized in the form of tables and each
table has a set of rows and columns. The data is related to each other through primary and foreign
keys.
ii. Non-Relational Database Management System (NoSQL or Non-SQL)-Data is organized in the form of
key-value pairs, document, graph, or column-based. These are designed to handle large-scale, high-
performance scenarios.
For Example, a university database organizes the data about students, faculty, admin staff, etc. which helps in
the efficient retrieval, insertion, and deletion of data from it.

• Key features of a DBMS include: -


i. Data modeling: A DBMS provides tools for creating and modifying data models, which define the structure
and relationships of the data in a database. process of creating a visual representation of information
ii. Data storage and retrieval: A DBMS is responsible for storing and retrieving data from the database, and can
provide various methods for searching and querying the data.
iii. Concurrency control: A DBMS provides mechanisms for controlling concurrent access to the database, to
ensure that multiple users can access the data without conflicting with each other.
iv. Data integrity and security: A DBMS provides tools for enforcing data integrity and security constraints, such
as constraints on the values of data and access controls that restrict who can access the data.
v. Backup and recovery: A DBMS provide mechanisms for backing up and recovering the data in the event of a
system failure.

• Advantages of using a DBMS: -


i. Data organization: A DBMS allows for the organization and storage of data in a structured manner, making it
easy to retrieve and query the data as needed.
ii. Data integrity: A DBMS provides mechanisms for enforcing data integrity constraints, such as constraints on
the values of data and access controls that restrict who can access the data.
iii. Concurrent access: A DBMS provides mechanisms for controlling concurrent access to the database, to
ensure that multiple users can access the data without conflicting with each other.
iv. Data security: A DBMS provides tools for managing the security of the data, such as controlling access to the
data and encrypting sensitive data.
v. Backup and recovery: A DBMS provide mechanisms for backing up and recovering the data in the event of a
system failure.
vi. Data sharing: A DBMS allows multiple users to access and share the same data, which can be useful in a
collaborative work environment.

• Disadvantages of using a DBMS: -


i. Complexity: DBMS can be complex to set up and maintain, requiring specialized knowledge and skills.
ii. Performance overhead: The use of a DBMS can add overhead to the performance of an application,
especially in cases where high levels of concurrency are required.
capacity to be changed
iii. Scalability: The use of a DBMS can limit the scalability of an application, since it requires the use of locking
and other synchronization mechanisms to ensure data consistency.
iv. Cost: The cost of purchasing, maintaining and upgrading a DBMS can be high, especially for large or complex
systems.
v. Limited use cases: Not all use cases are suitable for a DBMS, some solutions don’t need high reliability,
consistency or security and may be better served by other types of data storage.

• Need/Importance of DBMS: -
1) Processing Queries and Object Management: In traditional file systems, we cannot store data in the form of
objects. In practical-world applications, data is stored in objects and not files. So, in a file system, some application
software maps the data stored in files to objects so that it can be used further. We can directly store data in the form
of objects in a database management system. Application-level code needs to be written to handle, store and scan
through the data in a file system whereas a DBMS gives us the ability to query the database.
2) Controlling redundancy and inconsistency: Redundancy refers to repeated instances of the same data. A database
system provides redundancy control whereas in a file system, same data may be stored multiple times. For example,
if a student is studying two different educational programs in the same college, say ,Engineering and History, then his
information such as the phone number and address may be stored multiple times. Therefore, it increases time taken
to access and store data. A DBMS uses data normalization to avoid redundancy and duplicates.
3) Efficient memory management and indexing: DBMS makes complex memory management easy to handle. In file
systems, files are indexed in place of objects so query operations require entire file scans whereas in a DBMS, object
indexing takes place efficiently through database schema based on any attribute of the data or a data-property. This
helps in fast retrieval of data based on the indexed attribute.
4) Concurrency control and transaction management: Consider two withdrawal transactions X and Y in which an
amount of 100 and 200 is withdrawn from an account A initially containing 1000. Now since these transactions are
taking place simultaneously, different transactions may update the account differently. X reads 1000, debits 100,
updates the account A to 900, whereas Y also reads 1000, debits 200, updates A to 800. In both cases account A has
wrong information. This results in data inconsistency. A DBMS provides mechanisms to deal with this kind of data
inconsistency while allowing users to access data concurrently. A DBMS implements ACID (atomicity, durability,
isolation, consistency) properties to ensure efficient transaction management without data corruption.
5) Access Control and ease in accessing data: A DBMS can grant access to various users and determine which part
and how much of the data can they access from the database thus removing redundancy. Moreover, if a user has to
extract specific data, then he needs a code/application to process that task in case of file system, e.g., Suppose a
manager needs a list of all employees having salary greater than X. In case of DBMS, it provides easy access of data
through queries, (e.g., SELECT queries) and whole logic need not be rewritten. Users can specify exactly what they
want to extract out of the data.
6) Integrity constraints: Data stored in databases must satisfy integrity constraints. For example, consider a database
schema consisting of the various educational programs offered by a university. Then we have a schema of students
enrolled in these programs. A DBMS ensures that it is only out of one of the programs offered schema, that the
student is enrolled in, i.e. Not anything out of the blue. Hence, database integrity is preserved.

RDBMS: -
• A Relational Database Management System is referred to as RDBMS. A relational database is a type of database
that stores and allows access to data. These types of databases are referred to as "relational" because the data
items within them have pre-determined relationships with one another. Data in a relational database is stored in
tables. The tables are connected by unique IDs or "keys." When a user needs to access specific information, they
can use a key to access all the tables of data that have been pre-determined to be related to that key.
• A relational database organizes data into rows and columns, which collectively form a table. Data is typically
structured across multiple tables, which can be joined together via a primary key or a foreign key. These unique
identifiers demonstrate the different relationships which exist between tables, and these relationships are usually
illustrated through different types of data models.
• For example, imagine your company maintains a database table with customer information, which contains
company data at the account level. There may also be a different table, which describes all the individual
transactions that align to that account. Together, these tables can provide information about the different industries
that purchase a specific software product.
DBMS RDBMS
DBMS stores data as file. RDBMS stores data in tabular form.
Multiple data elements can be accessed at the
Data elements need to access individually.
same time.
Data is stored in the form of tables which are
No relationship between data.
related to each other.
Normalization is not present. Normalization is present.
DBMS does not support distributed database. RDBMS supports distributed database.
It uses a tabular structure where the headers are
It stores data in either a navigational or
the column names, and the rows contain
hierarchical form.
corresponding values.
It deals with small quantity of data. It deals with large amount of data.
Data redundancy is common in this model. Keys and indexes do not allow Data redundancy.
It is used for small organization and deal with
It is used to handle large amount of data.
small data.
It supports single user. It supports multiple users.
Data fetching is slower for the large amount of Data fetching is fast because of relational
data. approach.
The data in a DBMS is subject to low security There exist multiple levels of data security in a
levels with regards to data manipulation. RDBMS.

Low software and hardware necessities. Higher software and hardware necessities.
Examples: MySQL, PostgreSQL, SQL Server,
Examples: XML, Window Registry, etc.
Oracle, Microsoft Access etc.

Tables and steps to create it: -


• A database table is a structure that organises data into rows and columns which are similar to a worksheet in
spreadsheet applications. The columns run vertically and represent a specific field. The rows and columns intersect,
forming a grid. Each table has a unique name and consists of columns and rows. The columns in a table represent
the attributes or properties of the data being stored, while the rows represent the individual instances or records of
the data.
• The header cell of a column usually displays the name of the column which reflect the contents of each cell in that
column. For example, a column name of FirstName could be used to reflect that the cells will contain the first name
of an individual. The rows don’t typically have a header cell as such, but often the first column will contain a unique
identifier – such as an ID. This field is often assigned as the primary key, as a primary key requires a unique
identifier (i.e., the value of this field will be different for each record). This means that we can identify each record
by its ID (or other unique identifier).
• Therefore, it is also called a relation because it represents a logical connection between entities or objects. This is
where the relational part comes from relational database management systems.
• For example, in a database for a company's employees, a table might be created for the employees' personal
information, such as their name, address, phone number, and employee ID. Each row in the table would represent
an individual employee, and each column would represent a specific attribute of that employee's personal
information.
• Steps to create a table:-
i. Click the Create tab.
ii. Click Table.
iii. Create a Table. A new table appears in Datasheet View. You can start entering data right away, but you should
add some fields first.
iv. Click the Click to Add field heading. A list of data types appears. See the table at the end of this lesson to
learn more about your options.
v. Select the field type. When selecting a field type, select the smallest or shortest field that is required for your
data. For example, don’t choose Large Number if you only need to store a 2-digit number.
vi. Type a name for the field. To change the name of a field header, double-click the field header and type the
field name you want to use.
vii. Repeat Steps 3-5 to add the remaining fields to your table.
viii. When you’re finished adding fields, click the Close button and click Yes to save your changes.
ix. Enter a name for your new table.
x. Click OK.

Create a Table in Design View

i. Click the Create tab.


ii. Click Table Design.
iii. Create a Table
iv. A new table appears in the window in Design View.
v. Enter a field name in the Field Name column and press Enter.
vi. Click the Data Type list arrow and select a data type for the field.
vii. See the table at the end of this lesson for more information about data types. Repeat steps 3-4 to add as
many fields as you want.
viii. When you’re finished, click the Close button. Save and name your table.

Database Constraints: -
• Database is a representation of the real-world situation and to represent the same while designing the database,
certain rules and constraints or controls that determine the retrieval of information with respect to the realistic
environment and behaviour needs to be considered.
• Following are the different types of constraints identified for the effective design of database for any application or
organisation:-
i.Structural Constraints: Structural constraints are used to specify the data/information structure that bests suits to the
application architecture and other parameters that are considered while developing the database. Simple data are
represented using simple data structure and complex with complex data structure. Common data structures that are
used in the process of database design are linear structures, search trees and hashing schemes.
ii.Type Constraints: Type constraint is limited to the attribute definition of an entity. For example, the database
designer would like to specify the limit for the length of a specific attribute of an entity, specify an entity as a logical
field, limit by the number of characters for a field etc. or a set pattern to key in the data to define the value of the
attribute.
iii.Range Constraints: Range constraints limit the values an attribute can take. For example, the student roll number
from a specific data must start from some specific number/digit, otherwise it will be an invalid value or specify
arrange of students in a class (say 140). The attribute value will be invalid if it crosses the limit. Similar such cases can
be defined when we know the limit and range, for example, days in a week, months in a year etc.
iv.Relationship Constraints: A student can enrol in another course only when the student is a residential student. A
manufacturing organisation can define in its HR policy that minimum requirements for a skilled labour is that he/she
shall possess ITI qualification and must have completed 12th class. The above two examples represent the
characteristics of relationship constraint. Relationship constraints represent the relationships on values between the
entities.
v.Temporal Constraints: These constraints are enforced for a limited time period. For example, sales tax, excise tax,
income tax etc. Now, all the database needs to be modified to incorporate VAT, the new tax system, before they bill
to the customer. Another example would be internal grade of a student which will keep changing as he improves over
a period of time.
vi.Entity Integrity Constraints: These are the set of rules called by the application and these are applicable on all
instances of the relation. For example, in a university application, “a student should not be allowed to take more than
two courses at a time”. “Students should complete all the assignments before taking up the final examination”.
vii.Dependency Constraints: Dependency constraints are considered with respect to the relationship that exists among
the data of an entity. There are two such dependencies especially in a relational database system. They are functional
dependency and transitive dependency.

Keys: -
• In a DBMS (Database Management System), keys are one of the most fundamental concepts used for
organizing and accessing data in a database. A key is a column or set of columns that uniquely identifies each
row in a table. Keys are crucial in ensuring the accuracy and consistency of data in a database. We use a key
for defining various types of integrity constraints in a database.
• A table, on the other hand, represents a collection of the records of various events for any relation. Now,
there might be thousands of these records, and some of these might even be duplicated. Thus, we need a
way in which one can identify all of these records uniquely and separately, i.e., without any duplicates. This
hassle is removed with the help of keys. The primary motive of the keys is to provide every record with a
unique identity of its own.
• For example, let us consider a database of all the students who are studying in a college. The attribute of all
the students will identify each of these people uniquely. We can refer to these students by their names,
departments, sections, and year. Similarly, we can also mention only the university roll number and fetch all
the other details based on that roll number.
• Types of keys:-
i. Primary Key: The primary key refers to a column or a set of columns of a table that helps us identify all the
records uniquely present in that table. A table can consist of just one primary key. Also, this primary key
cannot consist of the same values reappearing/repeating for any of its rows. All the values of a primary key
have to be different, and there should be no repetitions. The PK (PRIMARY KEY) constraint that we put on a
column/set of columns won’t allow these to have a null value or a duplicate. Any table can consist of only a
single primary key constraint.
ii. Candidate Key: The candidate keys refer to those attributes that identify rows uniquely in a table. In a table,
we select the primary key from a candidate key. Thus, a candidate key has similar properties as that of the
primary keys that we have explained above. In a table, there can be multiple candidate keys. A table can have
multiple candidate keys but only one primary key. The value of the Candidate Key is unique and may be null
for a tuple and there can be more than one candidate key in a relationship.
iii. Super Key: A super key refers to the set of all those keys that help us uniquely identify all the rows present in
a table. It means that all of these columns present in a table that can identify the columns of that table
uniquely act as the super keys. A super key is a candidate key’s superset. One only need to pick the primary
key of any table from the super key’s set so as to make it the table’s identity attribute.
iv. Alternate Key: As we have stated above, any table can consist of multiple choices for the primary key. But it
can only choose one. Thus, all those keys that did not become a primary key are known as alternate keys. In
other words, the total number of the alternate keys is the total number of candidate keys minus the primary
key. The alternate key may or may not exist. If there is only one candidate key in a relation, it does not have
an alternate key.
v. Foreign Key: We use a foreign key to establish relationships between two available tables. The foreign key
would require every value present in a column/set of columns to match the referential table’s primary key. A
foreign key helps us to maintain data as well as referential integrity. It is a key it acts as a primary key in one
table and it acts as secondary key in another table. It combines two or more relations (tables) at a time and
acts as a cross-reference between the tables.
vi. Composite Key: The composite key refers to a set of multiple attributes that help us uniquely identify every
tuple present in a table. The attributes present in a set may not be unique whenever we consider them
separately. Thus, when we take them all together, it will ensure total uniqueness(Two or more attributes are
used together to make a composite key). It acts as a primary key if there is no primary key in a table.
vii. Unique Key: A unique key refers to a column/a set of columns that identify every record uniquely in a table.
All the values in this key would have to be unique. Remember that a unique key is different from a primary
key. It is because it is only capable of having one null value. A primary key, on the other hand, cannot have a
null value.

• Importance of keys:-
i. Uniqueness: Keys ensure that each row in a table is unique. This ensures that there are no duplicate rows in
the table, which can cause data inconsistency and errors.
ii. Referential Integrity: Keys are used to establish relationships between tables. The primary key of one table is
used as a foreign key in another table. This ensures that data is consistent between the two tables and
maintains referential integrity.
iii. Data Consistency: Keys ensure that the data in a database is consistent. They prevent data from being
inserted into a table if it violates the unique constraints of the key.
iv. Efficient Access: Keys are used to organize data in a database. They enable efficient searching and sorting of
data, which improves the performance of the database.

Queries:-
• A query is a question or a request for information expressed in a formal manner. In computer science, a query is
essentially the same thing, the only difference is the answer or retrieved information comes from a database.
• A database query is a request for data from a database. The request should come in a database table or a combination
of tables using a code known as the query language. Queries make it easier to perceive trends at a high level or make
edits to data in large quantities. It enables users to locate records that meet certain criteria, make complex
calculations, apply complex operations to a large data set, and automate functions that are essential for data
management. They also make it possible to consolidate data into digestible pieces of information for reporting
purposes.
• Queries can be written in a structured query language (SQL) or using graphical user interfaces provided by database
management systems (DBMS).
• Queries can be used for a variety of purposes, such as generating reports, extracting data for analysis, or updating
records in a database. Queries can also be used to perform calculations and aggregations on data, such as calculating
the sum or average of a set of values.
• How do Queries work:-
i. A query works the same way – it adds meaning to the code, allowing the system to understand and execute
actions accordingly. Be it SQL or any other query language, both the user and the database can exchange
information as long as they use the same language.
ii. Meanwhile, a well-designed database stores data in multiple tables. They consist of columns that hold the data’s
attributes, along with rows or records of information. A query then helps retrieve data from different tables,
arrange them, and display them according to the commands.
iii. A query can either be a select, an action, or a combination of both. Select queries can retrieve information from
data sources, and action queries work for data manipulation, for example, to add, change or delete data.
• Types of Queries:-
i. Select Query: This type of query is used to retrieve data from one or more tables in the database. The SELECT
statement is used to specify the columns that should be returned and the conditions that should be met for the
data to be retrieved.
ii. Insert Query: This type of query is used to insert new data into a table in the database. The INSERT INTO statement
is used to specify the table and the values that should be inserted.
iii. Update Query: This type of query is used to update existing data in a table in the database. The UPDATE statement
is used to specify the table, the columns to be updated, and the new values.
iv. Delete Query: This type of query is used to delete data from a table in the database. The DELETE statement is used
to specify the table and the conditions that should be met for the data to be deleted.
v. Join Query: This type of query is used to retrieve data from two or more tables in the database that are related to
each other. The JOIN statement is used to specify the tables and the conditions that should be met for the data to
be retrieved.
vi. Aggregate Query: This type of query is used to perform calculations on the data in a table in the database. The
GROUP BY statement is used to group the data and the aggregate functions (such as COUNT, SUM, AVG) are used to
perform the calculations.
vii. Subquery: This type of query is used to retrieve data from one table based on the results of another query. The
subquery is used as a condition in the WHERE clause of the main query.
viii. Stored Procedure: This is a pre-written program that is stored in the database and can be executed when needed.
Stored procedures can be used to perform complex tasks or calculations on the data in the database.
ix. Transaction Query: This type of query is used to perform a series of database operations as a single unit of work.
Transactions ensure that the database remains in a consistent state even if an error occurs during the process. The
BEGIN TRANSACTION, COMMIT and ROLLBACK statements are used to manage transactions.

• Examples:-
i. Number the Rows in a Result Set: Sometimes we want to create a ranking that assigns each row a number indicating
the position of that row in the ranking: 1 to the first row, 2 to the second one, and so on. SQL provides a few ways to
do this. If we want a simple sequence of numbers from 1 to N, we can use the ROW_NUMBER() function. However, if
we want a ranking that allows two rows in the same position (i.e., because they share the same value) we can use
the RANK() or DENSE_RANK() function. The following query creates a report where each row has a position value:

SELECT

employee_id,

last_name,

first_name,

salary,

ROW_NUMBER() OVER (ORDER BY employee_id) as ranking_position

FROM employee

ii. Join a table to itself: In some cases, we need to join a table to itself. Think about the employee table. Every row
has a column called manager_id with the ID of the manager supervising this employee. Using a self-join, we can
obtain a report with the column’s employee_name and manager_name; this will show us who manages each
employee. Here is the query:

SELECT

e1.first_name ||’ ‘|| e1.last_name AS manager_name,

e2.first_name ||’ ‘|| e2.last_name AS employee_name

FROM employee e1

JOIN employee e2
ON e1.employee_id = e2.manager_id

In the above query, we can see the table employee is referenced twice as e1 and e2, and the join condition
is e1.employee_id = e2.manager_id. This condition links each employee row with the manager row.

iii. Show All Rows with an Above-Average Value: We need a report showing all employees with a salary that’s higher
than the company average. We can first create a subquery to obtain the average salary of the company, and then
compare the salary of every employee with the subquery result. This is shown in the following example:

SELECT

first_name,

last_name,

salary

FROM employee

WHERE salary > ( SELECT AVG(salary) FROM employee )

You can see the subquery that obtains the average salary in the WHERE clause. In the main query, we select the
employee’s name and salary.

Relationship among tables:-


• In a database management system (DBMS), a relationship is the way in which two or more tables are linked to each
other based on a common field or key. Relationships are used to establish connections between tables in a database,
and are fundamental to the organization and retrieval of data in a structured and efficient manner.
• The term relation is sometimes used to refer to a table in a relational database. However, it is more often used to
describe the relationships that exist between the tables in a relational database. A relationship between two
database tables presupposes that one of them has a foreign key that references the primary key of another table.
Relationships enable relational databases to divide and store data in separate tables while connecting disparate data
items.
• An entity-relationship diagram, also known as ERD, ER diagram, or ER model, comprises a graphical representation of
how entities relate to each other within a database. ER models are widely used in database design as they are fairly
abstract and are easy to view and analyse.
• Degree of Relationship:-
In DBMS, a degree of relationship represents the number of entity types that associate in a relationship. For
example, we have two entities, one is a student and the other is a bag and they are connected with the primary
key and foreign key. So, here we can see that the degree of relationship is 2 as 2 entities are associating in a
relationship.
Shown as a Diamond : Diamond is doubled if one of the participants is dependent on the other Participants are
connected by continuous lines, labelled to indicate cardinality. In partial relationships roles (if identifiable) are written
on the line connecting the partially participating entity rectangle to the relationship diamond. Total participation is
indicated by double lines

• Types of degree: We have 4 types of degrees of relationships:-


i. Unary: In this type of relationship, both the associating entity type are the same. So, we can say that unary
relationships exist when both entity types are the same and we call them the degree of relationship is 1. Or in
other words, in a relation only one entity set is participating then such type of relationship is known as a unary
relationship. Example: In a particular class, we have many students, there are monitors too. So, here class
monitors are also students. Thus, we can say that only students are participating here. So, the degree of such
type of relationship is 1.

• Binary (degree 2): In a Binary relationship, there are two types of entity associates. So, we can say that a Binary
relationship exists when there are two types of entity and we call them a degree of relationship is 2. Or in other
words, in a relation when two entity sets are participating then such type of relationship is known as a binary
relationship. This is the most used relationship and one can easily be converted into a relational
table. Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his ‘ID’. So, here two entity
types are associating we can say it is a binary relationship. Also, one ‘Father’ can have many ‘daughters’ but each
‘daughter’ should belong to only one ‘father. We can say that it is a one-to-many binary relationship.

• Ternary(degree 3): In the Ternary relationship, there are three types of entity associates. So, we can say that a
Ternary relationship exists when there are three types of entity and we call them a degree of relationship is 3.
Since the number of entities increases due to this, it becomes very complex to turn E-R into a relational table.
Now let’s understand with the examples. Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The
relationship between these entities is defined as the teacher teaching a particular course, also the teacher teaches
a particular class. So, here three entity types are associating we can say it is a ternary relationship.

• N-ary (n degree): In the N-ary relationship, there are n types of entity that associates. So, we can say that an N-ary
relationship exists when there are n types of entities. There is one limitation of the N-ary relationship, as there are
many entities so it is very hard to convert into an entity, rational table. So, this is very uncommon, unlike binary
which is very much popular. Example: We have 5 entities Teacher, Class, Location, Salary, Course. So, here five
entity types are associating we can say an n-ary relationship is 5.

• Types of Relationship:-
i. One to One Relationships: It is used to create a relationship between two tables in which a single row of the
first table can only be related to one and only one records of a second table. Similarly, the row of a second
table can also be related to anyone row of the first table. This type of relationship permits a maximum of a
single record on both sides. The primary key corresponds to either one or no data in another table. In simple
words, here is the mapping of a single instance of an entity with a single instance of the other entity. Here,
the primary key of one entity is accessible in the other entity as a foreign key.

Example: Relationship between department and faculty.


ii. One to Many Relationships: It is used to create a relationship between two tables. Any single rows of the first
table can be related to one or more rows of the second tables, but the rows of second tables can only relate
to the only row in the first table. It is also known as a many to one relationship. The widely used database
relationship is one-to-many. It is a cardinality-type relationship between the two entities. One record in one
table may have a relationship with one or more records in the other table. It is feasible when a foreign key of
one table references the primary key of another.

iii. Many to Many Relationships: Each record of the first table can relate to any records (or no records) in the
second table. Similarly, each record of the second table can also relate to more than one record of the first
table. It is also represented an N:N relationship. Many-to-many database relationships are relatively
uncommon. It is a kind of cardinality that describes the connection between two entities. Multiple records
from one table have a relation with multiple records from another table. It comprises two one-to-many
relationships between the two tables. This type of relationship is challenging to establish. There is an
introduction of a third table(junction table) to solve and execute the many-to-many relationship in the
relational database and connects two one-to-many relationships to create a many-to-many relationship.

Report Generation:-
• In DBMS (Database Management System), report generation refers to the process of extracting data from one or
more tables in a database and presenting it in a formatted manner for easy readability and understanding.
• Reports are typically created to provide insights into the data stored in a database and help users make informed
decisions. They can be generated on demand or scheduled to run at regular intervals, and can be in various formats
such as text, HTML, PDF, or Excel.
• Report generation involves collecting, analysing, and interpreting data, and then presenting the information in a
structured and meaningful way. The process often includes creating charts, tables, and graphs to illustrate key points,
and organizing the information into sections or chapters.
• Reports can be generated for a wide range of purposes, such as business reports for executives, financial reports for
investors, academic reports for research purposes, or medical reports for healthcare.
• Report generation refers to the process of creating a document or presentation that summarizes information, data,
or findings in a clear and organized manner. Reports are typically used to provide information to stakeholders,
decision-makers, or clients to help them understand a particular issue or make informed decisions.
• DBMS often provides built-in reporting tools to generate reports, or third-party reporting tools can be used to create
more customized and complex reports.
• Some examples of report generation in DBMS:-
i. Sales Report: A sales report is a report that displays sales data over a particular period, such as a week, a month,
or a year. The report may show sales by product, by region, or by salesperson. The report can be generated by
querying the sales transaction data from the database.
ii. Inventory Report: An inventory report is a report that displays the current status of inventory levels in a business.
The report can show the quantity of each product in stock, the location of each item, and the total value of the
inventory. The report can be generated by querying the inventory data from the database.
iii. Customer Report: A customer report is a report that displays information about the customers of a business. The
report can show customer names, addresses, phone numbers, email addresses, and purchase history. The report
can be generated by querying the customer data from the database.

• Essential feature of report generation:-


i. Customization: The user can customize the report based on their requirements. They can select the fields they
want to include in the report, sort the data, set filters, and define the report layout.
ii. Templates: Many DBMS come with predefined report templates that can be used as a starting point for creating
custom reports. These templates include various report formats, such as tables, graphs, and charts.
iii. Data aggregation: DBMS can aggregate data from multiple tables and present it in a single report. This is useful
when the user needs to analyse data from different sources.
iv. Formatting: DBMS allows users to format the report in various ways, such as font style, size, and colour. They can
also add headers, footers, and page numbers to the report.
v. Export: The report can be exported in different file formats such as PDF, Excel, and HTML. This allows the user to
share the report with others or use it for further analysis.
vi. Automation: Many DBMS support scheduling of reports generation. The user can specify the frequency of the
report generation, and the system will automatically generate the report at the specified time.
vii. Security: DBMS allows users to restrict access to reports based on user roles and permissions. This ensures that
only authorized users can view or modify the reports.
viii. Drill-down: DBMS supports drill-down functionality that allows the user to explore the data in more detail. By
clicking on a specific data point in the report, the user can drill down to the underlying data to get more insights.
• Importance of report generation in DBMS:-
i. Data Retrieval: The first step in generating a report is to retrieve the necessary data from the database. This
involves creating a query that selects the relevant data from the database.
ii. Filtering and Sorting: Once the data is retrieved, it may need to be filtered and sorted to ensure that the report
displays the desired information in a clear and organized manner.
iii. Grouping: Grouping data allows you to summarize and organize it based on specific criteria. For example, you may
want to group sales data by region, product, or salesperson.
iv. Calculations and Aggregations: Calculations and aggregations allow you to perform complex calculations on your
data, such as totals, averages, and percentages.
v. Formatting: Formatting the report is an important step to ensure that the data is presented in a readable and
visually appealing manner. This includes selecting fonts, colours, and layout options.
vi. Report Design: The design of the report should be carefully considered to ensure that it is easy to read and
understand. This includes selecting the appropriate chart types, tables, and graphs to present the data.
vii. Report Distribution: Once the report is generated, it needs to be distributed to the appropriate stakeholders. This
may involve exporting the report to a specific file format, such as PDF or Excel, or integrating it into a web-based
reporting system for online access.

• Types of report generation:-

There are two types of the report generation process, which are as follows:

1. Full-automatic Generation: Fully automatic generation is a template-based process. YoY (Year over Year), MoM
(Month over Month) ranking is the often-utilized monetary insights. Take the most often involved for instance,
including MoM, YoY Ranking. At the point when the report generator is used, layouts of monetary statistics have
been created inside. The full-automatic generation just requires us to link to the database and drag it to the relating
cell.

2. Semi-automatic Generation: Each module is generated automatically in semi-automatic generation by using


professional functions. Semi-automatic generation is common and can more likely meet clients’ customized
requirements as compared to full-automatic report generation.

You might also like