Professional Documents
Culture Documents
XII. We can drop a sequence from a database with a DROP SEQUENCE command.
For example, to drop the sequences created earlier-
DROP SEQUENCE CUS_CODE_SEQ; DROP SEQUENCE
INV_NUMBER_SEQ; Dropping a sequence does not delete the values we
assigned to table attributes (CUS_CODE and INV_NUMBER); it deletes only the
sequence object from the database. The values we assigned to the table columns
(CUS_CODE and INV_NUMBER) remain in the database.
V. Both versions of fragment-and-replicate work with any join condition, since every
tuple in r can be tested with every tuple in s.
VI. Usually has a higher cost than partitioning, since one of the relations (for asymmetric
fragment-and-replicate) or both relations (for general fragment-and-replicate) have to be
replicated.
VII. Sometimes asymmetric fragment-and-replicate is preferable even though partitioning
could be used.
E.g., say s is small and r is large, and already partitioned. It may be cheaper to replicate s
across all processors, rather than repartition r and s on the join attributes.
VIII. General Fragment and replicate reduces the sizes of the relations at each processor,
compared to asymmetric fragment and replicate.
5) Explain procedural SQL with an example?
I. This Isolate critical code
- All applications access shared code
- Better maintenance and logic control
II. Persistent stored module (PSM) is a block of code containing:
- Standard SQL statements
- Procedural extensions
- Stored and executed at the DBMS server
III. Procedural SQL (PL/SQL) enables you to:
Store procedural code and SQL statements in database
Merge SQL and traditional programming constructs
IV. Procedural code executed by DBMS when invoked by end user
- Anonymous PL/SQL blocks
- Triggers
- Stored procedures and
- PL/SQL functions
A. Anonymous PL/SQL blocks -
- Anonymous PL/SQL code block is a collection of the commands enclosed inside
BEGIN and END clauses and does not have a specific name.
- Ex - The following anonymous PL/SQL block inserts a row in the VENDOR
table and displays the message “New Vendor Added!”
BEGIN
INSERT INTO VENDOR VALUES (25772,'Clue Store', 'Issac Hayes',
'456','323-2009', 'VA', 'N');
DBMS_OUTPUT.PUT_LINE('New Vendor Added!');
END;
/
B. Triggers -
- A trigger is procedural SQL code that is automatically invoked by the RDBMS
upon the occurrence of a given data manipulation event.
- Syntax -
CREATE OR REPLACE TRIGGER trigger_name [BEFORE / AFTER]
[DELETE / INSERT / UPDATE OF column_name]
ON table_name
[FOR EACH ROW]
[DECLARE]
[variable_name data type[:=initial_value] ]
BEGIN
PL/SQL instructions;
..........
END;
- Example -
C. Stored Procedure -
I. It is Named collection of procedural and SQL statements. Stored
procedures are stored in the database.
II. Syntax -
CREATE OR REPLACE PROCEDURE procedure_name [(argument
[IN/OUT] data-type, )] [IS/AS] [variable_name data type[:=initial_value] ]
BEGIN
PL/SQL or SQL statements;
...
END;
III. Example -
D. PL/SQL Function -
- A stored function is basically a named group of procedural and SQL
statements that returns a value.
- Syntax to create a function:
CREATE FUNCTION function_name (argument IN data-type, )
RETURN data-type [IS]
BEGIN
PL/SQL statements;
...
RETURN (value or expression);
END;
6) Compare between Object Relational and Object Oriented Databases?
• Relational systems
• simple data types, powerful query languages, high protection.
• Persistent-programming-language-based OODBs
• complex data types, integration with programming language, high performance.
• Object-relational systems
• complex data types, powerful query languages, high protection.
• Object-relational mapping systems
• complex data types integrated with programming language, but built as a layer
on top of a relational database system
• Note: Many real systems blur these boundaries
• E.g. A persistent programming language built as a wrapper on a relational
database offers the first two benefits, but may have poor performance.
Nesting:
● Nesting is the opposite of unnesting, creating a collection-valued attribute
● Nesting can be done in a manner similar to aggregation, but using the function
collect() in place of an aggregation operation, to create a multiset
● To nest the flat_books relation on the attribute keyword:
○ select title, author, Publisher (pub_name, pub_branch ) as publisher,
collect (keyword) as keyword_set from flat_books group by title, author,
publisher.
Advantages:
● allows parallel processing on fragments of a relation
● allows a relation to be split so that tuples are located where they are most
frequently accessed.
12) Compare between parallel databases and distributed databases?
Parallel Database: A parallel DBMS is a DBMS that runs across multiple
processors and is designed to execute operations in parallel, whenever possible.
The parallel DBMS links a number of smaller machines to achieve the same
throughput as expected from a single large machine.
Features:
● Completes work very quickly.
● There are parallel working of CPUs
● It improves performance.
● It divides large tasks into various other task
Distributed database: is defined as a logically related collection of data that
is shared which is physically distributed over a computer network on different
sites. The Distributed DBMS is defined as, the software that allows for the
management of the distributed database and makes the distributed data
available for the users.
Features :
● It is a group of logically related shared data
● The data gets split into various fragments
● There may be a replication of fragments
● The sites are linked by a communication network
● The main difference between the parallel and distributed databases is that the
former is tightly coupled and then later loosely coupled.
Parallel Databases Distributed Databases
In parallel databases, processes are tightly In distributed databases, the sites are loosely
coupled and constitutes a single database coupled and share no physical components
system i.e., the parallel database is a i.eThe distributed database is our
centralized database and data reside in a geographically departed, and data is
single location distributed at several locations.
In parallel databases, query processing and In distributed databases, query processing and
transaction is complicated. transaction is more complicated in distributed
database systems
In parallel databases, it’s not applicable. In distributed databases, a local and global
transaction can be transformed into
distributed database systems
Skew is the major issue with the increasing Blocking due to site failure and transparency
degree of parallelism in parallel databases. are the major issues in distributed databases.
In parallel databases, there are 3 types of Distributed databases are generally a kind of
architecture: shared memory, shared disk, and shared-nothing architecture
shared-nothing.
In parallel databases, the data is partitioned In distributed databases, each site preserve a
among various disks so that it can be retrieved local database system for faster processing
faster. due to the slow interconnection between sites