Database Concepts
Database Concepts
DATABASE CONCEPTS
This tutorial will introduce you to the following things:
so forth.
Advantages
Reduced data redundancy.
Reduced updating errors and increased consistency.
Greater data integrity and independence from applications
programs.
Improved data access to users through use of host and query
languages.
Improved data security.
costs.
Damage to database affects virtually all
application programs.
Extensive conversion costs in moving form a
and users.
HOW IS A DATABASE ORGANIZED BY MS OFFICE ACCESS?
Number Numeric values, such as distances. Note that there is a separate data type for currency.
Yes/No Yes and No values and fields that contain only one of two values.
OLE Object Pictures, graphs, or other ActiveX objects from another Windows-based application. Hyperlink
Text or combinations of text and numbers stored as text and used as a hyperlink address.
Attachment Images, Spreadsheet files, documents, charts, and other types of supported files attached to the records in your
database, similar to attaching files to e-mail messages.
Calculated Results of a calculation. The calculation must refer to other fields in the same table. You would use the
Expression Builder to create the calculation.
Lookup Wizard Displays either a list of values that is retrieved from a table or query, or a set of values that you specified when
you created the field. The Lookup Wizard starts and you can create a Lookup field. The data type of a Lookup
field is either text or number, depending on the choices that you make in the wizard.
DATABASE RELATIONSHIPS
1) One-to-One
2) One-to-Many (or Many-to-One)
3) Many-to-Many
ONE-TO-ONE
DML commands
Manipulate and query data in existing
tables.
Example
1. CREATE TABLE student(sid NUMBER PRIMARY KEY NOT
NULL,
snameVARCHAR2(20),
sex CHAR(1),
bdate DATE);
2. CREATE TABLE department(did NUMBER,
dnameVARCHAR(20),
PRIMARY KEY(did));
MODIFY TABLE STRUCTURE
datatype
Example.
ALTER TABLE department ADD faculty
varchar(20);
TO REMOVE AN ATTRIBUTE/ COLUMN
‘01-aug-2000’,001);
Don’t forget
To insert data first to the referenced table and
Sorting Data
SELECT* FROM student ORDER BY name;
Special Characters:
_ Used to match any single character.
% Used to match an arbitrary number of
characters.
Select * from student where sname like ‘%j’;
Select * from student where sname like ’Abeb_’;
DELETE RECORD
Ex.
DELETE FROM student WHERE name =
‘Abebe’;
DROP TABLE
Logout SQL
SQL> quit;
AGGREGATE FUNCTIONS
Very top-level
Min:- finds the smallest value in a group
Max:- finds the largest value in a group
Avg:- returns the average value for the specified
column of a group
Sum:- totals a specific column for a group
Count:- counts all the item in a group
Ex.
Select min(sal) From emp;
Select max(sal)-min(sal) From emp;
LET’S GO TO PRACTICE!