Beruflich Dokumente
Kultur Dokumente
In the example above, each subject that the pupil studies has to be entered as a separate record.
Redundancy: this file has a very simple row and column structure. There are no relationships
between data. The main weakness of this type of file is that data has to be repeated.
Data Integrity: The more often data has been recorded the higher the possibility of the data
having an error or inconsistency. The user of the data must be able to rely on the correctness
and accuracy of the data. The correctness, reliability and accuracy of the data is called data
integrity.
Disadvantages of flat file databases:
The computer has more data to read through, so accessing and searching through them
can be slow.
Data has to be repeated and leads to inputting errors and inconsistencies
File sizes can be large due to repeated data
Unique constraints : Unique constraints ensure that the values in a set of columns are unique and
not null for all rows in the table. The columns specified in a unique constraint must be defined as
NOT NULL. The database manager uses a unique index to enforce the uniqueness of the key
during changes to the columns of the unique constraint.
Primary key constraints: You can use primary key and foreign key constraints to
define relationships between tables.
(Table) Check constraints : A check constraint (also referred to as a table check
constraint) is a database rule that specifies the values allowed in one or more columns of every
row of a table. Specifying check constraints is done through a restricted form of a search
condition.
Foreign key (referential) constraints : Foreign key constraints (also known as referential
constraints or referential integrity constraints) enable you to define required relationships
between and within tables.
Informational constraints : An informational constraint is a constraint attribute that can be used
by the SQL compiler to improve the access to data. Informational constraints are not enforced
by the database manager, and are not used for additional verification of data; rather, they are
used to improve query performance.
Q3. What is the difference between internal & external schema?
Ans. Three-schema Architecture
Reminder: A schema is a description of the structure of the database
Internal level has an internal schema
Conceptual level has a conceptual schema
External level usually has several external schemas
Note that each of these schemas are only descriptions of data; the data really only exists at the
physical level
External Level
The end user is presented with special views that are tailored to their specific needs
Some of these views may be forms to fill out, others for interactive retrieval of information, etc.
Many different views may be available that are completely different that the way the base tables
are arranged
Conceptual or logical level
Description of the structure of the entire DB
Hides the details of physical storage
Concentrates on describing entities, data types, relationships, user operations, and constraints.
In the relational model, this is the base tables
Changes at this level can be made without having any effect on the external level
Internal Level
This is a description of the physical storage structure of the database
Operations performed here are translated into modifications of the contents and structure of the
files
All the views available for a database appear in the view selector (the View by list).
You can customize all aspects of a view, including:
The name of the view
The fields that appear in the view
The column title for each field in the view
The order of the fields in the view
The width of columns in the view, as well as the overall width of the view
The set of records that appear in the view (Filtering)
The order in which records are displayed in the view (Sorting & Grouping)
Column totals for numeric and currency fields (Totaling & Subtotaling)
In addition to seeing the view on screen, users can also print out the view on paper. They can do this
using the built-in print button or by using a defined report, which allows you to customize details of
the print out.
Views are basically a join of two or more underlying database tables. Certain tables are logically
related and make sense and more meaning when viewed linked together. Instead os making
these joins at runtime and increasing overheads, views when existing can provide information
readily such as in Search Helps in data entry screens.
Another example is when there is a table with many fields and it does not make a lot of sense to
see all of them together everytime, it is better we project only certain columns that we want to
see.
There are four types of views:
a) Database View (Generally used a a read only view)
b) Maintenance View (Used as a means to maintain the underlying tables participating in the
view)
c) Projection View (Single table view)
d) Help View (used in 'search helps' got by pressing F4)
Q6. What is the difference between Union & Set Intersection Operation?
Ans: The UNION, EXCEPT, and INTERSECT operators all operate on multiple result sets to return a single
result set:
The UNION operator combines the output of two query expressions into a single result set. Query
expressions are executed independently, and their output is combined into a single result table.
The EXCEPT operator evaluates the output of two query expressions and returns the difference
between the results. The result set contains all rows returned from the first query expression except
those rows that are also returned from the second query expression.
The INTERSECT operator evaluates the output of two query expressions and returns only the rows
common to each.
The following figure illustrates these concepts with Venn diagrams, in which the shaded portion indicates the
result set.
Figure: Result Set
Syntax
performed does not contain the ALL keyword, any duplicates retained from previous evaluations are
eliminated.
Usage notes
The UNION and EXCEPT operators have the same precedence. A query with multiple operators is
evaluated from left to right. The following example:
query_expression1 union query_expression2 except query_expression3
is evaluated as:
(query_expression1 union query_expression2) except query_expression3
The INTERSECT operator has higher precedence than the UNION and EXCEPT operators. Therefore,
in the absence of parentheses, INTERSECT operations are always evaluated first. The example:
query_expression1 union query_expression2 intersect
query_expression3
is evaluated as:
query_expression1 union (query_expression2 intersect
query_expression3)
Parentheses that override the default precedence affect processing order and therefore which duplicate
rows are retained and eliminated.
Joins specified in union_expression take higher precedence than all three operators unless the default
order is changed with parentheses.
An INSERT INTO...SELECT statement can contain UNION, INTERSECT, and EXCEPT operators:
insert into orders.all
select * from orders.new
union
select * from orders.old
When queries use search conditions that contain OR connectives, you can sometimes improve
performance by rewriting those queries with UNION operators.
DMS Assignment B
o
o
Ans:
Data Modeling
A data model is used to describe the structure "logic" and "physics" of a database. Relationships,
data types and constraints are known as the structure or level, dividing into 2 types:
High Level - we call conceptual data model or Entity-Relationship model, its main concept is a
projection of the data that gets closest to the vision that the user has data.
Low - known as physical data model, is what provides a detailed view yet of how the data are
aramazenados computer.
Schemes
When using the term "description" of the database, as we understand the call of "schema of a
database" that is specified for a project database.
Instances
Instances are formed when a data is saved in the database for a certain time they formed these
database instances, being changed every time a change in the database is performed. DBMS
ensures that all instances satisfying the schema of the database, respecting its structure and its
constraints.
In a DBMS architecture has as main objective, separate user applications of physical data that
are divided from the diagrams below:
o
o
o
Level domestic or internal schema - uses a data model that shows the physical storage structure
of the database, the details of the saved data and access paths.
Level conceptual or conceptual scheme - performs a full description of the structure of the
database but did not offer details of the data stored in the database.
Level or external layout view - describes the views of the database to a group of users that shows
which users have access to this database.
We can say that is allowed to perform schema changes or level of a database without changing a
higher level. Recalling that only those levels or regimens are shown in Figure 1. Below is
representing two types of data independence:
o
o
o
o
o
o
o
o
Logical data independence: change only the conceptual level, without any change in the external
or in user applications.
Physical Data Independence: change the internally without having to change the conceptual
level, externally or user applications
Languages for Data Manipulation
The use of language DDL (Data Definition Language - Data Definition Language) is defined by the
conceptual and internal level. When there is a separation of internal and conceptual that is not
absorbed a clear view of the user, the DBMS has to compile the DDL action, with the action,
permission to execute the statements identified by their descriptions of schemes / levels where
you will store them in the DBMS catalog.
Where this detachment has an understanding of the user uses the language SDL (Storage
Definition Language - Storage Definition Language) for specifying schema / internally.
By the end, when the DBMS uses the architecture with three levels, the language used is VDL
(Vision Definition Language) that serves to deinio of views (views) of the database
When the developer has knowledge in language SQL (Strucuture Query Language) simply just
use the basic commands that form the language DDL, DML and DCL, which are described below:
DDL (commands that create objects) - CREATE TABLE, CREATE VIEW, CREATE INDEX, CREATE
PROCEDURE among thers.
DCL (commands that help in the security of the database) - GRANT, REVOKE.
DML (commands responsible for altering the data) - SELECT, DELETE, UPDATE, INSERT.
Classification of DBMS
Users: single user, are used in workstations, minicomputers and large machines.
Location: have 2 states located and distributed. When all data is located are on a single disk, if
the data is distributed across multiple machines.
Environment: it has two types, the homogeneous environment that is formed by a single DBMS
and heterogeneous environment that is composed of different DBMSs. One example is to have a
system running two types of database.
1. First Normal Form: A relation is in 1st Normal form (1NF) if and only if, in every legal value of
that relation, every tuple contains exactly one value for each attribute.
1NF relations have a number of discrepancies and therefore it not the most desirable form of a
relation.
Let us take a relation (modified to illustrate the point in discussion) as
Rel1 {S#, SUPPLYSTATUS, SUPPLYCITY, P#, PARTQTY}
Primary Key{S#, P#}
FD {SUPPLYCITY SUPPLYSTATUS}
2. Second
Normal Form
A relation is in 2NF if and only if it is in 1NF and every nonkey attribute is fully functionally
dependent on the primary key. Here it has been assumed that there is only one candidate key,
which is of course primary key.
A relation in 1NF can always decomposed into an equivalent set of 2NF relations. The reduction
process consists of replacing the 1NF relation by suitable projections.
We have seen the problems arising due to the less-normalization (1NF) of the relation. The
remedy is to break the relation into two simpler relations.
REL2{S#, SUPPLYSTATUS, SUPPLYCITY} and
REL3{S#, P#, PARTQTY}
REL2 and REL3 are in 2NF with their {S#} and {S#, P#} respectively. This is because all
nonkeys of REL1{ SUPPLYSTATUS, SUPPLYCITY}, each is functionally dependent on the
primary key that is S#. By similar argument, REL3 is also in 2NF. Evidently, these two
relations have overcome all the update anomalies stated earlier. Now it is possible to insert the
facts regarding supplier S5 even when he is not supplied any part, which was earlier not
possible. This solves insert problem. Similarly, delete and update problems are also over now.
INSERT: We are unable to insert the fact that a particular city has a particular status until we
have some supplier actually located in that city.
DELETE: If we delete sole REL2 tuple for a particular city, we delete the information that that
city has that particular status.
UPDATE: The status for a given city still has redundancy. This causes usual redundancy
problem related to update.
3. Third Normal Form
To convert the 2NF relation into 3NF, once again, the REL2 is split into two simpler relations
REL4 and REL5 as shown below.
RELATION 4 {S#, SUPPLYCITY}
and
RELATION 5
{SUPPLYCITY SUPLLYSTATUS}
Sample relation is shown below.
RELATION 4
RELATION 5
S#
SUPPLYCITY
S1
S2
S3
S4
S5
Madras
Mumbai
Mumbai
Madras
Kolkata
SUPPLYCITY
SUPPLYSTATUS
Madras
Mumbai
Kolakata
200
100
300
Evidently, the above relations RELATION 4 and RELATION5 are in 3NF, because there is no transitive
dependencies. Every 2NF can be reduced into 3NF by decomposing it further and removing any
transitive dependency.
4.
It seems that the sole operation necessary or available in the further normalization process is the
replacement of a relation in a nonloss way by exactly two of its projections. This assumption has
successfully carried us as far as 4NF. It comes perhaps as a surprise, therefore, to discover that
there exist relations that cannot be nonloss-decomposed into two projections but can be
nonlossdecomposed
into three (or more). An unpleasant but convenient term, we will describe such a
relation as "n-decomposable" (for some n > 2) - meaning that the relation in question can be
nonloss-decomposed into n projections but not into m for any m < n.
A relation that can be nonloss-decomposed into two projections we will call "2-decomposable"
and similarly term n-decomposable may be defined.
Co.
Popu.
Co.
name
Counties
Pop
u.
Located in1
Belongsto
Cities
Capital
Ci.
Popu.
Ci.
name
Name
States
Assignment C
Part A ( Q1-Q20)
1. What does acronym SQL stands for?
a) Standardized Query Language
b) Structured Query Language
c) Simple Query Language
11. John is working in the customer table and needs to know what customers are located in
Florida. To find the information, he would.
a) create a new table
b) create a new query
c) create a new form
d) utilize the Database Wizard
12. Where does the DBMS store the definitions of data elements and their relationships?
a) Data file
b) Data dictionary
c) Index
d) Data map
13. When the DBMS translates logical requests into commands that physically locate and
retrieve the requested information, it is fostering data ____.
a) Integrity
b) Inconsistency
c) Independence
d) Mining
14. All of these are true about a database except
a) it is a shared, integrated structure
b) it must contain multiple tables
c) it stores user data
d) iit stores metadata
15. Metadata is:
a) raw facts
b) user created data
c) data about data
d) warehoused data
16. The DBMS stores definitions of the data elements and their relationships in a:
a) fixed length record
b) data dictionary
c) fixed length field
d) information diary
17. ____ is defined as "the condition in which all of the data in the database are consistent
with the real-world events and conditions."
a) data dictionary
b) data integrity
c) data anomaly
d) data processing
18. ____ is a DBMS function in which the DBMS creates and manages the complex
structures required for data storage.
a) data dictionary management
b) backup and recovery management
c) data storage management
d) database communication interfaces
19. The ___________ manages interaction between the end user and the database.
a) DM query engine
b) DBMQ
c) DBMS
d) DP
20. The hierarchical database model is based on a ____.
a) Tree Structure
b) Lack of a child segment
c) Lack of a parent segment
d) Matrix
Part B (Q21-40) Table Name = Library
No.
Title
1
2
3
4
5
6
7
8
9
10
Data Structure
Computer Studies
Adv. Pascal
DBASE dummies
Mastering C++
Guide Network
Mastering Access
DOS Guide
Basic for Beginners
Windows Guide
Author
Ajeet
Shivam
Vivek
Shivani
Manav
Robin
Divjot
Ankit
Ankita
Malvika
Type
DS
FND
PROG
DBMS
PROG
NET
DBMS
OS
PROG
OS
Pub
McGraw
Galgotia
McGraw
PustakM
BPB
ZPress
BPB
PH1
BPB
BPB
Qty.
Price
4
2
4
5
3
3
2
3
3
1
(Rs.)
217
75
350
130
295
200
135
175
40
225
MySQL> SELECT *
FROM Library
WHERE Misplacement_Charges = Price*1.25
ORDER BY Title;
MySQL> INSERT INTO Library VALUES (11, Title of Book, Author of Book, Type of Book, Pub of Book,
Qty. of Book, Price of Book);
8. Count the no of books in each Type.
MySQL> SELECT COUNT (DISTINCT publisher)
FROM Library
GROUP BY Type
ORDER BY Quantity;
9. Add one more attribute No_of_copies in the above table.
MySQL> INSERT INTO Library VALUES (no_of_copies int);
10. Update the new attribute value with 2 for each book.
MySQL> UPDATE Library VALUES (no_of_copies int);
11. Count the total number of Publishers.
MySQL> SELECT COUNT (DISTINCT pub)
FROM Library
GROUP BY Pub
ORDER BY Quantity;
12. Drop table Library.
MySQL> DROP Table Library;