COURSE OUTLINES:
Record keeping constituted the major part of the operation of most organizations
and corporate bodies. Businesses keep records on customers, employees, inventory,
taxes, payrolls, sales and so on. Schools keep records of students, teachers and class
attendance. Clubs keep tracks of membership meetings and dues. Records, such as
these constitute the database of an organization.
In the past, database were kept in paper and stored in ledgers and cabinets, clerks
were employed just to file and retrieve these paper records. Today, records are
increasingly kept as electronic images in a computer.
Advantage of Database.
• Data Independence
Low systems/programs maintenance
• Data Consistency
Due to the fact that each data item is held only once, there is no danger of an item
being updated on one system and not on the other
• Controlled Redundancy
This means reducing to a minimum the number of data items, which are duplicated
in a database. In a non-database system, the same
Information may be held on many different files, which not only
Wastes space but also makes updating much more time consuming.
Data Integrity
In a database, data are organized into a single, logical structure, with logical
relationships defined between associated data entities. This makes it easy for users
to relate one item of data to another.
The DBMS provides users with the ability to specify constraints on
data such as making a field entry essential or using a validation routine
• Data Security
The DBMS can ensure only authorized users are allowed access to the
data.
Disadvantage Of Database
Repository Centralized knowledge base containing all data definitions, screen and
report formats and definitions of other organizations and system components.
• Database management system (DBMS)
Commercial software system used to create, maintain and provide controlled access
to the database and repository.
• Database
A shared collection of logically related data, designed to meet the information needs
of multiple users in an organization.
• Application programs
Computer programs that are used to create and maintain the database and provide
information to users.
• User interface
Languages, menu and other facilities by which users interact with various system
components.
• Data administrators
Persons who are responsible for the overall information resources of an organization.
• System developers
Persons such as system analysts and programmer who design new application
Programs.
• End users
Persons throughout the organization, who add, delete and modify data in the
database and who request or receive information from it.
RELATIONAL DBMS
Relational Database Concept.
The principles of the relational model were first outlined by Dr. E. F. Codd in a June
1970 paper called A Relational Model of Data for Large Shared Data Banks . In this
paper, Dr. Codd proposed the relational model for database systems.
A relational database stores all its data inside tables, and nothing more. All
operations on data are done on the tables themselves or produce another table as the
result. You never see anything except for tables.
Relational database management systems (RDBMS) soon became very popular
because of their ease of use and flexible structure.
Components of the Relational Model • Collections of objects or relations that store
the data • A set of operators that can act on the relations to produce other relations •
Data integrity for accuracy and consistency
Relational Database Definition.
A relational database uses relations or two-dimensional tables to store information.
Relational databases are organized by fields, records, and tables. A field is a single
piece of information; a record is one complete set of fields; and a table is a collection
of records.
Database
Course Table CourseID CourseDesp MentorID DCS Diploma In Computer Studies
1006 DIC Diploma In Computing 1006 DICT Diploma In Info-Comm Technology
1002 DIT Diploma In Information Technology 1001
diagram
Table
A relational database system contains one or more objects called tables. The data or
Information for the database is stored in these tables. Tables are uniquely identified
by their names and are comprised of columns and rows. Columns contain the column
name, data type, and any other attributes for the column. Rows contain the records
or data for the columns. In relational database, table is also known as relation.
Row
A single row or tuple representing all data required for a particular object. The
Student table (Figure 1.2), shows each row representing a piece of information about
a student. Each row in a table should be identified by a primary key, which allows no
duplicate rows. The order of rows is insignificant; specify the row order when the
data is retrieved. In another words, the rows of a table are considered to be in no
particular order so they are an unordered set.
Column
A column or attribute contains one particular type of information that is kept about
all the rows in the table. A column cannot, or should not, contain one type of
information for one row and another type for another row.
Each column has a name and it represents it own information. For example the
StudID column contains a list of student identification number
Each column has a name and it represents its own information. For example the
StudID column contains a list of student identification number.
A column may contain or not contain any key value. The column StudID (as example)
is a primary key . This student number identifies a unique student in the Student
table. Another type of key value is the foreign key . The CourseID column is a foreign
key ; a column that defines how tables relate to each other. A foreign key refers to a
primary key or a unique key in another table. In the example, CourseID uniquely
identifies a course in the Course table.
A column that is not a key value represents one kind of data in a table; in the example,
the last name of all the employees. Column order is insignificant when storing data;
specify the column order when the data is retrieved.
• Primary key
A primary key is a single field or combination of fields that uniquely defines a record.
None of the fields that are part of the primary key can contain a null value. A table
can have only one primary key.
General Guidelines:
• No duplicate values are allowed in a primary key.
• Primary keys generally cannot be changed.
• Foreign key
A foreign key is a field in a relational table that matches the primary key column of
another table. The foreign key can be used to cross-reference table.
Field
A field can be found at the intersection of a row and a column. There can be only one
value in it. It is the smallest part of a table and it cannot be broken down into smaller
parts. A field contains one single piece of data, a single unit of information.
Null value
A field may have no value in it. This is called a null value. In the Student table, those
who are a group leader are not eligible to be assigning group leader identification to
them because they themselves is a group leader. For example S005, the group leader
field is with NULL value because he is not being lead by any leader.
The interactions catered for by most existing DBMS fall into four main groups:
• Data definition: Defining new data structures for a database, removing data
structures from the database, modifying the structure of existing data.
A DBMS is responsible for maintaining the integrity and security of stored data, and
for recovering information if the system fails.
DEFINITIONS
Fields A field can be said to be an item of data. E.g. Surname, Address etc.
Record – A record is a collection of fields about a particular object.
Database structure – A database structure is a description of each field that
makes up a data record. Each field description is composed of the following.
Field Name – The name for a particular field (for example, first name, middle
names last names, Address, phone etc) field names can contain up to 64 characters
(letters numbers and space) however, field name must to be unique within the table.
Field Type (data type) – whether the field will contain numbers, text, and
date/time. Memo etc.
Field Width – the maximum width of an entry allowed for a field.
Communicating with a RDBMS by Using SQL.
Relational database management system or RDBMS in short is a software or
environment that acts as the middleman for the user to communicate to the
database. User need to issue the SQL statement at the RDBMS and then
RDBMS will sent this statement to the database and return a list of result to the
user at the RDBMS interface. SQL is used to interact with your database's data.
Access uses SQL for many tasks: whenever a query is run it uses SQL to filter
the data; whenever a report is displayed SQL is used to gather the data to be
displayed; SQL provides the data displayed on Access form.
DIAGRAM
= Equal to
!= Not equal to
What is SQL?
SQL (pronounced "sequel") stands for Structured Query Language. SQL is used
to Communicate with a database. According to ANSI (American National
Standards
Institute), it is the standard language for relational database management
systems.
SQL statements are used to perform tasks such as update data on a database,
orRetrieve data from a database. Some common relational database
management systems
that use SQL are: Oracle, Sybase, Microsoft SQL Server, Access, Ingres, etc.
Although most database systems use SQL, most of them also have their own
Additional proprietary extensions that are usually only used on their system.
However, The standard SQL commands such as "Select", "Insert", "Update",
"Delete", "Create", and "Drop" can be used to accomplish almost everything
that one needs to do with a Database. Throughout this module, it will teach you
the basics of each of these commands as well as allow you to put them to
practice using the SQL view in Microsoft Access.
SQL statements
SQL statement can be group into few category based on their functionality.
Category SQL statement
• Data Retrieval Language (DRL) SELECT
• Data Manipulation Language (DML) INSERT DELETE
UPDATE
• Data Definition Language (DDL) CREATE ALTER DROP
RENAME TRUNCATE
• Transaction Control COMMIT ROLLBACK
SAVEPOINT
• Data Control Language (DCL) GRANT REVOKE
1) Creating a database
mysql> CREATE database 134a;
Query OK, 1 row affected (0.00 sec)
2) Deleting a database
mysql> DROP database 134a;
Query OK, 0 rows affected (0.00 sec)
Creating a Table
3) After we have created the database we use the USE statement to
change the current database;
mysql> USE 134a;
Database changed
4) Creating a table in the database is achieved with the CREATE table
statement
mysql> CREATE TABLE president (
-> last_name varchar(15) not null,
-> first_name varchar(15) not null,
-> state varchar(2) not null,
-> city varchar(20) not null,
-> birth date not null default '0000-00-00',
-> death date null
-> );
Query OK, 0 rows affected (0.00 sec)
Create Database student;
Query ok,
Create a table students(Fname varchr(50),Lname varchar(50),Dept varchar(50),
Course Varchar(30), Gender char(30));
Create table Employee( empid int, empname varchar(50), empdept varchar(50),
empaddres varchar(40), empsal int);
TYPES OF DBMS:
There are four main types of database management systems (DBMS) and these are
based upon their management of database structures. In other words, the types of
DBMS are entirely dependent upon how the database is structured by that particular
DBMS, these are:
• Hierarchical DBMS.
• Network DBMS.
• Object-Oriented DBMS. And
• Relational DBMS.
• HIERARCHICAL DBMS:
A DBMS is said to be hierarchical if the relationships among data in the database are
established in such a way that one data item is present as the subordinate of another
one or a sub unit. Here subordinate means that items have "parent-child"
relationships among them. Direct relationships exist between any two records that
are stored consecutively. The data structure "tree" is followed by the DBMS to
structure the database. No backward movement is possible/allowed in the
hierarchical database.
The hierarchical data model was developed by IBM in 1968 and introduced in
information management systems. This model is like a structure of a tree with the
records forming the nodes and fields forming the branches of the tree. In the
hierarchical model, records are linked in the form of an organization chart. A tree
structure may establish one-to-many relationship.....
4.Efficiency: It is very efficient because when the database contains a large number
of 1:N relationship and when the user require large number of transaction.
• NETWORK DBMS:
2. Complex queries can be carried out. A language called SQL has been
developed to allow programmers to 'Insert', 'Update', 'Delete', 'Create', 'Drop' table
records.
3. Better security. By splitting data into tables, certain tables can be made
confidential. When a person logs on with their username and password, the system
can then limit access only to those tables whose records they are authorized to view.
For example, a receptionist would be able to view employee location and contact
details but not their salary. A salesman may see his team's sales performance but not
competing teams.
• DATA SECURITY:
Other safeguards:
• Software safeguards include giving users:
• A user identity and a password.
• Users of this type of system have to log in and log out every time
they use it.
• Other safeguards include:
• Password individual files.
• Data encryption.
• To encrypt data is to encode it so that it is unreadable by anyone
else who does not have the ‘key’.
• DATA INTEGRITY:
The integrity of data means its accuracy and completeness. Data has integrity if it
has not been corrupted in any way. Common causes of errors are:
• Mistakes in data capture (faulty sensors etc)
• Transmission errors (over the internet etc)
• Transcription errors (transposition of letters)
Data is said to be corrupt if errors are introduced into it. Usually the errors have
been introduced by faulty equipment.
• DATA SECURITY:
Other safeguards:
• Software safeguards include giving users:
• A user identity and a password.
• Users of this type of system have to log in and log out every time
they use it.
• Other safeguards include:
• Password individual files.
• Data encryption.
• To encrypt data is to encode it so that it is unreadable by anyone
else who does not have the ‘key’.
• DATA INTEGRITY:
The integrity of data means its accuracy and completeness. Data has integrity if it
has not been corrupted in any way. Common causes of errors are:
• Mistakes in data capture (faulty sensors etc)
• Transmission errors (over the internet etc)
• Transcription errors (transposition of letters)
Data is said to be corrupt if errors are introduced into it. Usually the errors have
been introduced by faulty equipment.