SlideShare a Scribd company logo
1
Database Management System
BT0066 Part-2
By Milan K Antony
Copy© Milan K Antony | milankantony@gmail.com |
2
1. Explain the statement that relational algebra operators
can be composed. Why the ability to compose operators is
important?
The Relational Algebra consists of a set of basic
operators that take relations as their operands and return the
result as a relation. This means that operators can be
composed - the output of one operation may be used as
input to another operation.
 Query languages: Allow manipulation and retrieval of data
from a database.
 Relational model supports simple, powerful QLs:
o Strong formal foundation based on logic.
o Allows for much optimization.
 Query Languages != programming languages!
o QLs not expected to be “Turing complete”.
o QLs not intended to be used for complex
calculations.
o QLs support easy, efficient access to large data
sets.
Formal Relational Query Languages
 Two mathematical Query Languages form the basis for
“real” languages (e.g. SQL), and for implementation:
o Relational Algebra: More operational(procedural),
very useful for representing execution plans.
Copy© Milan K Antony | milankantony@gmail.com |
3
o Relational Calculus: Lets users describe what they
want, rather than how to compute it. (Non-
operational, declarative.)
Preliminaries
 A query is applied to relation instances, and the result
of a query is also a relation instance.
o Schemas of input relations for a query are fixed
(but query will run regardless of instance!)
o The schema for the result of a given query is also
fixed! Determined by definition of query language
constructs.
 Positional vs. named-field notation:
o Positional notation easier for formal definitions,
named-field notation more readable.
o Both used in SQL
Relational Algebra
 Basic operations:
o Selection ( ) Selects a subset of rows
from relation.
o Projection ( ) Deletes unwanted columns
from relation.
o Cross-product ( ) Allows us to combine two
relations.
Copy© Milan K Antony | milankantony@gmail.com |
4
o Set-difference ( ) Tuples in reln. 1, but not
in reln. 2.
o Union ( ) Tuples in reln. 1 and in reln. 2.
 Additional operations:
o Intersection, join, division, renaming: Not
essential, but (very!) useful.
 Since each operation returns a relation, operations can be
composed! (Algebra is “closed”.)
Projection
 Deletes attributes that are not in projection list.
 Schema of result contains exactly the fields in the
projection list, with the same names that they had in the
(only) input relation.
 Projection operator has to eliminate duplicates! (Why??,
what are the consequences?)
o Note: real systems typically don’t do duplicate
elimination unless the user explicitly asks for it.
(Why not?)
Selection
 Selects rows that satisfy selection condition.
 Schema of result identical to schema of (only) input
relation.
 Result relation can be the input for another relational
algebra operation! (Operator composition.)
Copy© Milan K Antony | milankantony@gmail.com |
5
Union, Intersection, Set-Difference
 All of these operations take two input relations, which
must be union-compatible:
o Same number of fields.
o `Corresponding’ fields have the same type.
 What is the schema of result?
Cross-Product
 Each row of S1 is paired with each row of R1.
 Result schema has one field per field of S1 and R1, with
field names `inherited’ if possible.
o Conflict: Both S1 and R1 have a field called sid.
Division
 Not supported as a primitive operator, but useful for
expressing queries
like:
Find sailors who have reserved all boats.
 Precondition: in A/B, the attributes in B must be
included in the schema for A. Also, the result has
attributes A-B.
o SALES(supId, prodId);
o PRODUCTS(prodId);
o Relations SALES and PRODUCTS must be built using
projections.
Copy© Milan K Antony | milankantony@gmail.com |
6
o SALES/PRODUCTS: the ids of the suppliers
supplying ALL products.
Expressing A/B Using Basic Operators
 Division is not essential op; just a useful shorthand.
o (Also true of joins, but joins are so common that
systems implement joins specially. Division is NOT
implemented in SQL).
 Idea: For SALES/PRODUCTS, compute all products such
that there exists at least one supplier not supplying it.
o x value is disqualified if by attaching y value from
B, we obtain an xy tuple that is not in A.
Since each operation returns a relation, operations can
be composed!
2. What is an unsafe query? Give an example and explain
why it is important to disallow such queries.
Here is an informal example of an unsafe query. Consider the
database of all
people living in Sweden, and suppose that the Last_Name field
may contain any string of up to 64 characters. Then the
following is an unsafe query which is easily represented in the
domain calculus. “Give me the set of strings of length at most
64 which do not represent the last name of someone living in
Sweden.”
Copy© Milan K Antony | milankantony@gmail.com |
7
The formalization of safety is rather technical,and will not be
presented here. For a query designed by hand, it is usually
obvious whether or not it is safe. Of course, a query
processor must be able to detect safety, or lack thereof.
3. Give a set of FDs for the relation schema R(A,B,C,D)
with primary key AB under which R is in 1NF but not in
2NF.
. Consider the set of FD: AB CD→ and B C→ . AB is
obviously a key for this
relation since AB CD→ implies AB ABCD→ . It is a primary
key since there are
no smaller subsets of keys that hold over R(A,B,C,D). The
FD: B C→ violates
2NF since:
C B is false; that is, it is not a trivial FD
B is not a superkey
C is not part of some key for R
B is a proper subset of the key AB (transitive dependency)
4. When it is useful to have replication or fragmentation
of data? Explain.
Replication is the process of sharing information so as to
ensure consistency between redundant resources, such as
software or hardware components, to improve reliability,
Copy© Milan K Antony | milankantony@gmail.com |
8
fault-tolerance, or accessibility. It could be data replication
if the same data is stored on multiple storage devices, or
computation replication if the same computing task is executed
many times. A computational task is typically replicated in
space, i.e. executed on separate devices, or it could be
replicated in time, if it is executed repeatedly on a single
device.
In computing, failover is the capability to switch over
automatically to a redundant or standby computer server,
system, or network upon the failure or abnormal termination
of the previously active application,
[1]
server, system, or
network. Failover happens without human intervention and
generally without warning, unlike switchover
Fault-tolerance or graceful degradation is the property
that enables a system (often computer-based) to continue
operating properly in the event of the failure of (or one or
more faults within) some of its components. If its operating
quality decreases at all, the decrease is proportional to the
severity of the failure, as compared to a naïvely-designed
system in which even a small failure can cause total breakdown.
Fault-tolerance is particularly sought-after in high-availability
or life-critical systems.
5. What is late binding of methods? Give an example of
inheritance that illustrates the need for dynamic binding.
Copy© Milan K Antony | milankantony@gmail.com |
9
Connecting a method call(i.e. Function Call) to a method
body(i.e. Function) is called binding. When binding is
performed before the program is run (by the compiler and
linker, if there is one), it’s called early binding. You might
not have heard the term before because it has never been an
option with procedural languages. C compilers have only one
kind of method call, and that’s early binding. The other
solution is called late binding, which means that the binding
occurs at run time, based on the type of object. Late binding
is also called dynamic binding or run-time binding. When a
language implements late binding, there must be some
mechanism to determine the type of the object at run time
and to call the appropriate method. That is, the compiler still
doesn’t know the object type, but the method-call mechanism
finds out and calls the correct method body. The late-binding
mechanism varies from language to language, but you can
imagine that some sort of type information must be installed
in the objects. All method binding in Java uses late binding
unless the method is static or final (private methods are
implicitly final). This means that ordinarily you don’t need to
make any decisions about whether late binding will occur—it
happens automatically. Reference Links - Here is a very nice
article on Difference Between Early and late Binding The
polymorphic assignment p := r is valid because of the above
rule. If condition c is false, p will be attached to an object
of type POLYGON for the computation of p . perimeter ,
which will thus use the polygon algorithm. In the opposite case,
Copy© Milan K Antony | milankantony@gmail.com |
10
however, p will be attached to a rectangle; then the
computation will use the version redefined for RECTANGLE .
This is known as dynamic binding .
6. Describe the circumstances in which you would choose to
use Embedded SQL rather than Standalone SQL or only a
general-purpose programming language.
Embedded SQL refers to the use of standard SQL statements
embedded within a procedural programming language SQL
functions are primarily a mechanism for extending the power
of SQL to handle attributes of complex data types (like
images), or to perform complex and non-standard operations.
Embedded SQL is useful when imperative actions like displaying
results and interacting with the user are needed. These cannot
be done conveniently in an SQL only environment. Embedded
SQL can be used instead of SQL functions by retrieving data
and then performing the function's operations on the SQL
result. However a drawback is that a lot of query-evaluation
functionality may end up getting repeated in the host language
code
When sorting data to be displayed in a subfile, the Open Query
File (OPNQRYF) command is often used. This comes in handy
when you are providing the user with the ability to change how
he displays the data in the subfile. I agree that OPNQRYF is a
powerful way to select and sort data before loading your
subfile, but its real strength is sorting and selecting data in a
Copy© Milan K Antony | milankantony@gmail.com |
11
batch environment. I have used it with subfile programs, and,
although
it’s a bit of a pain, it does work, especially if you use
optimizing techniques. Another method for providing multiple
sorting criteria in your subfiles is to use logical files. One
problem with logical files is that you are required to maintain
an access path for every sort criterion required by your users.
Another problem is the complexity of your subfile load routine
when using multiple logical files to provide the users with
different looks at the data. That gets ugly.
What if you had a tool that allowed you the same select and
sort capabilities as logical files and OPNQRYF but did so in a
flexible and efficient manner, while allowing you to produce a
well-structured, easily maintainable program? Wouldn’t that be
awesome? Well, with embedded SQL, that’s just what you get.
SQL embedded into your RPG program allows you to sort and
select the data as you want, but it also provides the user with
some added power.
What if multiple users from different departments are going
to use your subfile program but, as is usually the case with
users, they each want to see the data in a different order?
You can certainly accomplish this by including enough logical
files in your program to cover every possible sorting criterion,
but this may require many logical files, especially if the user
wants secondary and tertiary sorts. This may also create
unnecessary access path administration for the system if all the
logical files are created for this one application. It also makes
Copy© Milan K Antony | milankantony@gmail.com |
12
for an ugly subfile build routine in your RPG program. Another
method to allow dynamically sorting subfiles is to use OPNQRYF.
You could create one open query for each possible sort or
dynamically create the open query based on what the user
wants to do. Either way, you would be passing parameters back
and forth between the RPG and CL programs to either build
the OPNQRYF command or select which specific OPNQRYF
command to use. I’ve messed around with the latter method,
and the CL can get cumbersome if you try to give the users
complete flexibility by allowing them to sort by more than one
field at a time. I love users, but that’s a lot of work just to
provide them with a different view of the same data.
By embedding SQL, you can dynamically build your SELECT
statement based on how the user wants to sort the data, all in
one neat little subroutine. You can also use techniques that
allow you to provide this capability very efficiently and, with a
couple of minor changes, for data on other AS/400s. I’ll tell
you how it’s done.
7. What is relational completeness? If a query language is
relationally complete, can you write any desired query in
that language?
Relational algebra is essentially equivalent in expressive
power to relational calculus (and thus first-order logic); this
result is known as Codd's theorem. Some care, however, has
Copy© Milan K Antony | milankantony@gmail.com |
13
to be taken to avoid a mismatch that may arise between the
two languages since negation, applied to a formula of the
calculus, constructs a formula that may be true on an infinite
set of possible tuples, while the difference operator of
relational algebra always returns a finite result. To overcome
these difficulties, Codd restricted the operands of relational
algebra to finite relations only and also proposed restricted
support for negation (NOT) and disjunction (OR). Analogous
restrictions are found in many other logic-based computer
languages. Codd defined the term relational completeness to
refer to a language that is complete with respect to first-
order predicate calculus apart from the restrictions he
proposed. In practice the restrictions have no adverse effect
on the applicability of his relational algebra for database
purposes.
8. What types of anomalies are found in relational
database
There are several standard types of anomaly in a
database. It doesn't need to be a relational database; the
same anomalies are present in any database. A properly
designed relational database specifically aims to eliminate these
anomalies. If the database is not properly normalized, it is
susceptible to insertion, update and deletion anomalies. The
update anomaly occurs when the same data is stored in several
records and a change has to be made. If only some of the
Copy© Milan K Antony | milankantony@gmail.com |
14
records are updated, an update erors occurs - eg we could
end up recording two teachers as giving the same class. If
you are dealing with hundreds of records, this is quite likely
to occur. If you wish to record some info in advance of
needing it, such as the name of a teacher for a class that at
present has no students enrolled, and the teacher name is only
recorded next to each student rather than in a separate table,
then with no student enrolled, you can't add the teacher info.
This is an insertion anomaly. A deletion anomaly occurs not
when you delete something by accident, but when deleting a
record also removes the only instance of some other data. So
if we recorded a class's details along with a student's, have
only one student enrolled and then that student withdrew, we
would be deleting the class info as well. Normalisation of a
relational database is designed to overcome these problems
Copy© Milan K Antony | milankantony@gmail.com |

More Related Content

What's hot

Handout#08
Handout#08Handout#08
Handout#08
Sunita Milind Dol
 
Programming in c by pkv
Programming in c by pkvProgramming in c by pkv
Programming in c by pkv
Pramod Vishwakarma
 
Handout#06
Handout#06Handout#06
Handout#06
Sunita Milind Dol
 
Chapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsChapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutions
Saeed Iqbal
 
The Database Environment Chapter 4
The Database Environment Chapter 4The Database Environment Chapter 4
The Database Environment Chapter 4
Jeanie Arnoco
 
C programming course material
C programming course materialC programming course material
C programming course material
Ranjitha Murthy
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NET
Waqas Tariq
 
Cobol questions and answers
Cobol questions and answersCobol questions and answers
Cobol questions and answersSweta Singh
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
Ankit92Chitnavis
 
Advanced property tracking Industrial Modeling Framework
Advanced property tracking Industrial Modeling FrameworkAdvanced property tracking Industrial Modeling Framework
Advanced property tracking Industrial Modeling Framework
Alkis Vazacopoulos
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
Infinity Tech Solutions
 
Assignment11
Assignment11Assignment11
Assignment11
Sunita Milind Dol
 
Basic Coding In VHDL COding
Basic Coding In VHDL COdingBasic Coding In VHDL COding
Basic Coding In VHDL COding
anna university
 
Handout#04
Handout#04Handout#04
Handout#04
Sunita Milind Dol
 
Handout#07
Handout#07Handout#07
Handout#07
Sunita Milind Dol
 
Modeling Aspects with AP&P Components
Modeling Aspects with AP&P ComponentsModeling Aspects with AP&P Components
Modeling Aspects with AP&P Components
mukhtarhudaya
 
Programming topics. syed arslan rizvi
Programming topics. syed arslan rizviProgramming topics. syed arslan rizvi
Programming topics. syed arslan rizviSyed Arslan Rizvi
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
sumitbardhan
 

What's hot (20)

Handout#08
Handout#08Handout#08
Handout#08
 
Programming in c by pkv
Programming in c by pkvProgramming in c by pkv
Programming in c by pkv
 
Handout#06
Handout#06Handout#06
Handout#06
 
Chapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutionsChapter 9 & chapter 10 solutions
Chapter 9 & chapter 10 solutions
 
The Database Environment Chapter 4
The Database Environment Chapter 4The Database Environment Chapter 4
The Database Environment Chapter 4
 
Training 8051Report
Training 8051ReportTraining 8051Report
Training 8051Report
 
C programming course material
C programming course materialC programming course material
C programming course material
 
Ak procedural vs oop
Ak procedural vs oopAk procedural vs oop
Ak procedural vs oop
 
Aspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NETAspect Oriented Programming Through C#.NET
Aspect Oriented Programming Through C#.NET
 
Cobol questions and answers
Cobol questions and answersCobol questions and answers
Cobol questions and answers
 
Procedural programming
Procedural programmingProcedural programming
Procedural programming
 
Advanced property tracking Industrial Modeling Framework
Advanced property tracking Industrial Modeling FrameworkAdvanced property tracking Industrial Modeling Framework
Advanced property tracking Industrial Modeling Framework
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
 
Assignment11
Assignment11Assignment11
Assignment11
 
Basic Coding In VHDL COding
Basic Coding In VHDL COdingBasic Coding In VHDL COding
Basic Coding In VHDL COding
 
Handout#04
Handout#04Handout#04
Handout#04
 
Handout#07
Handout#07Handout#07
Handout#07
 
Modeling Aspects with AP&P Components
Modeling Aspects with AP&P ComponentsModeling Aspects with AP&P Components
Modeling Aspects with AP&P Components
 
Programming topics. syed arslan rizvi
Programming topics. syed arslan rizviProgramming topics. syed arslan rizvi
Programming topics. syed arslan rizvi
 
358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1358 33 powerpoint-slides_1-introduction-c_chapter-1
358 33 powerpoint-slides_1-introduction-c_chapter-1
 

Viewers also liked

Bt0064 logic design2
Bt0064 logic design2Bt0064 logic design2
Bt0064 logic design2
Techglyphs
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
Techglyphs
 
Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Bt8901 objective oriented systems2
Bt8901 objective oriented systems2
Techglyphs
 
Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)
Techglyphs
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
Techglyphs
 
Bt9002 Grid computing 2
Bt9002 Grid computing 2Bt9002 Grid computing 2
Bt9002 Grid computing 2
Techglyphs
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1
Techglyphs
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
Techglyphs
 
Bt9002 grid computing 1
Bt9002 grid computing 1Bt9002 grid computing 1
Bt9002 grid computing 1
Techglyphs
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1
Techglyphs
 
Bt0064 logic design1
Bt0064 logic design1Bt0064 logic design1
Bt0064 logic design1
Techglyphs
 
Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)
Techglyphs
 
Elements analysis dfd_er_std
Elements analysis dfd_er_stdElements analysis dfd_er_std
Elements analysis dfd_er_std
Ammar Jamali
 

Viewers also liked (13)

Bt0064 logic design2
Bt0064 logic design2Bt0064 logic design2
Bt0064 logic design2
 
Bt0074 oops with java2
Bt0074 oops with java2Bt0074 oops with java2
Bt0074 oops with java2
 
Bt8901 objective oriented systems2
Bt8901 objective oriented systems2Bt8901 objective oriented systems2
Bt8901 objective oriented systems2
 
Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)Bt0062 fundamentals of it(2)
Bt0062 fundamentals of it(2)
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
Bt9002 Grid computing 2
Bt9002 Grid computing 2Bt9002 Grid computing 2
Bt9002 Grid computing 2
 
Bt0066 database management system1
Bt0066 database management system1Bt0066 database management system1
Bt0066 database management system1
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
 
Bt9002 grid computing 1
Bt9002 grid computing 1Bt9002 grid computing 1
Bt9002 grid computing 1
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1
 
Bt0064 logic design1
Bt0064 logic design1Bt0064 logic design1
Bt0064 logic design1
 
Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)Bt0062 fundamentals of it(1)
Bt0062 fundamentals of it(1)
 
Elements analysis dfd_er_std
Elements analysis dfd_er_stdElements analysis dfd_er_std
Elements analysis dfd_er_std
 

Similar to Bt0066 database management system2

FRACTAL ANALYSIS OF GOOD PROGRAMMING STYLE
FRACTAL ANALYSIS OF GOOD PROGRAMMING STYLEFRACTAL ANALYSIS OF GOOD PROGRAMMING STYLE
FRACTAL ANALYSIS OF GOOD PROGRAMMING STYLE
cscpconf
 
Fractal analysis of good programming style
Fractal analysis of good programming styleFractal analysis of good programming style
Fractal analysis of good programming style
csandit
 
Slides chapter 11
Slides chapter 11Slides chapter 11
Slides chapter 11
Priyanka Shetty
 
Thoughtful Software Design
Thoughtful Software DesignThoughtful Software Design
Thoughtful Software Design
Giovanni Scerra ☃
 
Software Engineering - SOFTWARE DESIGN Process
Software Engineering - SOFTWARE DESIGN ProcessSoftware Engineering - SOFTWARE DESIGN Process
Software Engineering - SOFTWARE DESIGN Process
Dr Anuranjan Misra
 
Software architacture recovery
Software architacture recoverySoftware architacture recovery
Software architacture recovery
Imdad Ul Haq
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
Nimai Chand Das
 
Book management system
Book management systemBook management system
Book management system
SHARDA SHARAN
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
ReKruiTIn.com
 
Matopt
MatoptMatopt
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptx
Fajar Baskoro
 
advanced computer architesture-conditions of parallelism
advanced computer architesture-conditions of parallelismadvanced computer architesture-conditions of parallelism
advanced computer architesture-conditions of parallelism
Pankaj Kumar Jain
 
Functional Effects - Part 1
Functional Effects - Part 1Functional Effects - Part 1
Functional Effects - Part 1
Philip Schwarz
 
Secret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software SystemsSecret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software Systems
Bart Jonkers
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
SHARDA SHARAN
 
Software design
Software designSoftware design
Software design
Himanshu Awasthi
 
The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean Architecture
Dmytro Turskyi
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-studentrandhirlpu
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 

Similar to Bt0066 database management system2 (20)

FRACTAL ANALYSIS OF GOOD PROGRAMMING STYLE
FRACTAL ANALYSIS OF GOOD PROGRAMMING STYLEFRACTAL ANALYSIS OF GOOD PROGRAMMING STYLE
FRACTAL ANALYSIS OF GOOD PROGRAMMING STYLE
 
Fractal analysis of good programming style
Fractal analysis of good programming styleFractal analysis of good programming style
Fractal analysis of good programming style
 
Slides chapter 11
Slides chapter 11Slides chapter 11
Slides chapter 11
 
Thoughtful Software Design
Thoughtful Software DesignThoughtful Software Design
Thoughtful Software Design
 
Software Engineering - SOFTWARE DESIGN Process
Software Engineering - SOFTWARE DESIGN ProcessSoftware Engineering - SOFTWARE DESIGN Process
Software Engineering - SOFTWARE DESIGN Process
 
Software architacture recovery
Software architacture recoverySoftware architacture recovery
Software architacture recovery
 
C++ programing lanuage
C++ programing lanuageC++ programing lanuage
C++ programing lanuage
 
Book management system
Book management systemBook management system
Book management system
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Matopt
MatoptMatopt
Matopt
 
Unit-III(Design).pptx
Unit-III(Design).pptxUnit-III(Design).pptx
Unit-III(Design).pptx
 
advanced computer architesture-conditions of parallelism
advanced computer architesture-conditions of parallelismadvanced computer architesture-conditions of parallelism
advanced computer architesture-conditions of parallelism
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Functional Effects - Part 1
Functional Effects - Part 1Functional Effects - Part 1
Functional Effects - Part 1
 
Secret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software SystemsSecret Twists to Efficiently Develop Reactive Software Systems
Secret Twists to Efficiently Develop Reactive Software Systems
 
Password protected diary
Password protected diaryPassword protected diary
Password protected diary
 
Software design
Software designSoftware design
Software design
 
The Clean Architecture
The Clean ArchitectureThe Clean Architecture
The Clean Architecture
 
12 couplingand cohesion-student
12 couplingand cohesion-student12 couplingand cohesion-student
12 couplingand cohesion-student
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 

More from Techglyphs

Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Bt0068 computer organization and architecture
Bt0068 computer organization and architecture
Techglyphs
 
Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2
Techglyphs
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1
Techglyphs
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2
Techglyphs
 
Bt0072 computer networks 1
Bt0072 computer networks  1Bt0072 computer networks  1
Bt0072 computer networks 1
Techglyphs
 
Bt0072 computer networks 2
Bt0072 computer networks  2Bt0072 computer networks  2
Bt0072 computer networks 2
Techglyphs
 
Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1
Techglyphs
 
Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2
Techglyphs
 
Bt0077 multimedia systems
Bt0077 multimedia systemsBt0077 multimedia systems
Bt0077 multimedia systems
Techglyphs
 
Bt0078 website design
Bt0078 website design Bt0078 website design
Bt0078 website design
Techglyphs
 
Bt0077 multimedia systems2
Bt0077 multimedia systems2Bt0077 multimedia systems2
Bt0077 multimedia systems2
Techglyphs
 
Bt0078 website design 2
Bt0078 website design 2Bt0078 website design 2
Bt0078 website design 2
Techglyphs
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
Techglyphs
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
Techglyphs
 
Bt0081 software engineering
Bt0081 software engineeringBt0081 software engineering
Bt0081 software engineering
Techglyphs
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2
Techglyphs
 
Bt0081 software engineering2
Bt0081 software engineering2Bt0081 software engineering2
Bt0081 software engineering2
Techglyphs
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
Techglyphs
 

More from Techglyphs (18)

Bt0068 computer organization and architecture
Bt0068 computer organization and architecture Bt0068 computer organization and architecture
Bt0068 computer organization and architecture
 
Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2Bt0068 computer organization and architecture 2
Bt0068 computer organization and architecture 2
 
Bt0070 operating systems 1
Bt0070 operating systems  1Bt0070 operating systems  1
Bt0070 operating systems 1
 
Bt0070 operating systems 2
Bt0070 operating systems  2Bt0070 operating systems  2
Bt0070 operating systems 2
 
Bt0072 computer networks 1
Bt0072 computer networks  1Bt0072 computer networks  1
Bt0072 computer networks 1
 
Bt0072 computer networks 2
Bt0072 computer networks  2Bt0072 computer networks  2
Bt0072 computer networks 2
 
Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1Bt0075 rdbms with mysql 1
Bt0075 rdbms with mysql 1
 
Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2Bt0075 rdbms with mysql 2
Bt0075 rdbms with mysql 2
 
Bt0077 multimedia systems
Bt0077 multimedia systemsBt0077 multimedia systems
Bt0077 multimedia systems
 
Bt0078 website design
Bt0078 website design Bt0078 website design
Bt0078 website design
 
Bt0077 multimedia systems2
Bt0077 multimedia systems2Bt0077 multimedia systems2
Bt0077 multimedia systems2
 
Bt0078 website design 2
Bt0078 website design 2Bt0078 website design 2
Bt0078 website design 2
 
Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1Bt0080 fundamentals of algorithms1
Bt0080 fundamentals of algorithms1
 
Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2Bt0080 fundamentals of algorithms2
Bt0080 fundamentals of algorithms2
 
Bt0081 software engineering
Bt0081 software engineeringBt0081 software engineering
Bt0081 software engineering
 
Bt0082 visual basic2
Bt0082 visual basic2Bt0082 visual basic2
Bt0082 visual basic2
 
Bt0081 software engineering2
Bt0081 software engineering2Bt0081 software engineering2
Bt0081 software engineering2
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Reflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdfReflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdf
amberjdewit93
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
MERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDFMERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDF
scholarhattraining
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Reflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdfReflective and Evaluative Practice...pdf
Reflective and Evaluative Practice...pdf
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
MERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDFMERN Stack Developer Roadmap By ScholarHat PDF
MERN Stack Developer Roadmap By ScholarHat PDF
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 

Bt0066 database management system2

  • 1. 1 Database Management System BT0066 Part-2 By Milan K Antony Copy© Milan K Antony | milankantony@gmail.com |
  • 2. 2 1. Explain the statement that relational algebra operators can be composed. Why the ability to compose operators is important? The Relational Algebra consists of a set of basic operators that take relations as their operands and return the result as a relation. This means that operators can be composed - the output of one operation may be used as input to another operation.  Query languages: Allow manipulation and retrieval of data from a database.  Relational model supports simple, powerful QLs: o Strong formal foundation based on logic. o Allows for much optimization.  Query Languages != programming languages! o QLs not expected to be “Turing complete”. o QLs not intended to be used for complex calculations. o QLs support easy, efficient access to large data sets. Formal Relational Query Languages  Two mathematical Query Languages form the basis for “real” languages (e.g. SQL), and for implementation: o Relational Algebra: More operational(procedural), very useful for representing execution plans. Copy© Milan K Antony | milankantony@gmail.com |
  • 3. 3 o Relational Calculus: Lets users describe what they want, rather than how to compute it. (Non- operational, declarative.) Preliminaries  A query is applied to relation instances, and the result of a query is also a relation instance. o Schemas of input relations for a query are fixed (but query will run regardless of instance!) o The schema for the result of a given query is also fixed! Determined by definition of query language constructs.  Positional vs. named-field notation: o Positional notation easier for formal definitions, named-field notation more readable. o Both used in SQL Relational Algebra  Basic operations: o Selection ( ) Selects a subset of rows from relation. o Projection ( ) Deletes unwanted columns from relation. o Cross-product ( ) Allows us to combine two relations. Copy© Milan K Antony | milankantony@gmail.com |
  • 4. 4 o Set-difference ( ) Tuples in reln. 1, but not in reln. 2. o Union ( ) Tuples in reln. 1 and in reln. 2.  Additional operations: o Intersection, join, division, renaming: Not essential, but (very!) useful.  Since each operation returns a relation, operations can be composed! (Algebra is “closed”.) Projection  Deletes attributes that are not in projection list.  Schema of result contains exactly the fields in the projection list, with the same names that they had in the (only) input relation.  Projection operator has to eliminate duplicates! (Why??, what are the consequences?) o Note: real systems typically don’t do duplicate elimination unless the user explicitly asks for it. (Why not?) Selection  Selects rows that satisfy selection condition.  Schema of result identical to schema of (only) input relation.  Result relation can be the input for another relational algebra operation! (Operator composition.) Copy© Milan K Antony | milankantony@gmail.com |
  • 5. 5 Union, Intersection, Set-Difference  All of these operations take two input relations, which must be union-compatible: o Same number of fields. o `Corresponding’ fields have the same type.  What is the schema of result? Cross-Product  Each row of S1 is paired with each row of R1.  Result schema has one field per field of S1 and R1, with field names `inherited’ if possible. o Conflict: Both S1 and R1 have a field called sid. Division  Not supported as a primitive operator, but useful for expressing queries like: Find sailors who have reserved all boats.  Precondition: in A/B, the attributes in B must be included in the schema for A. Also, the result has attributes A-B. o SALES(supId, prodId); o PRODUCTS(prodId); o Relations SALES and PRODUCTS must be built using projections. Copy© Milan K Antony | milankantony@gmail.com |
  • 6. 6 o SALES/PRODUCTS: the ids of the suppliers supplying ALL products. Expressing A/B Using Basic Operators  Division is not essential op; just a useful shorthand. o (Also true of joins, but joins are so common that systems implement joins specially. Division is NOT implemented in SQL).  Idea: For SALES/PRODUCTS, compute all products such that there exists at least one supplier not supplying it. o x value is disqualified if by attaching y value from B, we obtain an xy tuple that is not in A. Since each operation returns a relation, operations can be composed! 2. What is an unsafe query? Give an example and explain why it is important to disallow such queries. Here is an informal example of an unsafe query. Consider the database of all people living in Sweden, and suppose that the Last_Name field may contain any string of up to 64 characters. Then the following is an unsafe query which is easily represented in the domain calculus. “Give me the set of strings of length at most 64 which do not represent the last name of someone living in Sweden.” Copy© Milan K Antony | milankantony@gmail.com |
  • 7. 7 The formalization of safety is rather technical,and will not be presented here. For a query designed by hand, it is usually obvious whether or not it is safe. Of course, a query processor must be able to detect safety, or lack thereof. 3. Give a set of FDs for the relation schema R(A,B,C,D) with primary key AB under which R is in 1NF but not in 2NF. . Consider the set of FD: AB CD→ and B C→ . AB is obviously a key for this relation since AB CD→ implies AB ABCD→ . It is a primary key since there are no smaller subsets of keys that hold over R(A,B,C,D). The FD: B C→ violates 2NF since: C B is false; that is, it is not a trivial FD B is not a superkey C is not part of some key for R B is a proper subset of the key AB (transitive dependency) 4. When it is useful to have replication or fragmentation of data? Explain. Replication is the process of sharing information so as to ensure consistency between redundant resources, such as software or hardware components, to improve reliability, Copy© Milan K Antony | milankantony@gmail.com |
  • 8. 8 fault-tolerance, or accessibility. It could be data replication if the same data is stored on multiple storage devices, or computation replication if the same computing task is executed many times. A computational task is typically replicated in space, i.e. executed on separate devices, or it could be replicated in time, if it is executed repeatedly on a single device. In computing, failover is the capability to switch over automatically to a redundant or standby computer server, system, or network upon the failure or abnormal termination of the previously active application, [1] server, system, or network. Failover happens without human intervention and generally without warning, unlike switchover Fault-tolerance or graceful degradation is the property that enables a system (often computer-based) to continue operating properly in the event of the failure of (or one or more faults within) some of its components. If its operating quality decreases at all, the decrease is proportional to the severity of the failure, as compared to a naïvely-designed system in which even a small failure can cause total breakdown. Fault-tolerance is particularly sought-after in high-availability or life-critical systems. 5. What is late binding of methods? Give an example of inheritance that illustrates the need for dynamic binding. Copy© Milan K Antony | milankantony@gmail.com |
  • 9. 9 Connecting a method call(i.e. Function Call) to a method body(i.e. Function) is called binding. When binding is performed before the program is run (by the compiler and linker, if there is one), it’s called early binding. You might not have heard the term before because it has never been an option with procedural languages. C compilers have only one kind of method call, and that’s early binding. The other solution is called late binding, which means that the binding occurs at run time, based on the type of object. Late binding is also called dynamic binding or run-time binding. When a language implements late binding, there must be some mechanism to determine the type of the object at run time and to call the appropriate method. That is, the compiler still doesn’t know the object type, but the method-call mechanism finds out and calls the correct method body. The late-binding mechanism varies from language to language, but you can imagine that some sort of type information must be installed in the objects. All method binding in Java uses late binding unless the method is static or final (private methods are implicitly final). This means that ordinarily you don’t need to make any decisions about whether late binding will occur—it happens automatically. Reference Links - Here is a very nice article on Difference Between Early and late Binding The polymorphic assignment p := r is valid because of the above rule. If condition c is false, p will be attached to an object of type POLYGON for the computation of p . perimeter , which will thus use the polygon algorithm. In the opposite case, Copy© Milan K Antony | milankantony@gmail.com |
  • 10. 10 however, p will be attached to a rectangle; then the computation will use the version redefined for RECTANGLE . This is known as dynamic binding . 6. Describe the circumstances in which you would choose to use Embedded SQL rather than Standalone SQL or only a general-purpose programming language. Embedded SQL refers to the use of standard SQL statements embedded within a procedural programming language SQL functions are primarily a mechanism for extending the power of SQL to handle attributes of complex data types (like images), or to perform complex and non-standard operations. Embedded SQL is useful when imperative actions like displaying results and interacting with the user are needed. These cannot be done conveniently in an SQL only environment. Embedded SQL can be used instead of SQL functions by retrieving data and then performing the function's operations on the SQL result. However a drawback is that a lot of query-evaluation functionality may end up getting repeated in the host language code When sorting data to be displayed in a subfile, the Open Query File (OPNQRYF) command is often used. This comes in handy when you are providing the user with the ability to change how he displays the data in the subfile. I agree that OPNQRYF is a powerful way to select and sort data before loading your subfile, but its real strength is sorting and selecting data in a Copy© Milan K Antony | milankantony@gmail.com |
  • 11. 11 batch environment. I have used it with subfile programs, and, although it’s a bit of a pain, it does work, especially if you use optimizing techniques. Another method for providing multiple sorting criteria in your subfiles is to use logical files. One problem with logical files is that you are required to maintain an access path for every sort criterion required by your users. Another problem is the complexity of your subfile load routine when using multiple logical files to provide the users with different looks at the data. That gets ugly. What if you had a tool that allowed you the same select and sort capabilities as logical files and OPNQRYF but did so in a flexible and efficient manner, while allowing you to produce a well-structured, easily maintainable program? Wouldn’t that be awesome? Well, with embedded SQL, that’s just what you get. SQL embedded into your RPG program allows you to sort and select the data as you want, but it also provides the user with some added power. What if multiple users from different departments are going to use your subfile program but, as is usually the case with users, they each want to see the data in a different order? You can certainly accomplish this by including enough logical files in your program to cover every possible sorting criterion, but this may require many logical files, especially if the user wants secondary and tertiary sorts. This may also create unnecessary access path administration for the system if all the logical files are created for this one application. It also makes Copy© Milan K Antony | milankantony@gmail.com |
  • 12. 12 for an ugly subfile build routine in your RPG program. Another method to allow dynamically sorting subfiles is to use OPNQRYF. You could create one open query for each possible sort or dynamically create the open query based on what the user wants to do. Either way, you would be passing parameters back and forth between the RPG and CL programs to either build the OPNQRYF command or select which specific OPNQRYF command to use. I’ve messed around with the latter method, and the CL can get cumbersome if you try to give the users complete flexibility by allowing them to sort by more than one field at a time. I love users, but that’s a lot of work just to provide them with a different view of the same data. By embedding SQL, you can dynamically build your SELECT statement based on how the user wants to sort the data, all in one neat little subroutine. You can also use techniques that allow you to provide this capability very efficiently and, with a couple of minor changes, for data on other AS/400s. I’ll tell you how it’s done. 7. What is relational completeness? If a query language is relationally complete, can you write any desired query in that language? Relational algebra is essentially equivalent in expressive power to relational calculus (and thus first-order logic); this result is known as Codd's theorem. Some care, however, has Copy© Milan K Antony | milankantony@gmail.com |
  • 13. 13 to be taken to avoid a mismatch that may arise between the two languages since negation, applied to a formula of the calculus, constructs a formula that may be true on an infinite set of possible tuples, while the difference operator of relational algebra always returns a finite result. To overcome these difficulties, Codd restricted the operands of relational algebra to finite relations only and also proposed restricted support for negation (NOT) and disjunction (OR). Analogous restrictions are found in many other logic-based computer languages. Codd defined the term relational completeness to refer to a language that is complete with respect to first- order predicate calculus apart from the restrictions he proposed. In practice the restrictions have no adverse effect on the applicability of his relational algebra for database purposes. 8. What types of anomalies are found in relational database There are several standard types of anomaly in a database. It doesn't need to be a relational database; the same anomalies are present in any database. A properly designed relational database specifically aims to eliminate these anomalies. If the database is not properly normalized, it is susceptible to insertion, update and deletion anomalies. The update anomaly occurs when the same data is stored in several records and a change has to be made. If only some of the Copy© Milan K Antony | milankantony@gmail.com |
  • 14. 14 records are updated, an update erors occurs - eg we could end up recording two teachers as giving the same class. If you are dealing with hundreds of records, this is quite likely to occur. If you wish to record some info in advance of needing it, such as the name of a teacher for a class that at present has no students enrolled, and the teacher name is only recorded next to each student rather than in a separate table, then with no student enrolled, you can't add the teacher info. This is an insertion anomaly. A deletion anomaly occurs not when you delete something by accident, but when deleting a record also removes the only instance of some other data. So if we recorded a class's details along with a student's, have only one student enrolled and then that student withdrew, we would be deleting the class info as well. Normalisation of a relational database is designed to overcome these problems Copy© Milan K Antony | milankantony@gmail.com |