Lesson 4 - Relations
.docx
keyboard_arrow_up
School
Colorado Technical University *
*We aren’t endorsed by this school
Course
225
Subject
Computer Science
Date
May 13, 2024
Type
docx
Pages
8
Uploaded by chrisjin92 on coursehero.com
Introduction
Consider pairing information into sets. For example, you can pair a student with a student ID or a student with a course. The association of sets is referred to as a
relation
.
In mathematics, a relation is the correspondence between the sets of information. A specific type of relation is a
function
.
Learning Materials
Relations can be represented in multiple ways. In any representation, the order is important and has to remain the same. One form that is used to represent a relation is ordered pairs. Consider the following example of a set of students and a set of student IDs.
Set A = {Nick, Erica, Amanda, Olivia}
Set B = {10, 12, 14, 16}
To write these two sets as a relation, the order must be determined. Each ordered pair in the relation will be (student name, student ID). The relation is
as follows:
R = {(Nick, 10), (Erica, 12), (Amanda, 14), (Olivia, 16)}.
The relation has a domain and a range. The
domain
is the first coordinate of the ordered pairs, and the
range
is the second coordinate of the ordered pairs. For the relation in the example, the domain would be the student names, or set A, and the range is the student IDs, or set B.
Another method to represent a relation is in tabular form. The domain and range are easily displayed in this form; one column is the domain, and the other is the range. The previous example of student names and student IDs in tabular form is as follows:
Student
Name
Student ID
Nick
10
Erica
12
Amanda
14
Olivia
16
In the example used, two sets are compared. Comparing two sets is referred to as a
binary relation.
Two sets are not always sufficient enough for the needed amount of information. Relations with more than two sets are
n-ary
relations
, where
n
is the number of sets in the relation. A binary set is not the
only n-ary with a special name. A relation with three sets is a
3-ary
or a
ternary relation
.
Consider adding two additional sets of information to the student name and student ID example. Set C is the student’s gender, and set D is the student’s major, as follows:
Set C = {male, female, female, female}
Set D = {Business, Education, Science, English}
The relation now contains four sets and is a 4-ary relation. The same formats
are used to represent the information; although, the tabular form is more transparent.
R = {(Nick, 10, male, Business), (Erica, 12, female, Education), (Amanda, 14,
female, Science), (Olivia, 14, female, English)}
Student
Name
Student
ID
Student
Gender
Student
Major
Nick
10
Male
Business
Erica
12
Female
Education
Amanda
14
Female
Science
Oliva
16
Female
English
A
function
is a relation with a specific requirement. The requirement is that every value in the first set must relate to exactly one element in the second set. In other words, the domain cannot repeat.
The relation {(2, 4), (3, 6), (4, 8), (5, 10)} also represents a function. One way to determine whether the relation is a function is to map the domain and range. Notice in the mapping below that each element in the domain maps to only one element in the range. The relation is a function.
The relation {(2, 4), (3, 6), (3, 8), (5, 10)} does not represent a function. The element 3 in the domain relates to both 6 and 8.
A graph represents a function only if the graph passes the vertical line test. If
a vertical line can be drawn through a graph and can intersect the graph in more than one location, the graph does not represent a function.
Example:
The following graph represents a function. A vertical line drawn would only intersect the graph one time.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
An Abstract Data Type (ADT) is a data type that contains just variables, without information about their values. ADTs have many benefits. By reducing the issue to its simplest parts, it becomes easier to solve.
arrow_forward
A strongly-typed data type implementation supports strongly-typed data, whereas a loosely-typed data type implementation supports loosely-typed data.
arrow_forward
4. Let A = {a, b, c, d}. Suppose R is an equivalence relation on A. Suppose R has three equivalence classes. Also
a Rd andbR c. Write R as a set. Describe them all.
..............................................................
arrow_forward
Airline Company
An airline company is interested in implementing a database system to manipulate the flights that it organizes.
The airline company has a certain number of airplanes. Each airplane has a unique code, a number of seats and a production year. An airplane belongs to a certain airplane model. Each model has a unique model number and is provided by a certain company. We have different airplanes of each model. Each flight is identified by a flight number, a scheduled departure time and a scheduled arrival time. We want also to keep track of the airport from which the flight is scheduled as well as the destination airport. Each airport is identified by a unique code, its name and the country in which it is located. Journeys of each flight are organized on a daily basis. Each journey is identified by a date, its actual departure time, its actual arrival time, and the number of passengers, in addition to the airplane that performs the journey. We want to keep track of the…
arrow_forward
O True
O False
6. Every aggregation relationship is an association *
O True
O False
7. Removing a duplicate code in the program is an example for *
(1 Point)
Reverse engineering
arrow_forward
> Create UML Class diagram for e-library system as described, make sure to show
attributes,
generalization where appropriate.
operations, multiplicities,
and
aggregations/compositions,
A library system has materials which would be books, journals, or CDs. All library
material (books, magazines, and CD) has a unique identification number and a title.
Books have one or more authors, journals have producer, while CDs have entertainer.
all library materials can be loaned to users, users have user-id, user-name, birthdate
(day, month, and year), age and phone-number. Users can loan any material, for each
loan the library records material-id, the user-id, loan-date (day, month, and year), and
loan time (hour, minute), and loan counter (shared)
arrow_forward
Airline Company
An airline company is interested in implementing a database system to manipulate the flights thatit organizes.The airline company has a certain number of airplanes. Each airplane has a unique code, anumber of seats and a production year. An airplane belongs to a certain airplane model. Eachmodel has a unique model number and is provided by a certain company. We have differentairplanes of each model. Each flight is identified by a flight number, a scheduled departure timeand a scheduled arrival time. We want also to keep track of the airport from which the flight isscheduled as well as the destination airport. Each airport is identified by a unique code, its nameand the country in which it is located. Journeys of each flight are organized on a daily basis.Each journey is identified by a date, its actual departure time, its actual arrival time, and thenumber of passengers, in addition to the airplane that performs the journey. We want to keeptrack of the seats occupied,…
arrow_forward
Computer Science
A course and a teacher object have a many-to-one relation. You need to enable a function wherein a course cannot be saved without notifying the teacher. What should be done to accomplish the task?
arrow_forward
Write a program in c++ to find the transpose of a matrix. Matrix is to be stored in a class object which should be constructed using a constructor dynamically by asking rows and columns to the user.
arrow_forward
Question Make Class Diagram And Use Case Diagram
The system Description
Title: Working student's system
The objective of the system is to create and manage a generic working domain for any
student through his/her computer at Oryx college. A user should be able to organize the
working space by a tree of topics corresponding to his/her activities in a recursive way. Each
topic should have a name, a short description, and if needed a list of links to folders, files or
the web. A topic is either a terminal or a non-terminal. If the topic is not terminal then it
should be related to other topics. Any terminal or non-terminal topic should be related to its
parent and possibly horizontally to other topics in the network of topics in a symmetric way.
By using the generic built structure, the system should be illustrated and used for student
work organization, which goal is to minimize the browsing time used by the student to
manage his/her documents, by adding, removing, reading, any target…
arrow_forward
A key aspect of an abstract data type is to facilitate
O information hiding
O interface hiding
O information manipulation
O attribute manipulation
arrow_forward
Data type
1.) Database Design : Take a crack at designing a simple database for 'A
Small Dentist Office'. To keep it simple, please exclude any financial
or billing information. So build a simple database that keeps track of
patient information and appointments. Keep this very simple, maybe
4 tables.
Part I: First determine the entities. The entities will be the
tables. For example in an employee database the entities might
be: an Employee, a Dept. These would then become the
tables...the Employee table and the Dept table. Once you
have come up with your 4 tables, move on to Part II.
Part II: Design each table. Tables must include:
a. Appropriate column names
b. Data type for each column
c. Whether a column can be 'null' or not
d. Indicate any Primary Keys' and Foreign
Keys'.
e. Indicate any relationships with other tables
PS → DO NOT USE MSAccess to do this Assign. I would use Excel for
this Assign, or you could possibly use MS Word.
arrow_forward
QUESTION 1
Happy Learning (this is a fictional scenario)
A private kindergarten, Happy Learning, wants to build a database to manage their operations. You were assigned to create an initial design based on the following customer description of their operations.
There are 3 age levels in the kindergarten (turtles, foxes and monkeys). At each level there 3 classes (red, blue and green). For a class we keep a code based on the initial of group color and level (e.g. RT for red turtles, GF for green foxes). Each class has a room number and a phone number (with the format (999) 9999999). Also, each class has a maximum capacity (between 25 and 35). For some classes we will keep brief directions to the class location in the building (less than 160 characters).
For a student we will keep the name (first, last, middle each less than 15 characters), any nickname (less than 10 characters), date of birth, address, and the class in which the student is currently enrolled. We will process…
arrow_forward
Write a C program that would:
- Let the users accept a relation.
- Input options should be in Matrix and Listed Method.
- Display the relation through a matrix or listed method.
- Let the user select "Display Properties of Relation"- This will print out the properties of the relation which include Symmetric, Asymmetric, Antisymmetric, Transitive and Reflexive.
##### Listed Display #####
R = {(1,1),(1,3),(2,2),(2,4),(3,1),(3,3),(4,2),(4,4)}
##### Display Properties of Relation ######
- Reflexive
- Symmetric
- Transitive
arrow_forward
a. The following pair of concepts are related in some way and different in another. Explain how the concepts are similar and how they are different: GROUP BY / ORDER BY
b. The following pair of concepts are related in some way and different in another. Explain how the concepts are similar and how they are different: WHERE / HAVING
arrow_forward
In what ways do Class and Structure vary from one another? Use an example to back up your claim
arrow_forward
SUNSHINE AIRLINE COMPANY
The ER Diagram for the SUNSHINE AIRLINE COMPANY is based on the following:
- For each airplane type, we keep track of a unique airplane type ID (AirplaneTypelD), number of engines
(NoOfEngines), and number of seats (NoOfSeats).
- For each airport, we keep track of a unique airport ID (AirportID), and the length of the main runway
(LengthOfRunway).
- Each airplane type is able to land at one airport at least, but may be able to land at many airports. Each
airport accommodates landing of at least one airplane type, but may accommodate landing of more airplane
types.
SUNSHINE AIRLINE COMANY (ERD)
XXX
YYY
zzz
PPP
AAA
Relationship
BBB
Symbol1
Symbol2
In the ER Diagram for the SUNSHINE AIRLINE COMPANY, which word should replace gg?
O LengthOfRunway
O NoOfEngines
O AirplaneTypelD
O AirportID
O NoOfSeats
arrow_forward
Decision Tree / We want to learn a function that returns (counts) the number of attributes with the value 1 on a dataset, each of which takes a binary value (0 or 1) and consists of attributes named a1, a2, a3. Draw the decision tree representing this function (explain your design ideas in a few sentences).
arrow_forward
Ball at the wallcontext
In a ball-at-the-wall game, children in the schoolyard must throw balls at the school wall to reach lines placed at certain heights. You want to predict how high the ball will hit the wall based on the parameters of the throw.
Constraints and information
The children are all placed behind a line drawn on the floor, at a known horizontal distance ? from the wall;The initial height at which the ball leaves the child's hand is known;The speed and angle of the throw are known;
Modelization
Creates a model to determine how high the ball will hit the wall based on the children's distance from the wall and the height, speed and angle of the ball as it leaves the child's hand .
Then test your model with the following parameters
Distance between the wall and the child: 3.9?;
Height of the ball when it leaves the child's hand: 1.05?;
Throw Speed: 14.1?/?;
Throw angle: 51∘
arrow_forward
Introduction The Object Oriented software model is designed to create a new data type by using the Class structure. Therefore the various operations which define a data type, such as the common operators, assignment, etc., have a software architecture available to create those operations and data types. Assignment Description This assignment is an exercise in creating a complete class definition. A standard way to do that is to use a math data type. Here we define a Rational Number data type in a class called “Rational”. The distinctive feature of this type is the data is kept as numerator and denominator throughout all operations; there is no floating point representation used. The standard math operations, addition, subtraction, etc., are implemented, including the iostream overload. The student will not only come to understand what is required for a complete representation of such a type, but also learn about the internal mechanics of its C++ implementation. The student will be…
arrow_forward
Objective:
To create a JSON for Scheme details with objects
Scenario:
Government wants to create a database for schemes launched in respective country.
Application sends the details of schemes in the form of JSON
Help to create a JSON with the information provided.
Name
Datatype of value
Scheme
String
MinistryDetails
Object
LaunchedYear
Number
Country
String
BudgetInCrores
Number
MinistryDetails- Object :
Name
Datatype of value
Ministry
String
MinisterName
String
HeadOfMinister
String
NOTE:
You can assume any data for the mentioned JSON structure, provided it is matching the specified datatype
arrow_forward
Explain the following and their use.PolymorphismInheritancePointersAbstract Data Types
arrow_forward
COVID TRACING DATABASE
Assumptions:
You can make the following assumptions in this project.
The database stores information about houses, each with a house ID, address, and zip code.
The database stores information about person, including person ID, house ID where the person lives, person name, phone number, and status where 1 means currently tested positive (i.e., the most recent test result is positive), 0 means currently tested negative (i.e., the most recent test result is negative), and null (no test so far so status is unknown).
The database stores information about a person's all past tests, including person ID, test date, and result (1 means positive and 0 negative).
The database stores information about events (could be gathering, party, etc.). Each event has an event ID, event name, date, and address.
The database stores information about a person participated in an event.
The database stores information about flights, including flight ID, flight date, flight number (a…
arrow_forward
Given the following UML diagram:
Student
- studentID: String
+ getStudentID(): String
+ toString(): String
Person
- lastName: String
- firstName: String
- dateOfBirth: Date
- address: Address
+ getName(): String
+ getDOB(): Date
+ getAddress(): Address
+ toString(): String
Professor
- employeeID: String
+getEmployelD(): String
+toString(): String
Write an implementation for the class Professor. DO NOT include or implement any
constructor for this class. There are no abstract methods/classes in this example.
toString method will return any simple String that contains firstName and
employeelD only; no less, no more!!
Assume firstName was defined as protected in class Person.
You are not allowed to add implementation for any class or methods other than
what is listed in the question statement.
arrow_forward
Q No. 2: Draw a Use Case diagram for "The Pizza Ordering System".
(Hint – correct > or > relationships will attract
additional marks).
The Pizza Ordering System
The Pizza Ordering System allows the user of a web browser to order pizza for home
delivery. To place an order, a shopper searches to find items to purchase, adds
items one at a time to a shopping cart, and possibly searches again for more items.
When all items have been chosen, the shopper provides a delivery address. If not
paying with cash, the shopper also provides credit card information.
The system has an option for shoppers to register with the pizza shop. They can
then save their name and address information, so that they do not have to enter
this information every time that they place an order.
arrow_forward
Adversarial Search Explain in English the purpose of using evaluation functions in adversarial
search? (It is not enough to explain what they do; you need to explain why what they do is useful.)
arrow_forward
UML Diagrams:
Course
-courseName: String
-students: Student []
-numberOfStudents: int
+Course(courseName : String)
+getCourseName() : String
+addStudent (student : Student) : void
+addStudent (studentName: String): void
+dropStudent(studentId: int ) : void
+getStudents() : Student []
+getNumberOfStudents() : int
a. How many constructors does Course have?
b. How many methods that are void?
c. How many methods that return a value?
d. What is the parameter to the method dropStudent?
arrow_forward
Exercise 2.3.2: This exercise introduces another running example, concerning
World War II capital ships. It involves the following relations:
Classes (class, type, country, numGuns, bore, displacement)
Ships (name, class, launched)
Battles (name, date)
Outcomes (ship, battle, result)
Ships are built in "classes" from the same design, and the class is usually named
for the first ship of that class. The relation Classes records the name of the
class, the type ('bb' for battleship or 'bc' for battlecruiser), the country that
built the ship, the number of main guns, the bore (diameter of the gun barrel,
in inches) of the main guns, and the displacement (weight, in tons). Relation
Ships records the name of the ship, the name of its class, and the year in which
the ship was launched. Relation Battles gives the name and date of battles
involving these ships, and relation Outcomes gives the result (sunk, damaged,
or ok) for each ship in each battle.
Write the following declarations:
a) A…
arrow_forward
Encapsulation in Java
Implement getters and setters for the class in the code editor. Ask the user input for each attribute and use the setters to set the attributes.
Inputs
1. Game Name
2. Year Published
3. Game Publisher
Sample Output
Enter game name: Genshin Impact
Enter year published: 2020
Enter game publisher: Hoyoverse
Genshin Impact is published on 2020 by Hoyoverse.
arrow_forward
The following is a Design Patterns: Singleton Pattern project with this UML class diagram.
Please explain the UML class diagram as shown in image:
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Related Questions
- An Abstract Data Type (ADT) is a data type that contains just variables, without information about their values. ADTs have many benefits. By reducing the issue to its simplest parts, it becomes easier to solve.arrow_forwardA strongly-typed data type implementation supports strongly-typed data, whereas a loosely-typed data type implementation supports loosely-typed data.arrow_forward4. Let A = {a, b, c, d}. Suppose R is an equivalence relation on A. Suppose R has three equivalence classes. Also a Rd andbR c. Write R as a set. Describe them all. ..............................................................arrow_forward
- Airline Company An airline company is interested in implementing a database system to manipulate the flights that it organizes. The airline company has a certain number of airplanes. Each airplane has a unique code, a number of seats and a production year. An airplane belongs to a certain airplane model. Each model has a unique model number and is provided by a certain company. We have different airplanes of each model. Each flight is identified by a flight number, a scheduled departure time and a scheduled arrival time. We want also to keep track of the airport from which the flight is scheduled as well as the destination airport. Each airport is identified by a unique code, its name and the country in which it is located. Journeys of each flight are organized on a daily basis. Each journey is identified by a date, its actual departure time, its actual arrival time, and the number of passengers, in addition to the airplane that performs the journey. We want to keep track of the…arrow_forwardO True O False 6. Every aggregation relationship is an association * O True O False 7. Removing a duplicate code in the program is an example for * (1 Point) Reverse engineeringarrow_forward> Create UML Class diagram for e-library system as described, make sure to show attributes, generalization where appropriate. operations, multiplicities, and aggregations/compositions, A library system has materials which would be books, journals, or CDs. All library material (books, magazines, and CD) has a unique identification number and a title. Books have one or more authors, journals have producer, while CDs have entertainer. all library materials can be loaned to users, users have user-id, user-name, birthdate (day, month, and year), age and phone-number. Users can loan any material, for each loan the library records material-id, the user-id, loan-date (day, month, and year), and loan time (hour, minute), and loan counter (shared)arrow_forward
- Airline Company An airline company is interested in implementing a database system to manipulate the flights thatit organizes.The airline company has a certain number of airplanes. Each airplane has a unique code, anumber of seats and a production year. An airplane belongs to a certain airplane model. Eachmodel has a unique model number and is provided by a certain company. We have differentairplanes of each model. Each flight is identified by a flight number, a scheduled departure timeand a scheduled arrival time. We want also to keep track of the airport from which the flight isscheduled as well as the destination airport. Each airport is identified by a unique code, its nameand the country in which it is located. Journeys of each flight are organized on a daily basis.Each journey is identified by a date, its actual departure time, its actual arrival time, and thenumber of passengers, in addition to the airplane that performs the journey. We want to keeptrack of the seats occupied,…arrow_forwardComputer Science A course and a teacher object have a many-to-one relation. You need to enable a function wherein a course cannot be saved without notifying the teacher. What should be done to accomplish the task?arrow_forwardWrite a program in c++ to find the transpose of a matrix. Matrix is to be stored in a class object which should be constructed using a constructor dynamically by asking rows and columns to the user.arrow_forward
- Question Make Class Diagram And Use Case Diagram The system Description Title: Working student's system The objective of the system is to create and manage a generic working domain for any student through his/her computer at Oryx college. A user should be able to organize the working space by a tree of topics corresponding to his/her activities in a recursive way. Each topic should have a name, a short description, and if needed a list of links to folders, files or the web. A topic is either a terminal or a non-terminal. If the topic is not terminal then it should be related to other topics. Any terminal or non-terminal topic should be related to its parent and possibly horizontally to other topics in the network of topics in a symmetric way. By using the generic built structure, the system should be illustrated and used for student work organization, which goal is to minimize the browsing time used by the student to manage his/her documents, by adding, removing, reading, any target…arrow_forwardA key aspect of an abstract data type is to facilitate O information hiding O interface hiding O information manipulation O attribute manipulationarrow_forwardData type 1.) Database Design : Take a crack at designing a simple database for 'A Small Dentist Office'. To keep it simple, please exclude any financial or billing information. So build a simple database that keeps track of patient information and appointments. Keep this very simple, maybe 4 tables. Part I: First determine the entities. The entities will be the tables. For example in an employee database the entities might be: an Employee, a Dept. These would then become the tables...the Employee table and the Dept table. Once you have come up with your 4 tables, move on to Part II. Part II: Design each table. Tables must include: a. Appropriate column names b. Data type for each column c. Whether a column can be 'null' or not d. Indicate any Primary Keys' and Foreign Keys'. e. Indicate any relationships with other tables PS → DO NOT USE MSAccess to do this Assign. I would use Excel for this Assign, or you could possibly use MS Word.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning