Categories: Uncategorized

What is the difference between a relation and a function?

The main difference between a relation and a function is that a relation is a table in a relational database while a function is a set of statements to perform a specific task in a program.

A table in a relational database system is called a relation. The user can design multiple tables or relationships in a single database. You can perform normalization on tables to minimize data redundancy. Additionally, you can use SQL to retrieve and manipulate data in these relationships. In contrast, a function is a group of statements that perform a task in a program. There may be one or more functions in a single program.

Key Areas Covered

1. What is a relationship?
     – Definition, Operation
2. What is a function
     – Definition, Operation
3. What is the difference between a relation and a function?
     – Comparison of key differences

Key terms

Function, relation, relational database, SQL

What is a relationship?

A database is a collection of related data that helps organize data. DBMS (Database Management System) is software that allows you to easily manage and retrieve data in databases. A database model describes the logical design and structure of a database. Additionally, it defines how to store, access, and update data in a DBMS. The most common database model is a relational model that was introduced by EF Codd introduced in the year 1970.

                                                           Figure 1: Relational model

A DBMS that uses the relational model is a relational DBMS. Databases in RDBMS are relational databases. They store data in tables. These tables are connected to each other, and each table has rows and columns. A row or tuple represents a record, while a column represents an attribute. In a company sales database, the customer table has columns such as customer name, contact number, city, and email. Each customer record is a row. This table is a relation. Similarly, a table in a relational database is a relation.

what is a function

A function is a set of statements to perform a certain task. Also called procedure or method. A programmer can divide the main program into multiple functions and call them as needed. And, this makes the program more manageable.

In addition, it improves code reusability. Each function has a name to identify it. However, multiple functions cannot have the same name. A function cannot accept parameters or multiple parameters. It has, depending on the return value, a return type. If it doesn’t return any value, then the return type is null.

See the following program.

                                                                    Figure 2: Function

In the main program, there is a Scanner object. On line 10 and 11, the user can give values ​​to the variables num1 and num2. These values ​​are passed to the maximum function. Find the maximum number between the two numbers and return the maximum value. In the main program, the result variable stores the return value of the function. Finally, the results are printed on the screen. The output is visible on the left side of the program. The user enters the values ​​50 and 40, and the maximum value 50 is displayed on the console.

Difference Between a Relation and a Function

Definition

A relation refers to a table in a relational database. In contrast, a function is a unit of code that is often defined by its function within a larger code structure. Therefore, these definitions describe the main difference between a relation and a function.

Use

Another difference between a relation and a function is that relations help to store data in the relational database in an organized manner while functions help to make the program maintainable and readable.

conclusion

Relation and function are two concepts in a relational database system. The main difference between a relation and a function is that a relation is a table in a relational database while a function is a set of statements to perform a specific task in a program.

Reference:

1.”DBMS Database Models.” Database models in DBMS | Studytonight , Available here.

Courtesy image:

1. “Rel model” By Tsedenjav.Sh – Own work (CC BY-SA 4.0) via Commons Wikimedia

Mohammad Asif Goraya

M A Goraya has qualification of M.phil in Agricultural Sciences. He has almost 15 years of teaching Experience at college and university level. He likes to share his research based knowledge with his students and audience.

Recent Posts

Difference Between Summary and Conclusion with Proper Definition and Brief Explanation

Main Difference - Summary vs Conclusion Summary and conclusion are two terms that are often…

11 months ago

Difference between Moth and Butterfly

Difference between moth and butterfly fall into two categories: anatomical and behavioral. Most moths are…

1 year ago

Difference Between Architect and Engineer

An engineer is a person whose job is to design and build engines, machines, roads,…

2 years ago

Difference between the Internet and the World Wide Web

Internet is the term used to identify the massive interconnection of computer networks around the…

2 years ago

Difference Between CD-R and CD-RW

A CD-R is a type of disc that does not contain any data. It is blank…

2 years ago

Difference between x86 and x64

Computing technologies are constantly evolving, and if we base our predictions on Moore's Law, they…

2 years ago