Table of Content Preface INDEX Introduction……………………………………………………………………..1 Background…………………………………………………............................1.1 AIM……………………………………………………………………………2.0 Functions and Facility………………………………………………………….3.0 Data manipulation language......................................................... ..................…...3.1 Data Definition Language…………………………………………………….…3.2 Data type and Constraint………………………………………………………..3.3 Clause………………………………………………………………………….…3.4 Changes made on the tools……………………………………………………….4.0 Changes made on the server………………………………………………………4.1 Activity Covered………………………………………………………………….5.0 ER Model for UCSI University…………………………………………………...5.1 ER diagram………………………………………………………………………...5.2 Create table statement……………………………………………………………..5.3
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
The growth of internet and the web over the last two decades and the rising demand to access
and manage information and data has deemed it necessary for a database management system
(DBMS). The relational database model was developed using SQL (Structure Query Language)
so that database management system could be arranged in tables called Relational database
management system (RDBMS) whereby these data(S) and information can be managed better,
and new information can be added, retrieved, updated without the need to reorganize the tables.
WHAT IS SQL?
SQL simply means Structured Query language, this structured query language is a computer
based language, which can be used for the storage of data, inserting data and deleting data in a
database.
The structured query language was written by Edgar f.Code also this computerized language is
the most widely used computerized language for relational database.
HISTORY OF SQL
The origin of SQL dates back to 1970’s by IBM, Dr. E. F. Codd published a book titled
“Relational model of Data for Large shared Data Banks “this eventually became the foundation
of the relational database System. This published book provided a new way to structure data
within the database and also led to the relational database System that we use today. [1]
The likes of DR.codd was not alone in the business, while he was busy defining the structure of
the database, how the database would look like, and how data’s are to be stored his colleagues
whose names are Donald D. Chamberlin and Raymond F. Boyce who worked at IBM had been
developing a query language known as SQUARE (SPECIFYING QUERIES AS RELATIONAL
EXPRESSIONS). [2] This language was used to set theory and duplicate mathematics to select
data from the database. This language had a terse mathematical syntax and became the proven
ground for concept which is important in database projects.
By 1974, Chamberlin and Boyce published “SEQUEL: A Structured English Query Language”
which detailed their refinements to SQUARE and introduced us to the data retrieval aspects of
SEQUEL. This new SEQUEL language was as powerful as SQUARE, but Chamberlin and
Boyce “kept in mind the notions of top down structured programming, the need for linear
notation, and the need for readable programs that are easy to maintain and modify”. The
resulting syntax could be described as block-structured English keyword syntax. [3]
2.0 Aim.
─ SQL was developed, to help store data
─ To deal with the relational database environment and to help solve problems
─ To modify database
─ To help build a database system, that can be able to store data, allows users to insert
rows, delete rows and so on
─ Manipulate and retrieve data stored in a database
3.0 FUNCTIONS AND FACILITIES OF SQL
The SQL language has many functions such as rows, columns clauses and tables. Semicolons are
used to end a statement in SQL computer based language. Though the semi-colon is not required
in every platform it is important for the statement.
Also the Select word is been used in SQL before writing a statement, the select statement is used
to show or indicate what the user wants to do with the database. Also the most common type of
operation in SQL is known as the “Query” statement.
(I.e. Select*
From students ;)
This simple SQL statement written above would retrieve all data from the student’s table, it is
also going to indicate its data type and constraints also it would indicate the null values in the
table.
The two main type of language used in SQL, are Data manipulation language and Data definition
Language.
3.1 Data Manipulation Language:
Data manipulation language is a core part of SQL.it is been used when a user wants’ to add or
delete data from the database. [4]
In these functions of SQL, we would be talking about how to add rows, delete rows and update
roes in a given database.
Insert Statement:
Insert statement are SQL statement which are used to insert new rows into a table in a database
environment. You can add rows, by using the insert syntax. [4]
Insert into table [(column [, column…….])]
Values (value [, values………]);
For example:
A user wants to insert a table, whose name is campus. Who has columns named, campus id and
campus name.
Insert into Campus
Values (UCSI, UCSI University);
Or the user can use this method.
Insert into campus (campus_id, campus_name)
Values (‘UCSI’, ‘UCSI University’);
This SQL insert statement above would insert a row whose id is UCSI into the table named
campus.
Update Statetement
The update statement is a feature in SQL language which is used to update tables in a database.
Although it’s main objective is to modify existing rows in a table. [4]
Just as the insert statement and the update statement have different meaning, so also they have
different syntax, and they have different functions.
Example:
A database administrator wants to update a table in his database. All what he or she needs to do
it’s to specify the role he or she wishes to update. Let’s assume the name of the table is called
employees, and the administrator wants’ to update the salary of all employees whose first name
is john to 500.
Update employees
SET first_ name = ‘john’
Where Salary=500;
So this update statement would update the salary status of all employees whose first name is
john, and give them a salary rate of 500.
Delete Statement
Delete statement is a type of data manipulation language which is used in deleting rows from a
table, in a database. The delete statement is the most easiest to execute among the main three
data manipulation languages. [4]
DELETER FROM table
[Where Condition];
What the delete statement is implying is that, for a user to delete a row, he or she has to specify
the role he or she wants to delete, by specifying the where condition the database administrator
has to be specify one data in the row he wants to delete, so that it can be deleted easily, because
if the where clause is not indicated, the entire rows in that particular table would be deleted.
Delete from campus
Where campus_id =’UCSI’;
3.2 Data Defining Language:
Data defining language are SQL languages which are used to create and manage tables in a
database. The main feature of the data definition language is called the create table statement.
Create Table Statement.
A database consists of different tables, which have data’s stored in them. The data’s can be
numerical or alphabetical, also the type of data that are stored in a table describes that particular
table. [5]
Example:
A table names driver, consist of columns that are related to the driver and rows that describes the
driver.
Create TABLE driver
(driver_name VARCHAR2 (20),
Address VARCHAR2 (30),
Telephone NUMBER (20))
The create table statement above shows a table titled “driver “this table has three columns. As
mentioned before the rows and columns in the table describes the particular table.
Nevertheless a database administrator with full understanding of SQL would be able to drop the
table and describe the table by writing simple SQL statement. The two SQL statements below are
used to drop table in a database and also describe table in a database.
Drop Table driver;
Describe driver;
3.3 Data types and Constraints. Data type and constraint are one of the most talked about
computer based related issue. Each computer language tries to define data type in a way related
to their application or to their software. [5]
Types of data types in SQL and their description.
The diagram below was attained based on reference. [5]
Data types Description
VARCHAR2 It specifies the length of the data’s Variables to
be precise.
CHAR The length of the data type when using Char is
being fixed, by the database itself rather than
the designer.
NUMBER It specifies the length of the numbers in a
particular column
DATE It is used to set Date and time in a database.
LONG It is like VARCHAR2,but it has a length up to
2GB
CLOB Unlike LONG it’s size it’s up to 4GB
RAW and LONG RAW It deals with the binary information in the
database
BLOB It has a length that is up to 4GB
BFILE This indicates that a binary data, has been
saved in an external file, and also its size is up
to 4GB
ROWID This data type in SQL represent the
Uniqueness of a row in its table, also it consist
of a 64 numbering system
Constraints
In SQL there are four main types of Constraints, and they are
1. PRIMARY KEY constraints
2. FOREIGN KEY Constraint
3. UNIQUE Constraint
4. CHECK Constraint
Constraint can be declared in both table levels and column level in database system, it all
depends on the administrator which one he or she wants to use in declaring the Constraint, but
the table level Constraint is the best method, because it gives the table a befitting Architecture
and also there are less problems, but column level constraint can be a little bit triggy because of
its ability to cause error.
PRIMARY KEY Constraint
A primary key constraint can be defined as a column or set of column that uniquely identifies
each row in a table. [6] If a column has been declared as a primary key is also means that the
column which is declared as the primary key can never contain a null value because of its
Uniqueness.
An SQL result table indicating a primary key and it’s null values.
Foreign Key
A foreign Key Constraint, simple means it is a primary key in its original table. For example
This Entity relational diagram above show a primary key constraint and how an attribute can be
considered a foreign key, there are two different tables here, where course id is a foreign key in n
the student table and a primary key in its own table (Course).
Unique and check Constraint.
A Unique integrity constraint requires that every value in a column or a set of column be unique. [7] It been unique means there would be no repetition of words or number in that column.
Unique column
Lecturer_id Lecturer_name Department Subject_teaching Email
Since SQL is a computer based language, the functions and facility of this language helped us in
this project. Also we were able to understand that despite SQL being a computer based Language
it could run on many platforms including oracle.
In this application, we were asked to create a database for UCSI University, A system that would
be able to allow storage of data, insertion of data, and respect the SQL standards. Based on the
description of the required database, a plan had to be made, a designing pattern has to be made,
the analysis of the system needs to be put into consideration, how the system is going to work
needed to be put into consideration, so by putting all the points into consideration, the ER model
was drawn to help facilitate the proposed system, after the ER model had been drawn, it gave us
a very befitting understanding on how the system is going to be. on how the attributes are to be
named, and which table would be related to another.
After getting this fact down, we drew the ER diagram. The ER diagram makes the creation of the
database much easier, because by drawing the ER diagram, we already know the primary key,
and the foreign key.
Actually a software known as DeZign for database was the software which we used in drawing
the ER diagram, the software helps us indicating foreign keys and primary keys. Also we created
the tables in the database using Oracle database 10g express edition, this software supports SQL
commands, so we used the SQL commands prompt in creating tables, describing tables and
inserting rows.
Eventually, after creating, describing and inserting rows into the database, we tried out the
application by writing out and running some queries.
.
Conclusion:
in conclusion the ER model serve as reference model to the ER diagram and the ER diagram
serve as reference model to the create table statements. Also the ER model indicates the channel
of transaction and how it occurs.
Finally the subjects table in the ER model has one prerequisite, to the head of department
(HOD).
References:
[1]LiquidNet.ltd (http://www.ntchosting.com/databases/structured-query-language.html)”History of
SQL”accessed 5/24/2010
[2]. D D Chamberlin, R. F. Boyce, 1974(http://www.almaden.ibm.com/cs/people/chamberlin/sequel-1974.pdf.)” SEQUEL: A Structured English Query Language” may 16, 2007
[3] chris Collins,( http://ccollins.wordpress.com/2007/05/20/history-of-sql/)” History of SQL”,May 20,2007