Download - Mc0067 Database Set1
-
7/31/2019 Mc0067 Database Set1
1/18
MC0067Database Management System
Set-1
Question 1. Write about:1. Linear Search
2. Collision Chain
ANS.
Linear SearchLinear search, also known as sequential search, means starting at the beginning of the data
and checking each item in turn until either the desired item is found or the end of the data is
reached. Linear search is a search algorithm, also known as sequential search that is
suitable for searching a list of data for a particular value. It operates by checking every
element of a list one at a time in sequence until a match is found. The Linear Search, orsequential search, is simply examining each element in a list one by one until the desired
element is found. The Linear Search is not very efficient. If the item of data to be found is at
the end of the list, then all previous items must be read and checked before the item that
matches the search criteria is found. This is a very straightforward loop comparing every
element in the array with the key. As soon as an equal value is found, it returns. If the loop
finishes without finding a match, the search failed and -1 is returned. For small arrays,
linear search is a good solution because it's so straightforward. In an array of a million
elements linear search on average will take500, 000 comparisons to find the key. For a much
faster search, take a look at binary search.
Algorithm
For each item in the databaseif the item matches the wanted info
exit with this item
Continue loop
wanted item is not in database
Collision Chain:In computer science, ahash table orhash map is a data structure that uses a hash function to map
identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their
telephone number). Thus, a hash table implements an associate array. The hash function is used to
transform the key into the index (the hash) of an array element (the slot or bucket) where thecorresponding value is to be sought.
Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely
achievable in practice (unless the hash keys are fixed; i.e. new entries are never added to the table
after it is created). Instead, most hash table designs assume that hast collisionsdifferent keys that
map to the same hash valuewill occur and must be accommodated in some way.
2. Write about:
-
7/31/2019 Mc0067 Database Set1
2/18
ANS.
2.1 Integrity Rules:These are the rules which a relational database follows in order to stay accurate and accessible.
These rules govern which operations can be performed on the data and on the structure of the
database. There are three integrity rules defined for a relational databse,which are:-
Distinct Rows in a Table - this rule says that all the rows of a table should be distinct to
avoid in ambiguity while accessing the rows of that table. Most of the modern database
management systems can be configured to avoid duplicate rows.
Entity Integrity (A Primary Key or part of it cannot be null) - this rule says that 'null' is
special value in a relational database and it doesn't mean blank or zero. It means the
unavailability of data and hence a 'null' primary key would not be a complete identifier. This
integrity rule is also termed as entity integirty.
Referential Integrity - this rule says that if a foreign key is defined on a table then a value
matching that foreign key value must exist as th e primary key of a row in some other table.
The following are the integrity rules to be satisfied by any relation.
No Component of the Primary Key can be null. The Database must not contain any unmatched Foreign Key values. This is called the
referential integrity rule.
Unlike the case of Primary Keys, there is no integrity rule saying that no component of the
foreign key can be null. This can be logically explained with the help of the following
example:
Consider the relations Employee and Account as given below.
2.2 Relational Operators:In the relational model, the database objects seen so far have specific names:
Name MeaningRelation Table
Tuple Record(Row)
Attribute Field(Column)
Cardinality Number of Records(Rows)
Degree(or Arity) Number of Fields(Columns)
View Query/Answer table
On these objects, a set of operators (relational operators) is provided to manipulate them:
1. Restrict
2. Project
3. Union
4. Difference
5. Product
6. Intersection
7. Join
8. Divide
Restrict:
Restrict simply extract records from a table.
it is also known as Select, but not the same SELECT as defined in SQL.
Project:Project selects zero or more fields from a table and generates a new table
-
7/31/2019 Mc0067 Database Set1
3/18
that contains all of the records and only the selected fields (with no duplications).
Union:
Union creates a new table by adding the records of one table to another
tables, must be compatible: have the same number of fields and each of the field pairs has to
have values in the same domain.
Difference:
The difference of two tables is a third table which contains the records which appear in the
first BUT NOT in the second.
Product:
The product of two tables is a third which contains all of the records in the first one added to
each of the records in the second.
Intersection:
The intersection of two tables is a third tables which contains the records which are commonto both.
Join:
The join of two tables is a third which contains all of the records in the first and the second
which are related.
Divide:
Dividing a table by another table gives all the records in the first which have values in their
fields matchingALL the records in the second.
The eight relational algebra operators are
1. SELECTTo retrieve specific tuples/rows from a relation.
2. PROJECTTo retrieve specific attributes/columns from a relation.
http://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00634.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00427.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00634.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00427.gif -
7/31/2019 Mc0067 Database Set1
4/18
3. PRODUCTTo obtain all possible combination of tuples from two relations.
4. UNIONTo retrieve tuples appearing in either or both the relations participating in the
UNION.
Eg: Consider the relation Ord_Jul as
ollows
(Table: Ord_Jul)
Note: The union operation shown above logically implies retrieval of records of Orders
placed in July or in August
5. INTERSECTTo retrieve tuples appearing in both the relations participating in the
INTERSECT.
Eg:
To retrieve Cust# of Customers whove placed orders in
July and in AugustCust#003
6. DIFFERENCETo retrieve tuples appearing in the first relation participating in the
DIFFERENCE but not the second.
http://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01220.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01027.jpghttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00823.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01220.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01027.jpghttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00823.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01220.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01027.jpghttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image00823.gif -
7/31/2019 Mc0067 Database Set1
5/18
Eg: To retrieve Cust# of Customers whove placed orders in July but
not in August
Cust#001
7. JOINTo retrieve combinations of tuples in two relations based on a common field in
both the relations.
Eg:
ORD_AUG join CUSTOMERS (here, the common column is
Cust#)
3. Write about:
Three Level Database ArchitectureData and Related Structures
Data are actually stored as bits, or numbers and strings, but it is difficult to work with data at
this level.
http://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01613.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01414.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01613.gifhttp://train-srv.manipalu.com/wpress/wp-content/uploads/2009/06/clip-image01414.gif -
7/31/2019 Mc0067 Database Set1
6/18
It is necessary to view data at different levels of abstraction.
Schema:
-
7/31/2019 Mc0067 Database Set1
7/18
Description of data at some level. Each level has its own schema.
We will be concerned with three forms of schemas:
physical,
conceptual, and external
Physical Data Level
The physical schema describes details of how data is stored: files, indices, etc. on the
random access disk system. It also typically describes the record layout of files and type offiles (hash, b-tree, flat).
Early applications worked at this level - explicitly dealt with details. E.g., minimizing
physical distances between related data and organizing the data structures within the file
(blocked records, linked lists of blocks, etc.)
Problem:
Routines are hardcoded to deal with physical representation.
Changes to data structures are difficult to make.
Application code becomes complex since it must deal with details. Rapid implementation of new features very difficult.
Conceptual Data Level
Also referred to as the Logical level
Hides details of the physical level.
In the relational model, the conceptual schema presents data as a set of tables.
The DBMS maps data access between the conceptual to physical schemas automatically.
Physical schema can be changed without changing application:
DBMS must change mapping from conceptual to physical.
Referred to as physical data independence.
-
7/31/2019 Mc0067 Database Set1
8/18
External Data Level
In the relational model, the external schema also presents data as a set of relations. An
external schema specifies a view of the data in terms of the conceptual level. It is tailored to
the needs of a particular category of users. Portions of stored data should not be seen by some
users and begins to implement a level of security and simplifies the view for these users
Examples:
Students should not see faculty salaries. Faculty should not see billing or payment data.
Information that can be derived from stored data might be viewed as if it were stored.
GPA not stored, calculated when needed.
Applications are written in terms of an external schema. The external view is computed when
accessed. It is not stored. Different external schemas can be provided to different categories
of users. Translation from external level to conceptual level is done automatically by DBMS
at run time. The conceptual schema can be changed without changing application:
Mapping from external to conceptual must be changed.
Referred to as conceptual data independence.
DBMS SERVICEJump to:navigation,search
DBMS_SERVICE is aPL/SQLpackage that can be used to define and manage
database services for a single instance. To define aRACservice (multi-instance) see
svrctl. Please note that services can also be defined from theDBCAGUI.
Functions
[edit] dbms_service.CREATE_SERVICE
SQL> exec dbms_service.CREATE_SERVICE(SERVICE_NAME=>'orderentry',NETWORK_NAME=>'db11g')
http://www.orafaq.com/wiki/DBMS_SERVICE#column-onehttp://www.orafaq.com/wiki/DBMS_SERVICE#column-onehttp://www.orafaq.com/wiki/DBMS_SERVICE#column-onehttp://www.orafaq.com/wiki/DBMS_SERVICE#searchInputhttp://www.orafaq.com/wiki/DBMS_SERVICE#searchInputhttp://www.orafaq.com/wiki/DBMS_SERVICE#searchInputhttp://www.orafaq.com/wiki/PL/SQLhttp://www.orafaq.com/wiki/PL/SQLhttp://www.orafaq.com/wiki/PL/SQLhttp://www.orafaq.com/wiki/RAChttp://www.orafaq.com/wiki/RAChttp://www.orafaq.com/wiki/RAChttp://www.orafaq.com/wiki/Svrctlhttp://www.orafaq.com/wiki/Svrctlhttp://www.orafaq.com/wiki/DBCAhttp://www.orafaq.com/wiki/DBCAhttp://www.orafaq.com/wiki/DBCAhttp://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=3http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=3http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=3http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=3http://www.orafaq.com/wiki/DBCAhttp://www.orafaq.com/wiki/Svrctlhttp://www.orafaq.com/wiki/RAChttp://www.orafaq.com/wiki/PL/SQLhttp://www.orafaq.com/wiki/DBMS_SERVICE#searchInputhttp://www.orafaq.com/wiki/DBMS_SERVICE#column-one -
7/31/2019 Mc0067 Database Set1
9/18
[edit] dbms_service.MODIFY_SERVICE
Modify an existing service. Example:
SQL> exec DBMS_SERVICE.MODIFY_SERVICE( -
> service_name => 'o11gr1', -> goal => DBMS_SERVICE.GOAL_THROUGHPUT, -> failover_method => DBMS_SERVICE.FAILOVER_METHOD_BASIC, -> failover_type => DBMS_SERVICE.FAILOVER_TYPE_SELECT, -> failover_retries => 10, -> failover_delay => 1, -> clb_goal => DBMS_SERVICE.CLB_GOAL_LONG);PL/SQL procedure successfully completed.
[edit] dbms_service.START_SERVICE
SQL> exec dbms_service.START_SERVICE('orderentry')SQL> show parameter service
[edit] dbms_service.STOP_SERVICESQL> exec dbms_service.STOP_SERVICE('orderentry')
[edit] dbms_service.DELETE_SERVICE
SQL> exec dbms_service.DELETE_SERVICE('orderentry')
[edit] Monitor
Use the following dictionary views to monitor services:
dba_services - All defined services
gv$active_services - All active (started) services
To see what service a session is connected to:
SELECT username, program, machine, service_name FROM gv$session;
Q. 4 explain the SQL syntax for :
1. Table Creation with constraint imposing using an example
Ans.
2. Functions Count, Sum, Average with appropriate examples
Ans.
Five Important aggregate functions are COUNT, SUM, AVG, MIN, and MAX. They are
called aggregate functions because they summarize the results of a query, rather than listingall of the rows.
http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=4http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=4http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=4http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=5http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=5http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=5http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=6http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=6http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=6http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=7http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=7http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=7http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=8http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=8http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=8http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=7http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=6http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=5http://www.orafaq.com/wiki/index.php?title=DBMS_SERVICE&action=edit§ion=4 -
7/31/2019 Mc0067 Database Set1
10/18
1. COUNT (*) gives the number of rows satisfying the conditions
2. SUM () gives the total of all the rows, satisfying any conditions, of the given column,
where the given column is numeric.
3. AVG () gives the average of the given column.
4. MIN () gives the smallest figure in the given column.
5. MAX () gives the largest figure in the given column.
1. COUNT (*)
The keyword COUNT can be used together to count the number of distinct results.
Syntax :-
SELECT COUNT (column) FROM table
EXAMPLE:-
With this "Persons" Table:
NAME AGE
Varsha 34
Ranjan 45
Devi
This example finds the number of persons with a value in the "Age" filled in the "Persons"
table:
SELECT COUNT (Age) FROM Persons
RESULT:-
2
The COUNT (column) function is handy for finding columns without a value. Note that the
result is one less than the number of rows in the original table because one of the persons
does not have an age value stored.
-
7/31/2019 Mc0067 Database Set1
11/18
2. SUM ()
The SUM function returns the total sum of a column in a given selection. NULL values
are not included in the calculation.
Syntax :-
SELECT SUM (column) FROM table
EXAMPLE I :-
With this "Persons" Table:
NAME AGE
Varsha 34
Ranjan 45
Devi 19
This example returns the sum of all ages in the "person" table:
SELECT SUM (Age) FROM Persons
RESULTS:-
98
EXAMPLE II :-
This example returns the sum of ages for persons that are more than 20 years old:
SELECT SUM(Age) FROM Persons WHERE Age>20
RESULT:-
79
3. AVG ()
The AVG function returns the average value of a column in a selection. NULL values
are not included in the calculation.
-
7/31/2019 Mc0067 Database Set1
12/18
Syntax :-
SELECT AVG (column) FROM table
EXAMPLE I :-
This example returns the average age of the persons in the "Persons" table:
SELECT AVG(Age) FROM Persons
Q. 5. Compare and Contrast the Centralized and Client / Server Architecture for DBMS.
AnsIncentralized database systems, the database system, application programs, and user-
interface all are executed on a single system and dummy terminals are connected to it. The
processing power of single system is utilized and dummy terminals are used only to display
the information. As the personal computers became faster, more powerful, and cheaper, the
database system started to exploit the available processing power of the system at the users
side, which led to the development of client/server architecture.
Disadvantages of centralized database system::
o When the central site computer or database system goes down, then everyone is
blocked from using the system until the system comes back.
o Communication costs from the terminals to the central site can be expensive.
In client/server architecture, the processing power of the computer system at the users end
is utilized by processing the user-interface on that system.
A client is a computer system that sends request to the server connected to the network, and aserver is a computer system that receives the request, processes it, and returns the requested
information back to the client. Client and server are usually present at different sites. The end
users (remote database users) work on client computer system and database system runs on
the server. Servers can be of several types, for example, file servers, printer servers, web
servers, database servers, etc. The client machines have user interfaces that help users to
utilize the servers. It also provides users the local processing power to run local applications
on the client side.
There are two approaches to implement client/server architecture. In the first approach, the
user interface and application programs are placed on the client side and the database system
on the server side. This architecture is called two-tier architecture. The application programsthat reside at the client side invoke the DBMS at the server side. The application program
http://my.safaribooksonline.com/9788131731925/gloss01#gloss01_037http://my.safaribooksonline.com/9788131731925/gloss01#gloss01_037http://my.safaribooksonline.com/9788131731925/gloss01#gloss01_037http://my.safaribooksonline.com/9788131731925/gloss01#gloss01_037 -
7/31/2019 Mc0067 Database Set1
13/18
interface standards like Open Database Connectivity (ODBC) and Java Database
Connectivity (JDBC) are used for interaction between client and server.Figure 1.9shows
two-tier architecture.
Fig. 1.9. Two-tier architecture
The second approach, that is, three-tier architecture is primarily used for web-based
applications. It adds intermediate layer known as application server (or web server) between
the client and the database server. The client communicates with the application server,
which in turn communicates with the database server. The application server stores the
business rules (procedures and constraints) used for accessing data from database server. It
checks the clients credentials before forwarding a request to database server. Hence, it
improves database security.
When a client requests for information, the application server accepts the request, processes
it, and sends corresponding database commands to database server. The database server sends
the result back to application server which is converted into GUI format and presented to theclient.Figure 1.10shows the three-tier architecture.
-
7/31/2019 Mc0067 Database Set1
14/18
Fig. 1.10. Three-tier architecture
ADVANTAGES:
1. CLIENT / SERVER system has less expensive platforms to supportapplications that had previously been running only on large and
expensive mini or main frame computers.
2. Client/ server environment facilities in more productive work by theusers and making better use of existing data.
3. It is more flexible as compared to the centralized systems.4. Responsive time 7 throughput is high.5. A single dg(on server) can be shared across several distinct client
(application) system.
DISADVANTAGE:
1. Programming cost is high in client / server environment, particularly ininitial phases.
2. Theres a lack of management tools for diagnosis, performancemonitoring and tuning and security control, for the DBMS client and
OS and networking environments.
Q. 6 Taking an example Enterprise System, List out the Entity types, Entity Sets, Attributesand Keys
Ans
Q 7
-
7/31/2019 Mc0067 Database Set1
15/18
Ans Relational Notation
Relational notation is a process of transforming an E/R diagram into a more friendly and usable
type of daigram that is easily readalbe. This can be done by taking the names of each table and
its attributes and ordering them in a specific order. You always start with the primary key(s), whichare always underlined. Next all other attributes are added. The only rule for attributes is if it
happens to be a foreign key it needs to be underlined with a dashed line:
Diagram 1
Looking at this E/R diagram to translate this into relational notation it would look like:
AUTHOR (Author_id, Author_lname, Author_fname, Address, City, State, Zip)
Note: the primary key in the table is underlined to show that it is the unique attribute.
-
7/31/2019 Mc0067 Database Set1
16/18
2
Diagram2Relational Notation:
TITLE (Title_id, Title, Pub_id)
Note: in this example the attribute Pub_id is what is known as a foreign key because it links
to the following table (PUBLISHER) through that attribute. Normally this is represented by
being placed at the end of the attribute list in the relational notation and is shown with a
dashed underline.
Diagram 3
Relational Notation:PUBLISHER (Pub_id, Pub_name, City)
-
7/31/2019 Mc0067 Database Set1
17/18
Diagram 4
Relational Notation:
AUTHOR_TITLE (Author_id, Title_id)
By translating E/R diagrams into relational notation it also makes it easy for an individual to
normalize and denormalize any given table in the schema; and if needed it is not very
complicated to restore relational notation back to E/R diagram format.
-
7/31/2019 Mc0067 Database Set1
18/18
Relational notation is a shorthand way to represent E/R diagrams. It is a half-way step
between an abstract tool and an implementation specific tool (SQL create table commands).
In terms of cardinalities, if you have a 1:1 (one-to-one) relationship between two tables youcan place the foreign key on either side when translating to relational notation, but is
dependant upon the context of the scope of what the prolect is requiring.. If you are presented
with a 1:N (one-to-many) relationship between tables foreign keys always will be on the
many side.
When dealing with suptype/supertype, they are considered a special form of a 1:1 therefore
foreign key placement is immaterial, due to the fact that subtypes are know as inheriting
everything from a supertype unless other wise noted.
Advantages
One of the best advantages of relational notation format is the ease to go from an E/R
diagram to an English format of notation rather easily. What this means is, it very easy to turn
an E/R diagram into something easily readable and useable, and still capture table names,
composite keys, primary keys, foreign keys, and all attributes.. Relational notation is also a
great refference point when creating tables in a SQL type program. Relational notion still
allows a user or designer an easy way to transfer dependencies and re-create composite keysin a graphical interface if so desired. It is also has an accepted format, which once learned,
can be applied to any table structure.
Disadvantages
One disadvantage of the relational notation is lack of visual descriptiveness. Essentially,
tables created by relationships and tables themselves lose a visual format to model them. This
can however be an advantage too though.
Q 8. Consider a University Database System and develop the ER Conceptual Schemadiagram i.e. E-R Diagram for the same
Ans....