Professional Documents
Culture Documents
To project on this further, multiple addresses kept together in one place, such as an
address book, could be termed as a coherent collection of data. Thus the address book
is a database and the postal addresses in the book, is the data that fills the database .
Hence, the objects, there attributes and the relationship between them (that are of
interest to us) are stored in the database that is designed, built and populated with
data for a specific purpose.
Software houses took up the cha1lenge of designing a system that would help in
managing data in such a database. These systems were called Database Management
Systems (DBMS). DBMS is a system that allows inserting, updating, deleting and
processing of data. Some of the DBMS developed by software houses were Oracle,
Ingress, Sybase, Dbase 3+, Fox base, FoxPro, MS Access, Database, Data flex,
Advanced Revelation, and so on.
EMP_NO
NAME
SKILL
POSITION_NO
123456
321
Mehul
RDBMS WAITER
Patel
(BCA-201) Class: SYBCA Unit/21
-I
WAITER
123457
323
JON
BUSBOY
BUSBOY
324
123458
BELLBOY
DON
The amount of data redundancy in stored data can325
1. BELLBOY be reduced.
HOSTESS
2.123459
No more data inconsistencies.
PAM
3. Stored data can be shared by a single or multiple users .
4.HOSTESS
Standards can be set and followed .
5. Data integrity can be maintained. Data integrity refers to the problem of
ensuring that database contains only accurate data.
6. Security of data can be simply implemented.
7. Data independence can be achieved, i.e. data and programs that manipulate the
data are two different entities.
۞ DISADVANTAGE OF DBMS:-
The relational data model has emerged from the research, development, test and
trial stages as a commercial product. Software systems using this approach are
available for all size of computer system. This model has the advantage of being
simple in principle; users can express their queries in a powerful query language.
In this model, the relation is the only construct required to represent the
association among the attributes of an entity as well as the relationship among
different entities. One of the main reason for introducing this model was to increase
the productivity of the application programmer by eliminating the need to change
application programs when a change is made to the database. Users need not know
the exact physical structure to use the database and are protected from any
changes made to these structures. They are however, still required to know the
data has been partitioned into the various relations.
EMPLOYEE POSITION
The relation is the only data structure used in the relational data model to represent
both entities and the relationship between them. A relation may be visualized as a
named table. Above figure shows two relations employee and position using tabular
structure. Each column of the table corresponds to an attribute of the relation and
is named.
RDBMSPatel
Mehul (BCA-201) Class: SYBCA Unit/21
-I
Relational Database Management Systems (RDBMS) stores data in the form of related
tables. RDBMS are powerful because they require few assumptions about how data is
related or how it will be extracted from the database. As a result, the same database
can be viewed in many different ways.
Today, popular commercial RDBMS for large databases include Oracle, Microsoft SQL
Server, Sybase SQL Server, and IBM's DB2. The most commonly used free RDBMS are
MySQL, PostgreSQL.
Today, the rules are not talked about as much but remain a goal for relational
database design .
Many of the databases will be small, with one or two tables. But as the databases
become braver, tackling, bigger projects, it will be noticed that the design of the tables
is proving problematic. The SQL written starts to become unmanageable and data
anomalies start to creep in. This means it is time to learn about database
normalization, or the optimization of tables.
RDBMS
Mehul Patel
(BCA-201) Class: SYBCA Unit/21
-I
> NORMALIZATION
Table: EmpPro
Field Key Type
Project Number --
Project Name --
Employee Number -- 1-n
Employee Name -- 1-n
Rate Category -- 1-n
Hurly Rate -- 1-n
1-n indicates that there are many occurrences of this field - it is a repeating group.
So far there are no keys, and there are repeating groups. So remove the repeating
groups, and define the primary key.
Table: EmpProj
Field Key
Project Number Primary Key
Project Name --
Employee Number Primary Key
Employee Name --
Rate Category --
Hurly Rate --
RDBMS
Mehul Patel
(BCA-201) Class: SYBCA Unit/21
-I
Field
Key
Project Number
Primary Key
Employee Number
>Second Normal Form Primary Key
A table is said to be in its second normal form when each record in the table is in the
first normal form and each column in the record is fully dependent on its primary key.
To convert the table into the second normal form remove and place these fields in a
separate table, with the key being that part of the original key they are dependent on.
Table: EmpProj
Table: Proj
Field Key
Project Number Primary Key
Project Name --
Table: Emp
Field Key
Employee Number Primary Key
Employee Name --
Rate Category --
Hurly Rate --
The table is now in 2nd normal form, but not yet in its 3rd normal form
RDBMS
Mehul Patel
(BCA-201) Class: SYBCA Unit/21
-I
Field Key
Table: Emp Employee Number Primary Key
Table: Rate Employee Name
Rate Category
>Third Normal Field Form
Table data is said to be inKey
third normal format when all transitive dependencies are
removed from this data".
To convert such data to its third normal form remove this transitive dependency by
splitting each relation in two separate relations. This means that data in columns A, B,
C must be placed in three separate tables, which are linked using a foreign key
To convert the table into the third normal form remove and place these fields in a
separate table, with the attribute it was dependent on as key, as follows:
Field
Table: EmpProj Key
Project Number Primary Key
Employee Number Primary Key
Table: Proj
Field Key
Project Number Primary Key
Project Name --
Rate Category --
Hurly Rate --
RDBMS
Mehul Patel
(BCA-201) Class: SYBCA Unit
10/21
-I
These tables are all now in their 3rd normal form, and ready to be implemented. There
are other normal forms such as Boyce-Codd normal form (BCNF), 4th and 5th normal
form, but these are very rarely used for business applications. In most cases, tables
that are in there 3rd normal form are already conforming to these types of table
formats anyway.
Table: Customer
Field Key
Customer Number Primary Key
Customer Name --
Address --
Pincode --
City --
Although this table is not technically in its 3rd normal format, removing this
information is not worth it. Creating more tables increases the load slightly, slowing
processing down. This is often counteracted by the reduction in table sizes, and
redundant data. But in this case, where the City would almost always be referenced as
part of the address, it isn't worth it. Normalization is just a helpful process that usually
results in the most efficient table structure, and not a rule for database design.
RDBMS
Mehul Patel
(BCA-201) Class: SYBCA Unit
11/21
-I
Way back in June 1970, Dr E. F. Codd published a paper entitled A Relational Model of
Data for Large Shared Data Banks. This relational model, sponsored by IBM, then
came to be accepted as the definitive model for RDBMS. The language developed by
IBM to manipulate the data stored within Codd's model was originally called Structured
English Query Language (SEQUEL) with the word English later being dropped in favor
Structured Query Language (SQL).
In 1979 a company called, Relational Software, Inc. released the first commercially
available implementation of SQL. Relational Software later came to be known as Oracle
Corporation. Oracle Corporation is a company that produces the most widely used,
Server based, Multi-user RDBMS named Oracle.
In common usage SQL also encompasses DML (Data Manipulation Language), for
Inserts, Updates, Deletes and DDL (Data Definition Language), used for creating and
111odifying tables and other database structures.
> DATATYPE(S):
1. Character Data types
Character data types are used to manipulate words and free-form text. These
data types are used to store character (alphanumeric) data in the database or national
character set. They are less restrictive than other data types and consequently have
fewer properties.
These data types are used for character data:
CHAR
VARCHAR
VARCHAR2
VARCHAR2 Datatype
The VARCHAR2 datatype specifies a variable length character string. When you
create a VARCHAR2 column, you can supply the maximum number of bytes of data
that it can hold. Oracle subsequently stores each value in the column exactly as you
specify it, provided it does not exceed the column's maximum length. This maximum
must be at least 1 byte, although the actual length of the string stored is permitted to
be zero. If you try to insert a value that exceeds the specified length, Oracle returns an
error.
You must specify a maximum length for a VARCHAR2 column. The maximum length
of VARCHAR2 data is 4000 bytes .
VARCHAR Datatype
The VARCHAR datatype is currently synonymous with the VARCHAR2 datatype.
It is recommended that you use VARCHAR2 rather than VARCHAR. In a future version
of Oracle, VARCHAR might be a separate datatype used for variable length character
strings compared with different comparison semantics .
RDBMS
Mehul Patel
(BCA-201) Class: SYBCA Unit/21
-I
2. NUMBER Datatype
The NUMBER datatype is used to store zero, positive and negative fixed and
floating point numbers with magnitudes between 1.0 x 10-130
and 9.9...9 x 10 125 (38 9s
followed by 88 0s) with 38 digits of precision. If you specify an arithmetic expression
whose value has a magnitude greater than or equal to 1.0 x 10 126
, Oracle returns an
error.
You can specify a fixed-point number using the following form:
NUMBER (p,s)
Where,
p is the precision , or the total number of digits. Oracle guarantees the portability of
numbers with precision ranging from 1 to 38.
s is the scale, or the number of digits to the right of the decimal point. The scale
can range from -84 to 127.
The following examples show how Oracle stores data using different precisions and
scales.
Actual Data Specified As Stored As
7456123 .89 NUMBER 7456123 .89
7456123 .89 NUMBER(9) 7456124
7456123 .89 NUMBER(9,2) 7456123 .89
7456123 .89 NUMBER(9,1) 7456123 .9
7456123 .8 NUMBER(6) exceeds precision
7456123 .8 NUMBER(15,1) 7456123 .8
7456123 .89 NUMBER(7,-2) 7456100
7456123 .89 NUMBER(-7,2) exceeds precision
You can specify a scale that is greater than precision, although it is uncommon.
In this case, the precision specifies the maximum number of digits to the right of the
decimal point. As with all number datatypes, if the value exceeds the precision, Oracle
returns an error message. If the value exceeds the scale, Oracle rounds the value. For
example, a column defined as NUMBER (4,5) requires a zero for the first digit after the
decimal point and rounds all values past the fifth digit after the decimal point. The
following examples show the effects of a scale greater than precision:
3. LONG Datatype
LONG columns store variable length character strings containing up to 2
gigabytes, or 2 31 -1 bytes. LONG columns have many of the characteristics of
VARCHAR2 columns. You can use LONG columns to store long text strings. Oracle uses
LONG columns in the data dictionary to store the text of view definitions. The length of
LONG values may also be limited by the memory available on your computer.
The use of LONG values is subject to some restrictions:
4. DATE Datatype
The DATE datatype is used to store date and time information. Although date
and time information can be represented in both CHAR and NUMBER datatypes, the
DATE datatype has special associated properties.
For each DATE value the following information is stored:
century
year
month
day
hour
minute
second
7. ROWID
For each row in the database, the ROWID pseudo column returns a row's address.
Usually, a ROWID value uniquely identifies a row in the database. However, rows in
different tables that are stored together in the same cluster can have the same
ROWID.
Values of the ROWID pseudo column have the data type ROWID.
You should not use ROWID as a table's primary key. If you delete and reinsert a
row with the Import and Export utilities, for example, its ROWID may change. If you
delete a row, Oracle may reassign its ROWID to a new row inserted later.
Although you can use the ROWID pseudo column in the SELECT and WHERE clauses
of a query, these pseudo column values are not actually stored in the database. You
cannot insert, update, or delete a value of the ROWID pseudo column.
TYPE: DML
SYNTAX:
UPDATE <tablename>
SET columnname = <expr>, columnname =<expr>
[ WHERE <condition> ];
Changing the existing values in a table or in a view’s base table.
> TRUNCATE
TYPE: DML
SYNTAX: TRUNCATE TABLE <tablename>;
Will delete all the records from a table and records cannot be ROLLBACK.
> RENAME
TYPE: DDL
SYNTAX: RENAME <oldname> TO <newname>;
User can rename a table.
SPOOL OUT: This command will stop spooling and will also copy the spool file’s
-)