Sie sind auf Seite 1von 31

Table of Content

Preface INDEX

Introduction..1 Background............................1.1 AIM2.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 server4.1 Activity Covered.5.0 ER Model for UCSI University...5.1 ER diagram...5.2 Create table statement..5.3 Insert Statement5.4 Problem Solving5.5 Discussion..6.0 Conclusion.7.0 References.8.0

1. Introduction 1.1. Background

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 1970s 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 datas 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 students 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 its 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 its to specify the role he or she wishes to update. Lets 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 datas stored in them. The datas 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 Address Telephone VARCHAR2 (20), VARCHAR2 (30), 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 VARCHAR2 Description It specifies the length of the datas 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 LONG It is used to set Date and time in a database. It is like VARCHAR2,but it has a length up to 2GB CLOB RAW and LONG RAW Unlike LONG its size its up to 4GB It deals with the binary information in the database BLOB BFILE It has a length that is up to 4GB 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 its 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 10007 10004 10009 Lecturer_name Ms Kasthuri Mr. Yemen Mr. Ibo Department IT Engineering Music Subject_teaching OOM1 Calculus keyboard Email k@yahoo.com Y@hotmail.com Ogmail.com

Not allowed, number already exists. 10007 10005 Mr. dean Mr. shaman agriculture fishery Agric science farming ag@sch.org Eu.yahoo.com Allowed. While check constraint are constraint that defines a condition each row must satisfy. 3.4 Clauses In SQL clause are used to indicate what you want the tables to retrieve, the types of clauses that are usually used in SQL are categorized into functional data and non functional data and they are: 1. Where clause 2. from clause 3. Having clause 4. with clause 5. Group By clause 6. Order By clause

Where clause: The where clause is the type of clause is the type of clause which restrict the number of rows returned by the queries, the where clause also makes sure the statement must be true before returning the required output of that statement. When writing an SQL statement which contains a where condition, the user of the system or the designer needs to be aware of the WHERE clause syntax and how it is been applied.
[8]

Also when using the where clause we are to take note of

single operators and multiple operators. Select column From table Where [(condition)] Operators = < > .<> IN ALL For example: Select driver_id, driver_name From taxi Where driver_id =10009; FROM CLAUSE The form clause is the type of clause in an SQL statement which indicates the table the user wants to retrieve a data from. For example: Description Equal Less than greater Not Equal to Includes all values, just like Equal to operator Return all values.

Select* From driver; This SQL command statement implies that all data in the drivers table should be derived or retrieved. Group By clause and Having clause These types of clause are used to group values in a particular column and also used to perform calculation in a column. [9] Example: Select last_name, emp_id, AVG (salary) From employees Having AVG (Salary) = 500; Group by emp_id

4.0

Changes made on the tool:

There is no way we are to talk about the changes made in SQL, without talking about the standards of sql.sql is a computing language that is very unique language that is different from many other languages, SQL can run on many platforms including oracle. Also the standards of this query language shows how the different SQL was developed, the aims and how it was been used, it also shows the weakness of the SQL server. SQL Standards SQL is a commonly recognized database language, the differences in major vendors implementations were growing, and some kind of standard became necessary. However in the year 1978, the Committee on Data Systems and Language (CODASYL) commissioned the development of a data model as a prototype of a database design. This development was done by the data defining language committee (DDLC) which later led to the development of the Data

defining language (DDC) and Data Manipulation Language (DML).This two SQL language became standard in the year 1986 and it was endorsed by an American association known as American National Standards Institute National Committee on Information Technology Standards H2 Technical Committee on Database (ANSI NCITS H2 TCD). In the year 1982, NCITS where given mandates to standardize relational model, since it was based on IBM SQL/DS specifications. The NCITS standardized the relational model and in the year 1984 the standard was already a recognized one. It allows more diversity among database. Finally in the year 1986 it was endoreced by the American National Standards Institute (ANSI) after its final endorsement it was adopted by the international standard Organization (ISO) in the year 1987.after the adaptation ISO developed the revised standard known as SQL89.which was published in the year 1989. SQL89 (SQL1) SQL89 also known as SQL 1 was the first SQL product that was extablished, it was published in the year 1989.but the end users could not ascertain upon implementations details. Because the end users could not agree with the implementation details. SQL92 (SQL2) Since many features in SQL 1989 was not working properly, and the end users where complaining,SQL89 was modified in the year 1992 for SQL92 which is also known as SQL2.The American National Standard institution (ANSI) took SQL82 as a basis and correct many features ,also it worked on the weakness of SQL89 to make SQL92 a better server. Also (ANSI) filled many gaps in the old standard, and presented conceptual SQL features to SQL92, which at that time exceeded the capabilities of any existing RDBMS implementation. Also, the SQL92 standard is over five times longer than its predecessor about 600 pages more, and has three levels of conformance. However in SQL89, the Entry-level conformance was different to that of SQL92. (i.e. circular views and correlated sub queries became prohibited in SQL91).

Despite the entry level conformance been different, the intermediate level conformance went through loads of improvement, the SQL92 was able to verify length, characters, national character set, case and cast expression, joint operators and dynamic SQL.that wasnt all the SQL 92 also creates loads of interactivity between the system and end users where by they can create tables, alter tables, set transactions, use sub queries in updatable view, use set operators (i.e. Union, Except, Intersect)to combine multiple queries result. Finally the SQL92 also has full-level conformance, and this full-level conformance includes deferrable constraints assertions, temporary local tables, privileges on character sets and domains. The testing of SQL 92 was performed by the U.S. Government Department of Commerce's National Institute of Standards and Technology (NIST). SQL99 (SQL3) SQL99 represents the next step in SQL standards development. The efforts to define this standard began virtually at the same time when its predecessor SQL92 (SQL2) was adopted. The new standard was developed under guidance of both ANSI and ISO committees. and the change introduced into the database world by SQL3 was as dramatic a shift from nonrelational to relational database model, its sheer complexity is reflected in the number of pages describing the standard over 1,500 comparing to 120 or so pages for SQL89 and about 600 pages for SQL92. Some of the defined standards (for example, stored procedures) existed as vendor-specific extensions, some of them (like OOP) are completely new to SQL proper. SQL3 was released as an ANSI/ISO draft standard in 1999; later the same year its status was changed to a standard level. It was lunch to enhance the current second generation SQL standard commonly called SQL-92,it was called SQL-92 because of the year it was published,SQL3 Was planned to be lunched in the year 1996but things didnt go as planned. also SQL3 has been characterized to be an Object Oriented SQL.also the SQL3 is the foundation of many other object oriented relational database management system (i.e. ORACLE8, Informix Universal Server, IBMs DB2 Universal Database, and others).It took nearly seven (7) years to develop this structured language instead of the three to four (3-4)years usually planned.SQL99 involves additional features that are not present in SQL-92 as well as total restructuring of the standards. The two organizations that are

involved in the standardization of the structured query language are and took part in the develop of SQL99, are ANSI and ISO.[10] 4.1 changes made on the server We cant talk of the changes made in the SQL computing Language alone, without talking about SQL server. Because without the availability of the server the SQL language would be unable to run on any platform including Oracle. SQL server version and the year it was developed: Year 1987 1988 1989 1990 Description It was release for UNIX platform
Microsoft, Sybase and Aston Tate release SQL server to OS/2 Microsoft, Sybase and Aston Tate release SQL server 1.0 for OS/2

Server 1.1 is released with support for Windows 3.0 clients. Aston-Tate development. drops out of SQL Server

1991

Microsoft and IBM end joint development of OS/2.

1992

Microsoft SQL Server 4.2 for 16-bit OS/2 1.3 is released. Microsoft and Sybase port SQL Server to Windows NT.

1993

Windows NT 3.1 is released. Microsoft and Sybase release version 4.2 of SQL Server for Windows NT.

1994

Microsoft and Sybase co-development of SQL Server of. cially ends. - Microsoft continues to develop the Windows

version of SQL Server. - Sybase continues to develop the UNIX version of SQL Server. 1995 1996 1998 2000 2001 Microsoft releases version 6.0 of SQL Server. Microsoft releases version 6.5 of SQL Server. Microsoft releases version 7.0 of SQL Server. Microsoft releases SQL Server 2000. Microsoft releases XML for SQL Server Web Release 1 (download). 2002 Microsoft releases SQLXML 2.0 (renamed from XML for SQL Server). Microsoft releases SQLXML 3.0. 2005 Microsoft releases SQL Server 2005 on November 7th, 2005. 2008 Microsoft releases SQL Server 2008 on August 6th 2008. 2010 Microsoft releases SQL Server 2008 R2 on April 21st 2010.

SQL Server 2005 The SQL Server 2005,was released on October 2005,it was codenamed(Yukon),it was released based on the features lacking in SQL Server 2002.its main aim was to manage XML data in addition to relational data. For this main reason the SQL Server 2005 was describes as an XML data type, which can be used as data type for columns or for queries.[11] Common language runtime(CLR)was the main feature in SQL server 2005,where by a user of the system can write codes as managed code, this are the codes that are being executed as by the common language runtime. Also the SQL Server 2005, added a feature that was not there in SQL Server 2002.where by the embedded Queries are being allowed to run, with the help of a Common Language runtime.

SQL server 2008 It was from SQL Server 2008, that the latest version of the SQL was attained.SQL Server 2008 was released by Microsoft on august 6th 2008, its main aim was to make data management selftuning, self organizing, and self maintaining with the development of SQL Server Always On technologies. SQL Server 2008, have data types that are not present on the other versions of the server, some of its data type are specialized date and time types and a spatial data type for location-dependent data. [12] Also the SQL Server 2008,the structured data and the metadata are stored in the SQL server database, whereas the unstructured data components are stored in the file system, so that file can be accessed using both Win32 and APIs SQL Server 2010. Oracle server R2, is the latest version of the SQL server, it was formally known with the codename (SQL Server Kilimanjaro aka KJ), this SQL server was released to the public at April 21, 2010.
[13]

SQL Server R2 adds certain features that are not present in SQL Server

2008.including a Master Data Management regarded as Master Data services.

5.O Activity Covered University database. A university (UCSI University), wants you to create a database for them that would be able to take care of their data storage, each campus has many departments, each departments has many lectures, a lecturer can be able to take more than one subject, there can be more than one course that has more than one similar subjects, one student can take many subjects.

5.1 ER model for UCSI University database

CAMPUS

HAS

1.* 1

DEPARTMENTS

HAS STUDENTS

has

take

1.*
COURSE

1.*
SUBJECTS

1.* 1
HAS

teach

LECTURERS

1. 1.*
REPORTS

1.*
prerequisite HOD

5.2 Entity relational diagram.

5.3 Create table statement: CAMPUS. CREATE TABLE "CAMPUS" ( "CAMPUS_ID" VARCHAR2(4000) NOT NULL ENABLE, "CAMPUS_NAME" VARCHAR2(4000) NOT NULL ENABLE, "LOCATION" VARCHAR2(4000), CONSTRAINT "CAMPUS_PK" PRIMARY KEY ("CAMPUS_ID") ENABLE ) /
Column Name
CAMPUS_ID CAMPUS_NAME LOCATION

Dat a T ype
VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000)

Nullabl e
No No Yes

Def ault
-

Primar y Key
1 1-3

DEPARTMENT_CAMPUS

CREATE TABLE "DEPARTMENTS_CAMPUS" ( "DEPARTMENT_ID" VARCHAR2(4000), "DEPARTMENT_NAME" VARCHAR2(4000) NOT NULL ENABLE, "HOD" VARCHAR2(4000) NOT NULL ENABLE, "DEPARTMENT_BUDGERT" NUMBER(15,1), "CAMPUS_ID" VARCHAR2(4000), CONSTRAINT "DEPARTMENTS_CAMPUS_PK" PRIMARY KEY

("DEPARTMENT_ID") ENABLE, CONSTRAINT ("CAMPUS_ID") REFERENCES "CAMPUS" ("CAMPUS_ID") ENABLE ) / "DEPARTMENTS_CAMPUS_FK" FOREIGN KEY

Column Name
DEPARTMENT_ID DEPARTMENT_NAME HOD DEPARTMENT_BUDGERT CAMPUS_ID

Dat a T ype
VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) NUMBER(15,1) VARCHAR2(4000)

Nullabl e
No No No Yes Yes -

Def ault

Primar y Key
1 1-5

COURSE

CREATE TABLE "COURSE" ( "COURSE_ID" VARCHAR2(4000), "COURSE_NAME" VARCHAR2(4000), "COURSE_DURATION" TIMESTAMP (6), "JOB_TYPES" VARCHAR2(4000), "DEPARTMENT_ID" VARCHAR2(4000), "CAMPUS_ID" VARCHAR2(4000), CONSTRAINT "COURSE_PK" PRIMARY KEY ("COURSE_ID") ENABLE, CONSTRAINT "COURSE_FK" FOREIGN KEY ("DEPARTMENT_ID") REFERENCES "DEPARTMENTS_CAMPUS" ("DEPARTMENT_ID") ENABLE, CONSTRAINT "COURSE_FK2" FOREIGN KEY ("CAMPUS_ID") REFERENCES "CAMPUS" ("CAMPUS_ID") ENABLE )
/
Column Name
COURSE_ID COURSE_NAME COURSE_DURATION JOB_TYPES DEPARTMENT_ID CAMPUS_ID

Dat a T ype
VARCHAR2(4000) VARCHAR2(4000) TIMESTAMP(6) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000)

Nullabl e
No Yes Yes Yes Yes Yes

Def ault
-

Primar y Key
1 1-6

STUDENT CREATE TABLE "STUDENT" ( "STUDENT_ID" NUMBER(15,1), "STUDENT_NAME" VARCHAR2(4000), "ADDREES" VARCHAR2(4000), "TELEPHONE" NUMBER(15,1), "GENDER" VARCHAR2(4000), "DOB" DATE, "GRADES" VARCHAR2(4000), CONSTRAINT "STUDENT_PK" PRIMARY KEY ("STUDENT_ID") ENABLE )

Column Name
STUDENT_ID STUDENT_NAME ADDREES TELEPHONE GENDER DOB GRADES

Dat a T ype
NUMBER(15,1) VARCHAR2(4000) VARCHAR2(4000) NUMBER(15,1) VARCHAR2(4000) DATE VARCHAR2(4000)

Nullabl e
No Yes Yes Yes Yes Yes Yes

Def ault
-

Primar y Key
1 1-7

LECTURERS CREATE TABLE "lecturers" ( "lecturer_id" NUMBER(15,0) NOT NULL ENABLE, "lecturer_name" VARCHAR2(4000) NOT NULL ENABLE, "lecturer_type" VARCHAR2(4000), "telephone" NUMBER(15,1), "address" VARCHAR2(4000), "subject qualified" VARCHAR2(4000), "department_id" VARCHAR2(4000),

"campus_id" VARCHAR2(4000), CONSTRAINT "lecturers_PK" PRIMARY KEY ("lecturer_id") ENABLE, CONSTRAINT "LECTURERS_FK" FOREIGN KEY ("department_id") REFERENCES "DEPARTMENTS_CAMPUS" ("DEPARTMENT_ID") ENABLE, CONSTRAINT "LECTURERS_FK2" FOREIGN KEY ("campus_id") REFERENCES "CAMPUS" ("CAMPUS_ID") ENABLE ) /
Column Name
lecturer_id lecturer_name lecturer_type telephone address subject qualified department_id campus_id

Dat a T ype
NUMBER(15,0) VARCHAR2(4000) VARCHAR2(4000) NUMBER(15,1) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000)

Nullabl e
No No Yes Yes Yes Yes Yes Yes

Def ault
-

Primar y Key
1 1-8

SUBJECTS

CREATE TABLE "SUBJECTS" ( "SUBJECT_NAME" VARCHAR2(4000) NOT NULL ENABLE, "PREREQUISITE" VARCHAR2(4000), "CLASS_ROOMS" VARCHAR2(4000) NOT NULL ENABLE, "DEPARTMENT_ID" VARCHAR2(4000), "CAMPUS_ID" VARCHAR2(4000), "STUDENT_ID" NUMBER(15,1), "LECTURER_ID" NUMBER(15,1), CONSTRAINT ("SUBJECT_NAME") ENABLE, CONSTRAINT ("DEPARTMENT_ID") "SUBJECTS_FK" FOREIGN KEY "SUBJECTS_PK" PRIMARY KEY
11143605700225 1275970813406

REFERENCES "DEPARTMENTS_CAMPUS" ("DEPARTMENT_ID") ENABLE, CONSTRAINT "SUBJECTS_FK2" FOREIGN KEY ("CAMPUS_ID") REFERENCES "CAMPUS" ("CAMPUS_ID") ENABLE, CONSTRAINT "SUBJECTS_FK3" FOREIGN KEY ("STUDENT_ID") REFERENCES "STUDENT" ("STUDENT_ID") ENABLE, CONSTRAINT "SUBJECTS_FK4" FOREIGN KEY ("LECTURER_ID") REFERENCES "lecturers" ("lecturer_id") ENABLE ) /
11141129549203 16475 11143605700225 1275971153316

Column Name
SUBJECT_NAME PREREQUISITE CLASS_ROOMS DEPARTMENT_ID CAMPUS_ID STUDENT_ID LECTURER_ID

Dat a T ype
VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) VARCHAR2(4000) NUMBER(15,1) NUMBER(15,1)

Nullabl e
No Yes No Yes Yes Yes Yes

Def ault
-

Primar y Key
1 1-7

11141129549203 16475

11143605700225 1275971153316

COURSE_SU BJECT
Column Name
COURSE_ID SUBJECT_NAME LECTURER_ID DEPARTMENT_ID CAMPUS_ID

Dat a T ype
VARCHAR2( 4000) VARCHAR2( 4000) NUMBER(15 ,1) VARCHAR2( 4000) VARCHAR2( 4000)

Nulla ble
Yes Yes Yes Yes Yes

Def a ult
-

Primar y Key
1-5

CREATE TABLE "COURSE_SUBJECT" ( "COURSE_ID" VARCHAR2(4000), "SUBJECT_NAME" VARCHAR2(4000), "LECTURER_ID" NUMBER(15,1), "DEPARTMENT_ID" VARCHAR2(4000), "CAMPUS_ID" VARCHAR2(4000), CONSTRAINT "COURSE_SUBJECT_FK" FOREIGN KEY ("COURSE_ID") REFERENCES "COURSE" ("COURSE_ID") ENABLE, CONSTRAINT "COURSE_SUBJECT_FK2" FOREIGN KEY ("SUBJECT_NAME") REFERENCES "SUBJECTS" ("SUBJECT_NAME") ENABLE, CONSTRAINT "COURSE_SUBJECT_FK3" FOREIGN KEY ("LECTURER_ID") REFERENCES "lecturers" ("lecturer_id") ENABLE, CONSTRAINT ("DEPARTMENT_ID") REFERENCES "DEPARTMENTS_CAMPUS" ("DEPARTMENT_ID") ENABLE, CONSTRAINT "COURSE_SUBJECT_FK5" FOREIGN KEY ("CAMPUS_ID") REFERENCES "CAMPUS" ("CAMPUS_ID") ENABLE ) / 5.4 Insert Statement Campus: 1. insert into campus values('North wing','UCSI UNIVERSITY','CHERAS'); 2. insert into campus values('SOUTH WING','UCSI UNIVERSITY','TAMAN CONNAUGHT CHERAS');
CAMPUS_ID
North wing SOUTH WING

"COURSE_SUBJECT_FK4"

FOREIGN

KEY

CAMPUS_NAME
UCSI UNIVERSITY UCSI UNIVERSITY CHERAS

LOC ATION

TAMAN CONNAUGHT CHERAS

2 rows returned in 0.06 seconds


11141129549203 16477 11143605700225

CSV Export
1275971532764

Departments_campus 1. Insert into Departments_campus Values ('IT','Information Technology','Ms chloe',7000,'SOUTH WING');


DEP ARTMENT_ID
IT

DEP ARTMENT_N AME


Information Technology

HOD
Ms chloe

DEP ARTMENT_BUDGERT
7000

CAMPUS_ID
SOUTH WING

Course 1.insert into course(course_id,course_name,department_id,campus_id) values('hybs','Business information system','IT','SOUTH WING');


COURSE_I D
4hycc hybs

COURSE_NAM E
computing Business information system

COURSE_DUR ATI O N
-

JOB_TYPE S
-

DEP ARTMENT_I D
IT

CAMPUS_I D
SOUTH WING

STUDENT INSERT INTO STUDENT VALUES(1000715597,'EMMANUEL UGOCHUKWU NWABRIJE','NO 20 AKAD

AVENUE',555-768-99,'MALE','8 JUNE,1985','A');
STUDENT_ID
1000715597

STUDENT_N AME
EMMANUEL UGOCHUKWU NWABRIJE

ADDREES
NO 20 AKAD AVENUE

TELEPHONE
-312

GENDER
MALE

DOB
08JUN85

GRADES
A

LECTURERS 1.insert into lecturer Values(7798,'Mr oscar','full time',555-897-435,'angkasa condo','java 1','IT','SOUTH WING');

lect urer _id


7798

lect urer _name


Mr oscar

lect urer _t ype


full time

telephone
-777

address
angkasa condo

subject qualifi ed
java 1

department _id
IT

campus_id
SOUTH WING

SUBJECT 1. INSERT INTO SUBJECT(SUBJECT_NAME,CLASS_ROOMS,LECTURER_ID) VALUES( JAVA 1,CG05,7798);

SUBJECT_N AME
java 1

PREREQUI SITE
-

CLASS_ROOMS
CG05

DEP ARTMENT_ID
-

CAMPUS_ID
-

STUDENT_ID
-

LECTURER_I D
7798

SUBJECT_ COURSE 1. insert into course_subject(COURSE_ID,SUBJECT_NAME) VALUES('hycc','java 1');


COURSE_I D
hycc

SUBJECT_N AME
java 1

LECTURER_I D
-

DEP ARTMENT_ID
-

CAMPUS_ID
-

5.5 PROBLEM SOLVING.

1. Write a query to display the list of student takes java 1. Select student_id, subject_name,class_rooms from subjects Where subject_name IN (select subject_name From subjects where subject_name = 'java 1');
STUDENT_ID
-

SUBJECT_N AME
java 1

CLASS_ROOMS
CG05

2. retrieve all data in the lecturers table?

select* from lecturer;

lect urer _id


7798

lect urer _name


Mr oscar

lect urer _t ype


full time

telephone
-777

address
angkasa condo

subject qualifi ed
java 1

department _id
IT

campus_id
SOUTH WING

3 .display the Date of birth, gender and grades of the student whose id is 1000715597. select student_id,dob,gender,grades from student where student_id= 1000715597;
STUDENT_ID
1000715597

DOB
08-JUN-85

GENDER
MALE

GRADES
A

4.using the union operator to retrieve data from the department_campus table? select department_id,department_name,department_budgert,campus_id from departments_campus union select department_id,department_name,department_budgert,campus_id from departments_campus

DEP ARTMENT_ID
IT

DEP ARTMENT_N AME


Information Technology

DEP ARTMENT_BUDGERT
7000

CAMPUS_ID
SOUTH WING

6.0 Discussion:

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


SQLaccessed 5/24/2010
[2]. D D Chamberlin, R. F. Boyce, 1974(http://www.almaden.ibm.com/cs/people/chamberlin/sequel1974.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

[4]. Chaitanya Koratamaddi and Nancy Greenberg Oracle Database 10g: SQL Fundamentals 1, student guide Vol .1, Data manipulation Language, pp. 8-5 8-20, December 2006 [5]. Chaitanya Koratamaddi and Nancy Greenberg Oracle Database 10g: SQL Fundamentals 1, student guide Vol .1, Data definition Language, pp. 9-8 9-18, December 2006 [6]. Chaitanya Koratamaddi and Nancy Greenberg Oracle Database 10g: SQL Fundamentals 1, student guide Vol .1, Data manipulation Language, pp. 9-24, December 2006 [7]. Chaitanya Koratamaddi and Nancy Greenberg Oracle Database 10g: SQL Fundamentals 1, student guide Vol .1, Data manipulation Language, pp. 9-22, December 2006 [8]. David haertzen, (http://infogoal.com/sql/sql-where.htm)SQL WHERE CLAUSE, JUNE 8, 2010 [9]. Ian Gilfillan,(
http://www.databasejournal.com/features/mysql/article.php/3469351/The-

HAVING-and-GROUP-BY-SQL-clauses.htm) THE HAVING AND GROUP BY CLAUSES

February 8,2005

10]Adam Einsbrg,Jim Melton (http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.114.1085)


Backgroud SQL,1999

[11]. Maud q.vincent (http://e-articles.info/e/a/title/A-Brief-History-of-Microsoft-SQL-Server/) a brief


history of Microsoft SQL.March 3, 2007

[12].J.NicholasHoover,(http://www.informationweek.com/news/windows/microsoft_news/show Article.jhtml?articleID=199500164) Microsoft Gives Peek At Next Version of SQL Server, May 9 2007 [13]. Buck woody, (http://blogs.technet.com/b/sqlserverexperts/archive/2010/04/21/sql-server2008-r2-launches.aspx)SQL SERVER 2008 R2 LUNCHES, April 21, 2010

Das könnte Ihnen auch gefallen