Unit 3(advanced state modeling & interaction meodelling)Manoj Reddy
The document provides an overview of advanced state modeling and interaction modeling techniques in UML. It discusses nested state diagrams and concurrent state diagrams for controlling complexity in state diagrams. It also covers activity models, use case models, and sequence models for interaction modeling. The relationships between class models, state models, and interaction models are also briefly described.
OS Process Synchronization, semaphore and Monitorssgpraju
The document summarizes key concepts in process synchronization and concurrency control, including:
1) Process synchronization techniques like semaphores, monitors, and atomic transactions that ensure orderly access to shared resources. Semaphores use wait() and signal() operations while monitors provide mutual exclusion through condition variables.
2) Concurrency control algorithms like locking and two-phase locking that ensure serializability of concurrent transactions accessing a database. Locking associates locks with data items to control concurrent access.
3) Challenges in concurrency control like deadlocks, priority inversion, and starvation that synchronization mechanisms aim to prevent. Log-based recovery with write-ahead logging and checkpoints is used to ensure atomicity of transactions in
This document contains code for a direct linking loader in two passes. The first pass loader reads the input file, stores the section information in a table, and generates an output file with the section table. The second pass loader reads the section table, resolves symbol references, and generates an executable file with the linked object code and resolved addresses. It opens input files, reads section headers, symbols and addresses, resolves symbols, and writes linked output to files at specified memory locations.
The document summarizes a seminar presentation on using directed acyclic graphs (DAGs) to represent and optimize basic blocks in compiler design. DAGs can be constructed from three-address code to identify common subexpressions and eliminate redundant computations. Rules for DAG construction include creating a node only if it does not already exist, representing identifiers as leaf nodes and operators as interior nodes. DAGs allow optimizations like common subexpression elimination and dead code elimination to improve performance of local optimizations on basic blocks. Examples show how DAGs identify common subexpressions and avoid recomputing the same values.
C++ provides built-in and user-defined data types. Built-in data types are pre-defined in C++ and include character, integer, floating point, double, void, and boolean. User-defined data types are composed of built-in types and include arrays, structures, unions, classes, and pointers. Data types determine the type of data that can be stored and the operations that can be performed on that data.
The document discusses subroutines in scientific programming. Subroutines are similar to functions but can return multiple values or no value at all via arguments, while functions return a single value via their name. A subroutine has a heading specifying its name and arguments, a specification part declaring argument types and intents, an execution part containing the code, and an END statement. Subroutines are called using the CALL statement with actual arguments associated with formal arguments. Arguments can be declared as INTENT(IN), INTENT(OUT), or INTENT(INOUT). Optional and keyword arguments allow fewer actual arguments than formal arguments in a subroutine call.
Run-Time Environments: Storage organization, Stack Allocation of Space, Access to Nonlocal Data on the Stack, Heap Management, Introduction to Garbage Collection, Introduction to Trace-Based Collection. Code Generation: Issues in the Design of a Code Generator, The Target Language, Addresses in the Target Code, Basic Blocks and Flow Graphs, Optimization of Basic Blocks, A Simple Code Generator, Peephole Optimization, Register Allocation and Assignment, Dynamic Programming Code-Generation
This document discusses structures in C++. It defines a structure as a collection of variables under a single name where the variables can be of different data types. It provides an example of declaring a structure with three variables of different types. It also discusses how to declare a structure variable which allocates memory, and how to access structure members using the dot operator. The document notes that structures can be nested within other structures and that arrays can contain structures or structures can contain arrays. It discusses passing structures to functions by value and by reference. Finally, it briefly introduces typedef, enumerated data types, and practice questions related to structures.
Unit 3(advanced state modeling & interaction meodelling)Manoj Reddy
The document provides an overview of advanced state modeling and interaction modeling techniques in UML. It discusses nested state diagrams and concurrent state diagrams for controlling complexity in state diagrams. It also covers activity models, use case models, and sequence models for interaction modeling. The relationships between class models, state models, and interaction models are also briefly described.
OS Process Synchronization, semaphore and Monitorssgpraju
The document summarizes key concepts in process synchronization and concurrency control, including:
1) Process synchronization techniques like semaphores, monitors, and atomic transactions that ensure orderly access to shared resources. Semaphores use wait() and signal() operations while monitors provide mutual exclusion through condition variables.
2) Concurrency control algorithms like locking and two-phase locking that ensure serializability of concurrent transactions accessing a database. Locking associates locks with data items to control concurrent access.
3) Challenges in concurrency control like deadlocks, priority inversion, and starvation that synchronization mechanisms aim to prevent. Log-based recovery with write-ahead logging and checkpoints is used to ensure atomicity of transactions in
This document contains code for a direct linking loader in two passes. The first pass loader reads the input file, stores the section information in a table, and generates an output file with the section table. The second pass loader reads the section table, resolves symbol references, and generates an executable file with the linked object code and resolved addresses. It opens input files, reads section headers, symbols and addresses, resolves symbols, and writes linked output to files at specified memory locations.
The document summarizes a seminar presentation on using directed acyclic graphs (DAGs) to represent and optimize basic blocks in compiler design. DAGs can be constructed from three-address code to identify common subexpressions and eliminate redundant computations. Rules for DAG construction include creating a node only if it does not already exist, representing identifiers as leaf nodes and operators as interior nodes. DAGs allow optimizations like common subexpression elimination and dead code elimination to improve performance of local optimizations on basic blocks. Examples show how DAGs identify common subexpressions and avoid recomputing the same values.
C++ provides built-in and user-defined data types. Built-in data types are pre-defined in C++ and include character, integer, floating point, double, void, and boolean. User-defined data types are composed of built-in types and include arrays, structures, unions, classes, and pointers. Data types determine the type of data that can be stored and the operations that can be performed on that data.
The document discusses subroutines in scientific programming. Subroutines are similar to functions but can return multiple values or no value at all via arguments, while functions return a single value via their name. A subroutine has a heading specifying its name and arguments, a specification part declaring argument types and intents, an execution part containing the code, and an END statement. Subroutines are called using the CALL statement with actual arguments associated with formal arguments. Arguments can be declared as INTENT(IN), INTENT(OUT), or INTENT(INOUT). Optional and keyword arguments allow fewer actual arguments than formal arguments in a subroutine call.
Run-Time Environments: Storage organization, Stack Allocation of Space, Access to Nonlocal Data on the Stack, Heap Management, Introduction to Garbage Collection, Introduction to Trace-Based Collection. Code Generation: Issues in the Design of a Code Generator, The Target Language, Addresses in the Target Code, Basic Blocks and Flow Graphs, Optimization of Basic Blocks, A Simple Code Generator, Peephole Optimization, Register Allocation and Assignment, Dynamic Programming Code-Generation
This document discusses structures in C++. It defines a structure as a collection of variables under a single name where the variables can be of different data types. It provides an example of declaring a structure with three variables of different types. It also discusses how to declare a structure variable which allocates memory, and how to access structure members using the dot operator. The document notes that structures can be nested within other structures and that arrays can contain structures or structures can contain arrays. It discusses passing structures to functions by value and by reference. Finally, it briefly introduces typedef, enumerated data types, and practice questions related to structures.
This document discusses distributed query processing and optimization. It covers query processing methodology which includes query decomposition, data localization, and global query optimization. Query decomposition takes a high-level query and breaks it down into fragments. Data localization determines which data fragments are involved. Global query optimization finds the most efficient execution plan by considering costs of operations and minimizing communication. The goal is to optimize queries running across distributed data in a network.
The document describes a simple code generator that generates target code for a sequence of three-address statements. It tracks register availability using register descriptors and variable locations using address descriptors. For each statement, it determines the locations of operands, copies them to a register if needed, performs the operation, updates the register and address descriptors, and stores values before procedure calls or basic block boundaries. It uses a getreg function to determine register allocation. Conditional statements are handled using compare and jump instructions and condition codes.
The Dempster-Shafer Theory was developed by Arthur Dempster in 1967 and Glenn Shafer in 1976 as an alternative to Bayesian probability. It allows one to combine evidence from different sources and obtain a degree of belief (or probability) for some event. The theory uses belief functions and plausibility functions to represent degrees of belief for various hypotheses given certain evidence. It was developed to describe ignorance and consider all possible outcomes, unlike Bayesian probability which only considers single evidence. An example is given of using the theory to determine the murderer in a room with 4 people where the lights went out.
The buffer cache stores recently accessed disk blocks in memory to reduce disk I/O. When a process requests data from a file, the kernel checks if the data is already cached in memory before accessing the disk. If cached, the data is returned directly from memory. If not cached, the data is read from disk into the cache. The buffer cache is managed as a pool using structures like a free list and buffer headers to track cached blocks. Caching recently used data in memory improves performance by reducing disk access frequency.
This document discusses various strategies for register allocation and assignment in compiler design. It notes that assigning values to specific registers simplifies compiler design but can result in inefficient register usage. Global register allocation aims to assign frequently used values to registers for the duration of a single block. Usage counts provide an estimate of how many loads/stores could be saved by assigning a value to a register. Graph coloring is presented as a technique where an interference graph is constructed and coloring aims to assign registers efficiently despite interference between values.
The document discusses run-time environments and how compilers support program execution through run-time environments. It covers:
1) The compiler cooperates with the OS and system software through a run-time environment to implement language abstractions during execution.
2) The run-time environment handles storage layout/allocation, variable access, procedure linkage, parameter passing and interfacing with the OS.
3) Memory is typically divided into code, static storage, heap and stack areas, with the stack and heap growing towards opposite ends of memory dynamically during execution.
This document discusses various techniques for optimizing computer code, including:
1. Local optimizations that improve performance within basic blocks, such as constant folding, propagation, and elimination of redundant computations.
2. Global optimizations that analyze control flow across basic blocks, such as common subexpression elimination.
3. Loop optimizations that improve performance of loops by removing invariant data and induction variables.
4. Machine-dependent optimizations like peephole optimizations that replace instructions with more efficient alternatives.
The goal of optimizations is to improve speed and efficiency while preserving program meaning and correctness. Optimizations can occur at multiple stages of development and compilation.
This document provides an overview of control structures in the C programming language. It discusses selection statements like if, if-else and switch statements that allow conditional execution of code. It also covers iteration statements like for, while and do-while loops that allow repetitive execution. Additionally, it explains jump statements like break, continue, goto and return that change the flow of control.
The document discusses operator overloading in C++. It defines operator overloading as allowing operators to perform special operations on user-defined types. As an example, the + operator can be overloaded to perform string concatenation in addition to numeric addition. It categorizes operators as unary, which operate on a single operand, and binary, which operate on two operands. The document provides an example of overloading the * operator to multiply the data members of a class. When called on two class objects, it returns a new object with the multiplied data members.
There are two primary forms of data exchange between parallel tasks - accessing a shared data space and exchanging messages.
Message passing refers to a means of communication between
different threads within a process
different processes running on the same node
different processes running on different nodes
When messages are passed between two different processes we speak of inter-process communication, or IPC.
Message passing can be used as a more process-oriented approach to synchronization than the "data-oriented" approaches used in providing mutual exclusion for shared resources.
The two main dimensions
Synchronous vs. asynchronous
Symmetric or asymmetric process/thread naming
RPC allows a program to call a subroutine that resides on a remote machine. When a call is made, the calling process is suspended and execution takes place on the remote machine. The results are then returned. This makes the remote call appear local to the programmer. RPC uses message passing to transmit information between machines and allows communication between processes on different machines or the same machine. It provides a simple interface like local procedure calls but involves more overhead due to network communication.
This document discusses different distributed computing system (DCS) models:
1. The minicomputer model consists of a few minicomputers with remote access allowing resource sharing.
2. The workstation model consists of independent workstations scattered throughout a building where users log onto their home workstation.
3. The workstation-server model includes minicomputers, diskless and diskful workstations, and centralized services like databases and printing.
It provides an overview of the key characteristics and advantages of different DCS models.
1) The document discusses structures in C programming. A structure is a collection of variables of different data types grouped together under a single name.
2) Structures are defined using the struct keyword followed by the structure name and members. Multiple variables of a structure type can be declared. Members are accessed using the dot operator.
3) Pointers to structures can be declared like pointers to other variables. Structure members can also be accessed using pointers. Arrays of structures allow storing multiple structures in an array. Structures can be nested by defining a structure inside another structure.
Cryptography and network Security
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National Institute of Standards and Technology (NIST).
The document discusses various UML diagrams used for modeling dynamic and implementation aspects of software systems. It describes interaction diagrams like sequence diagrams and collaboration diagrams which are used to model object interactions. It also covers state machine diagrams and activity diagrams which are used to model dynamic system behavior. Finally, it discusses implementation diagrams like package diagrams, component diagrams, and deployment diagrams which are used to model system organization and deployment.
The document discusses collaboration diagrams, which capture the dynamic behavior of objects collaborating to perform tasks. Collaboration diagrams illustrate object interactions through messages in a graph format. They show objects, links between objects, and messages to model control flow and coordination. Notations are used to represent classes, instances, links, messages, return values, self-messages, conditional messages, iteration, and collections of objects. Examples of converting sequence diagrams to collaboration diagrams for making a phone call, changing flight itineraries, and making a hotel reservation are provided.
C was developed by Dennis Ritchie while C++ was developed by Bjarne Stroustrup as an extension of C. C supports structured programming while C++ supports both structured and object-oriented programming. C++ adds object-oriented features like data encapsulation, inheritance, and polymorphism to C and is a superset of C.
Presentation of computer network on data link layersumit gyawali
The document presents information on the data link layer and services provided by the link layer. It discusses how the data link layer transfers data between network layers on different machines, divides data into frames, and adds headers for physical addressing. It describes three main services provided - unacknowledged connectionless, acknowledged connection-oriented, and acknowledged connectionless. Finally, it outlines how the data link layer is implemented using network interface cards that handle framing, linking, flow control, and error detection.
The document discusses C++ enumerations which allow the definition of custom data types with a fixed set of constants. An enumeration defines a list of named constants that can be used instead of regular integer values for improved type safety and clarity in code. Some key points covered include that enumerations are less crucial than structures but can simplify programming, enums can be used for things like days of the week or directions, and enums can have fields, constructors, methods but cannot extend classes. An example shows defining an enum for days of the week and using it in code.
This document discusses distributed query processing and optimization. It covers query processing methodology which includes query decomposition, data localization, and global query optimization. Query decomposition takes a high-level query and breaks it down into fragments. Data localization determines which data fragments are involved. Global query optimization finds the most efficient execution plan by considering costs of operations and minimizing communication. The goal is to optimize queries running across distributed data in a network.
The document describes a simple code generator that generates target code for a sequence of three-address statements. It tracks register availability using register descriptors and variable locations using address descriptors. For each statement, it determines the locations of operands, copies them to a register if needed, performs the operation, updates the register and address descriptors, and stores values before procedure calls or basic block boundaries. It uses a getreg function to determine register allocation. Conditional statements are handled using compare and jump instructions and condition codes.
The Dempster-Shafer Theory was developed by Arthur Dempster in 1967 and Glenn Shafer in 1976 as an alternative to Bayesian probability. It allows one to combine evidence from different sources and obtain a degree of belief (or probability) for some event. The theory uses belief functions and plausibility functions to represent degrees of belief for various hypotheses given certain evidence. It was developed to describe ignorance and consider all possible outcomes, unlike Bayesian probability which only considers single evidence. An example is given of using the theory to determine the murderer in a room with 4 people where the lights went out.
The buffer cache stores recently accessed disk blocks in memory to reduce disk I/O. When a process requests data from a file, the kernel checks if the data is already cached in memory before accessing the disk. If cached, the data is returned directly from memory. If not cached, the data is read from disk into the cache. The buffer cache is managed as a pool using structures like a free list and buffer headers to track cached blocks. Caching recently used data in memory improves performance by reducing disk access frequency.
This document discusses various strategies for register allocation and assignment in compiler design. It notes that assigning values to specific registers simplifies compiler design but can result in inefficient register usage. Global register allocation aims to assign frequently used values to registers for the duration of a single block. Usage counts provide an estimate of how many loads/stores could be saved by assigning a value to a register. Graph coloring is presented as a technique where an interference graph is constructed and coloring aims to assign registers efficiently despite interference between values.
The document discusses run-time environments and how compilers support program execution through run-time environments. It covers:
1) The compiler cooperates with the OS and system software through a run-time environment to implement language abstractions during execution.
2) The run-time environment handles storage layout/allocation, variable access, procedure linkage, parameter passing and interfacing with the OS.
3) Memory is typically divided into code, static storage, heap and stack areas, with the stack and heap growing towards opposite ends of memory dynamically during execution.
This document discusses various techniques for optimizing computer code, including:
1. Local optimizations that improve performance within basic blocks, such as constant folding, propagation, and elimination of redundant computations.
2. Global optimizations that analyze control flow across basic blocks, such as common subexpression elimination.
3. Loop optimizations that improve performance of loops by removing invariant data and induction variables.
4. Machine-dependent optimizations like peephole optimizations that replace instructions with more efficient alternatives.
The goal of optimizations is to improve speed and efficiency while preserving program meaning and correctness. Optimizations can occur at multiple stages of development and compilation.
This document provides an overview of control structures in the C programming language. It discusses selection statements like if, if-else and switch statements that allow conditional execution of code. It also covers iteration statements like for, while and do-while loops that allow repetitive execution. Additionally, it explains jump statements like break, continue, goto and return that change the flow of control.
The document discusses operator overloading in C++. It defines operator overloading as allowing operators to perform special operations on user-defined types. As an example, the + operator can be overloaded to perform string concatenation in addition to numeric addition. It categorizes operators as unary, which operate on a single operand, and binary, which operate on two operands. The document provides an example of overloading the * operator to multiply the data members of a class. When called on two class objects, it returns a new object with the multiplied data members.
There are two primary forms of data exchange between parallel tasks - accessing a shared data space and exchanging messages.
Message passing refers to a means of communication between
different threads within a process
different processes running on the same node
different processes running on different nodes
When messages are passed between two different processes we speak of inter-process communication, or IPC.
Message passing can be used as a more process-oriented approach to synchronization than the "data-oriented" approaches used in providing mutual exclusion for shared resources.
The two main dimensions
Synchronous vs. asynchronous
Symmetric or asymmetric process/thread naming
RPC allows a program to call a subroutine that resides on a remote machine. When a call is made, the calling process is suspended and execution takes place on the remote machine. The results are then returned. This makes the remote call appear local to the programmer. RPC uses message passing to transmit information between machines and allows communication between processes on different machines or the same machine. It provides a simple interface like local procedure calls but involves more overhead due to network communication.
This document discusses different distributed computing system (DCS) models:
1. The minicomputer model consists of a few minicomputers with remote access allowing resource sharing.
2. The workstation model consists of independent workstations scattered throughout a building where users log onto their home workstation.
3. The workstation-server model includes minicomputers, diskless and diskful workstations, and centralized services like databases and printing.
It provides an overview of the key characteristics and advantages of different DCS models.
1) The document discusses structures in C programming. A structure is a collection of variables of different data types grouped together under a single name.
2) Structures are defined using the struct keyword followed by the structure name and members. Multiple variables of a structure type can be declared. Members are accessed using the dot operator.
3) Pointers to structures can be declared like pointers to other variables. Structure members can also be accessed using pointers. Arrays of structures allow storing multiple structures in an array. Structures can be nested by defining a structure inside another structure.
Cryptography and network Security
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National Institute of Standards and Technology (NIST).
The document discusses various UML diagrams used for modeling dynamic and implementation aspects of software systems. It describes interaction diagrams like sequence diagrams and collaboration diagrams which are used to model object interactions. It also covers state machine diagrams and activity diagrams which are used to model dynamic system behavior. Finally, it discusses implementation diagrams like package diagrams, component diagrams, and deployment diagrams which are used to model system organization and deployment.
The document discusses collaboration diagrams, which capture the dynamic behavior of objects collaborating to perform tasks. Collaboration diagrams illustrate object interactions through messages in a graph format. They show objects, links between objects, and messages to model control flow and coordination. Notations are used to represent classes, instances, links, messages, return values, self-messages, conditional messages, iteration, and collections of objects. Examples of converting sequence diagrams to collaboration diagrams for making a phone call, changing flight itineraries, and making a hotel reservation are provided.
C was developed by Dennis Ritchie while C++ was developed by Bjarne Stroustrup as an extension of C. C supports structured programming while C++ supports both structured and object-oriented programming. C++ adds object-oriented features like data encapsulation, inheritance, and polymorphism to C and is a superset of C.
Presentation of computer network on data link layersumit gyawali
The document presents information on the data link layer and services provided by the link layer. It discusses how the data link layer transfers data between network layers on different machines, divides data into frames, and adds headers for physical addressing. It describes three main services provided - unacknowledged connectionless, acknowledged connection-oriented, and acknowledged connectionless. Finally, it outlines how the data link layer is implemented using network interface cards that handle framing, linking, flow control, and error detection.
The document discusses C++ enumerations which allow the definition of custom data types with a fixed set of constants. An enumeration defines a list of named constants that can be used instead of regular integer values for improved type safety and clarity in code. Some key points covered include that enumerations are less crucial than structures but can simplify programming, enums can be used for things like days of the week or directions, and enums can have fields, constructors, methods but cannot extend classes. An example shows defining an enum for days of the week and using it in code.
1. MODEL ANSWERS: DBMS ASSIGNMENT # 2
(REFER UNSOLVED EXCERCISES: CHAPTER 3 OF KORTH)
- PS Gill
Problem # 1 For the schema given below, express the following queries in
relational algebra:-
employee (person-name, street, city)
works (person-name, company-name, salary)
company (company-name, city)
manages (person-name, manager-name)
(a) Find names of employees working for First-Bank-Co
∏person-name (σcompany-name = “First-Bank-Co” (works))
(b) Find names and cities of residence of employees working for First-Bank-Co
∏person-name, city (σcompany-name = “First-Bank-Co” (employee × works))
(c) Find name, street and city of residence of employees working for First-Bank-Co
and earning more than 10,000
∏person-name, street, city(σcompany-name = “First-Bank-Co” ∧ salary > 10000 (employee × works))
(d) Find names of employees working in the same city where they live
∏person-name (σemployee. city = company. city (employee × works × company))
(e) Find names of employees who live in the same street and city as their managers
emp ← employee × manages
∏ emp. person-name (σemp. manager-name = mgr. person-name ∧ emp. city = mgr. city ∧ emp. street = mgr. street
(emp × ρmgr (employee)))
(f) Find names of employees, who are not working for Fist-Bank-Co
∏ person-name ( σcompany-name ≠ “First-Bank-Co” (works))
(g) Find names of employees, who earn more than every employee of First-Bank-Co
temp ← G max ( salary) ( σ company-name = “First-Bank-Co” (works) )
∏ person-name (σ salary > Temp (works) )
(h) Find companies located in every city, where First-Bank-Co is located
company ÷ ∏city (σ company-name = “First-Bank-Co” (company) )
Problem # 2 For the schema given below, find name & city of customers having a loan
from the bank:-
Customer (customer-name, customer-street, customer-city)
Branch (branch-name, branch-city, assets)
Account (account-number, branch-name, balance)
2. Loan (loan-number, branch-name, amount)
Depositor (customer-name, account-number)
Borrower (customer-name, loan-number)
Answer:- ∏ customer-name, customer-city (customer × borrower)
(a) Though Jackson’s name is there in the borrower table, why does he not appear in
the result (For Borrower Table, refer Fig 3.7 of Korth)?
Since, Jackson’s name is not there in the customer table (For Customer Table, refer
Fig 3.4 of Korth). So, the natural join of customer and borrower will not contain
any tuple for Jackson.
(b) What should be done to make Jackson appear in the result?
Add Jackson’s information in customer table.
(c ) Without modifying the database, use outer-join to make Jackson appear in the
result.
∏ customer-name, customer-city (customer × borrower)
Problem # 3 Consider the schema shown in Problem # 1 and give relational algebra
expressions for the following:-
(a) Modify database so that Jones now lives in Newtown
temp ← ∏ person-name, street, “Newtown” (σperson-name= “Jones” (employee))
employee ← temp ∪ ( employee – (σperson-name= “Jones” (employee)))
(b) Give all employees of First-Bank-Co a 10% rise in salary
temp ← ∏ person-name, company-name, salary*1.1 (σcompany-name= “First-Bank-Co” (works))
works ← Temp ∪ ( works – (σcompany-name= “First-Bank-Co” (works)))
(c) Give all managers a 10% rise in salary
temp1 ←∏works. person-name (works × works. person-name = manages. manager-name manages)
temp2 ← works × temp1
works ← ∏ person-name, company-name, salary*1.1 (temp2) ∪ (works – temp2)
(d) Give all managers a 10% rise in salary unless salary is more than 100000; and in
that case give a 3% rise.
temp1 ←∏works. person-name (works × works. person-name = manages. manager-name manages)
temp2 ← works × Temp1
temp3 ← ∏ person-name, company-name, salary*1.10 (σsalary < 100000 (temp2))
temp4 ← ∏ person-name, company-name, salary*1.03 (σsalary > 100000 (temp2))
works ← temp3 ∪ temp4 ∪ (works – temp2)
3. (e) Delete all tuples of works for employees working for Small-Bank-Co
works ← works - σcompany-name= “Small-Bank-Co” (works)
Problem # 4 For the schema shown in Problem # 2, find the accounts held by
more than two customers.
temp ← account-number G count-distinct (customer-name) as NUMB (depositor)
∏ account-number (σ NUMB > 2 (temp) )
Problem # 5 For the schema shown in Problem # 2, give relational algebra
expressions for the following queries:-
(a) Find the company with most employees.
temp1 ← company-name G count-distinct (person-name) as NUMB (works)
temp2 ← G max (NUMB) (temp1)
∏ company-name (σ NUMB = temp2 (temp1) )
(b) Find the company with the smallest pay-roll.
temp1 ← company-name G count-distinct (person-name) as NUMB (works)
temp2 ← G min (NUMB) (temp1)
∏ company-name (σ NUMB = Temp2 (temp1) )
(c) Find the company, whose employees earn more salary, on the average, than the
average salary of First-Bank-Co employees.
temp1 ← company-name G average (salary) as AVG-SAL (works)
temp2 ← G average (salary) (σ company-name = “First-Bank-Co” (works))
∏ company-name (σ AVG-SAL > Temp2 (temp1) )
Problem # 6 Let there be Schemas R (A,B,C) & S(D,E,F) and relations r(R) & s(S).
Give expressions in Tuple Relational Calculus (TRC) equivalent to the following
expressions in Relational Algebra (RA).
(a) ∏A (r)
TRC: { t | ∃ s ∈ r ( t [A] = s[A] ) }
(b) σB=17 (r)
TRC: { t | t ∈ r ∧ t [B] = 17 }
(c) r × s
TRC:{ t | ∃ u ∈ r ( t [A] = u[A] ∧ t [B] = u [B] ∧ t [C] = u [C] ] ∧
∃ v ∈ s ( t [D] = v[D] ∧ t [E] = v [E] ∧ t [F] = v [F] ) ) }
4. (d) ∏A,F (σC=D (r × s))
{ t | ∃ u ∈ r ( t [A] = u[A] ∧ ∃ v ∈ s ( t [F] = v [F] ∧ u [C] = v [D]) ) }
Problem # 7 Let there be Schema R (A,B,C) & and relations r1 (R) & r2 (R). Give
expressions in Domain Relational Calculus (DRC) equivalent to the following
expressions in Relational Algebra (RA).
(a) ∏A (r1)
DRC: { 〈a〉 | ∃ b,c ( 〈a,b,c〉 ∈ r1 ) }
(b) σB=17 (r1)
DRC: { 〈a,b,c〉 | 〈a,b,c〉 ∈ r1 ∧ b = 17 }
(c) r1 ∪ r2
DRC: { 〈a,b,c〉 | 〈a,b,c〉 ∈ r1 ∨ 〈a,b,c〉 ∈ r2}
(d) r1 ∩ r2
DRC: { 〈a,b,c〉 | 〈a,b,c〉 ∈ r1 ∧ 〈a,b,c〉 ∈ r2}
(e) r1 − r2
DRC: { 〈a,b,c〉 | 〈a,b,c〉 ∈ r1 ∧ ¬ 〈a,b,c〉 ∈ r2}
(f) ∏A,B (r1) × ∏B,C (r2)
DRC: { 〈a1,b,c2〉 | ∃ c1 ( 〈a1,b,c1〉 ∈ r1 ∧ ∃ a2 ( 〈a2,b,c2〉 ∈ r2 ))}
Problem # 8 Let there be Schemas R (A,B) & S(A,C) and relations r(R) & s(S). Give
Relational Algebra expressions equivalent to the following Domain Relational Calculus
(DRC) expressions.
(a) { 〈a〉 | ∃ b ( 〈a,b〉 ∈ r ∧ b = 17 )}
RA (σ B= 17 (r))
(b) { 〈a, b,c〉 | 〈a,b〉 ∈ r ∧ 〈a,c〉 ∈ s)}
RA r × s
(c) { 〈a〉 | ∃ b ( 〈a,b〉 ∈ r ) ∨ ∀ c (∃ d ( 〈d,c〉 ∈ s ) ⇒ 〈a,c〉 ∈ s )}
RA ∏A ( r ∪ ∏A,B ( ( r × s ) ÷ ∏C (s)))