0% found this document useful (0 votes)
7 views45 pages

Unit One

Uploaded by

hayela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views45 pages

Unit One

Uploaded by

hayela
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 45

GOFA INDUSTRIAL

COLLEGE

Web Development and Database Administration


Level-I
DEPARTMENT of ICT

1
Module Title: Access & Use Database
Application
Module code: EIS WDDBA1 M08 0322
Nominal duration: 70 Hour
Access & Use Database Application
 Unit one: Create database objects
 Unit Two: Add record on table
 Unit Three: Customize basic
settings
Unit one: Create database objects
 Database Systems
 Basic Design Principles
 Creating Database Object
 Creating Relationship
Introduction to Database Systems
 A database is an integrated collection of logically
related records or files consolidated into a
common pool that provides data for one or more
multiple uses.
 One way of classifying databases involves the
type of content, for example: bibliographic, full-
text, numeric, and image. Other classification
methods start from examining database models
or database architectures.
 The data in a database is organized according to a
database model. The relational model is the most
common.
Con…
 A Database Management System (DBMS) consists of
software that organizes the storage of data.
 A DBMS controls the creation, maintenance, and use of
the database storage structures of organizations and of
their end users.
 It allows organizations to place control of organization-
wide database development in the hands of Database
Administrators (DBAs) and other specialists. In large
systems, a DBMS allows users and other software to store
and retrieve data in a structured way.
 Database management systems are usually categorized
according to the database model that they support, such
as the network, relational or object model. The model
tends to determine the query languages that are available
Con…
 One commonly used query language for the
relational database is SQL, although SQL syntax
and function can vary from one DBMS to another.
 A great deal of the internal engineering of a
DBMS is independent of the data model, and is
concerned with managing factors such as
performance, concurrency, integrity, and recovery
from hardware failures. In these areas there are
large differences between products.
Database Design Principles
Introduction to MS Access
 MS Access is a database management tool that
enables one to store relevant data. This also has
the capabilities to retrieve, sort, summarize and
report results immediately and effectively.
 It can combine data from various files (tables)
through creating relationships.
Con…
 Microsoft Access (MS Access) enables one to
manage all important information from a single
database file. Within the file, one can use the
different objects:
 Tables -Store your data in your database.
 Queries - Ask questions about information stored
in your tables.
 Forms - A form is a type of a database object that
is primarily used to enter or display data in a
database.
 Reports - Allow you to print data based on
queries/tables that you have created
Con…
 Basic Database Concept: In studying MS Access,
it is but necessary to understand some basic
elements of a database before proceeding to it.
 Database Elements:
 Data are raw facts. It tells the truth about
something; a person, a place, an object, etc.
 Example:
 Name
Girma
“Girma” is a data. “Girma” is my name, so it tells
something about a person. “Girma” is a Name
 Gender “Male” is Girma’s gender. So it tells
Male
something about “Girma”.
Con…
 Information is a collection of data (raw facts)
which is contained in 1 file (table in Access)
ID Number First Name Last Name Gender Birthday Address

 Example: Stud-0001 Girma Abebe Male 11-05-1978 Bishoftu

 This is information about a person named


“Girma”
 Example of a table (file):
ID Number First Name Last Name Gender Birthday Address
Stud-0001 Girma Abebe Male 11-05-1978 Bishoftu
Stud-0002 Sintayehu Kifle Male 21-03-1980 Adama
Stud-0003 Abera Tekeba Male 5-01-1970 Bahirdar
Stud-0004 Tola Asfaw Male 25-12-1982 Jima
Stud-0005 Meron Aschalew Female 8-01-1985 Hawasa
Naming Convention
 It is manner of naming files and variables. Having a poor
naming convention can only add confusion, so it's important
that you start with a good scheme, and think about what
the scheme will mean to you. Here are the three things to
consider in establishing a naming convention:
1. Does my convention make sense to me?
 Must be simple and understandable to you.
2. Will my convention make sense to other people?
 Time will come that other people will look into your database
program, so they must able to understand it.
3. Can I be consistent in implementing and enforcing my
convention?
 All throughout my database work, your naming convention must
not change.
Database Design Principles
 Usability: Any information which we are storing in any
organization should be meaningful for that organization. If we are
storing those factors which are actually not fit with organization’s
requirement then this is just waste of resources.
 Extensibility: As we know that everyday new business
requirements come up and every day there is a need to change
or enhance information system to capture new requirements. So
information design should be extensible so that it can adopt new
requirements without much efforts or without major breaking
changes.
 Data Integrity: Now at this point we understand that information
is very much important for any organization. Based on the
historic information, every organization makes different
strategies, decisions for growth. One small mistake in data can
lead to major issues with any organization’s key decision and
hence a big risk for growth.
Con…
 Entity Integrity: Involves the structure (primary key and its
attributes) of the entity. If the primary key is unique and all
attributes are scalar and fully dependent on the primary
key, then the integrity of the entity is good. In the physical
schema, the table’s primary key enforces entity integrity.
 Domain Integrity: It defines that data should be of correct
type and we should handle optional data in correct way.
We can define proper data types for different attributes
based on organization’s requirement so that correct format
data should present in system.
 Referential Integrity: This defines if any entity is
dependent on another one then parent entity should be
there in the system and should be uniquely identifiable.
We can do this by implementing foreign keys.
Con…
 User defined integrity: There are few business rules which
we cannot validate just by primary keys, foreign keys etc.
There has to be some mechanism so that we can validate
complex rules for integrity. We can implement these rules in
following ways:
 Performance: As we know that information should be readily
available as requested. Performance of the system should be
up to the mark. As data in increasing day by day so at some
time there will be impact on performance if database design
is poor or we’ll not take any actions to improve performance.
 Availability: The availability of information refers to the
information’s accessibility when required regarding uptime,
locations, and the availability of the data for future analysis.
Disaster recovery, redundancy, archiving, and network
delivery all affect availability.
Con…
 Security: For any organizational asset, the level of
security must be secured depending on its value
and sensitivity. Sometime organizations has
suffered a lot because of data leaks which results
in loss of faith and tends to business risk. So
security is one of the most important aspect of
good database design.
Design Process
 Determine the purpose of your database: This helps prepare
you for the remaining steps.
 Find and organize the information required. Gather all of the
types of information you might want to record in the database,
such as product name and order number.
 Divide the information into tables: Divide your information
items into major entities or subjects, such as Products or
Orders. Each subject then becomes a table.
 Turn information items into columns: Decide what information
you want to store in each table. Each item becomes a field, and
is displayed as a column in the table. For example, an
Employees table might include fields such as Last Name and
Hire Date.
Con…
 Specify primary keys: Choose each table’s primary key. The
primary key is a column that is used to uniquely identify each
row. An example might be Product ID or Order ID.
 Set up the table relationships. Look at each table and decide
how the data in one table is related to the data in other tables.
Add fields to tables or create new tables to clarify the
relationships, as necessary.
 Refine your design: Analyze your design for errors. Create the
tables and add a few records of sample data. See if you can get
the results you want from your tables. Make adjustments to
the design, as needed.
 Apply the normalization rules: Apply the data normalization
rules to see if your tables are structured correctly. Make
adjustments to the tables, as needed.
Database Objects
Database Objects
 A database object in a relational database is a data
structure used to either store or reference data. The most
common object that people interact with is the table.
Other objects are indexes, stored procedures, sequences,
views and many more.
 When a database object is created, a new object type
cannot be created because all the various object types
created are restricted by the very nature, or source code,
of the relational database model being used, such as
Oracle, SQL Server or Access.
 What is being created is instances of the objects, such as a
new table, an index on that table or a view on the same
table.
The different type of Database objects
 Tables: - Recently, we define it as a file but
technically, it was defined as a container or a
worksheet-like container where the collection of
data has been stored.
 Tables - A table is a collection of data about a
specific topic, such as products or suppliers
 Basic Component of a Table:
 Meta Data – Database Structure
 Field – Column – Data
 Fieldname
 Record - Row - Information
Con…
 Metadata – is a “data about data” or synonymously called
table structure that defines what type of data your data is?
 Queries –Queries used to view, change, and analyze data in
different ways. You can also use them as a source of records
for forms, reports.
 Forms - A form is a type of a database object that is
primarily used to enter or display data in a database. You
can also use a form as a switchboard that opens other
forms and reports in the database, or as a custom dialog
box that accepts user input and carries out an action based
on the input.
 Reports - A report is an effective way to present your data
in a printed format. Because you have control over the size
and appearance of everything on a report.
Data types in Microsoft Access
 Every field in a table has properties and these
properties define the field's characteristics and
behavior. The most important property for a field
is its data type. A field's data type determines
what kind of data it can store. MS Access supports
different types of data, each with a specific
purpose.
 The data type determines the kind of the values
that users can store in any given field.
 Each field can store data consisting of only a
single data type.
Con…
Common data types in Access
Type of Data Description Size
Short Text Text or combinations of text and numbers, Up to 255 characters.
including numbers that do not require
calculating (e.g. phone numbers).
Long Text Lengthy text or combinations of text and Up to 63, 999 characters.
numbers.
Number Numeric data used in mathematical calculations. 1, 2, 4, or 8 bytes (16 bytes if set
to Replication ID).
Date/Time Date and time values for the years 100 through 8 bytes
9999.
Currency Currency values and numeric data used in 8 bytes
mathematical calculations involving data with
one to four decimal places.
AutoNumber A unique sequential (incremented by 1) number 4 bytes (16 bytes if set to
or random number assigned by Microsoft Access Replication ID).
whenever a new record is added to a table.

Yes/No Yes and No values and fields that contain only 1 bit.
one of two values (Yes/No, True/False, or
On/Off).
Con…
 If you use previous versions of Access, you will
notice a difference for two of those data types.
 In Access 2013, we now have two data types —
short text and long text. In previous versions of
Access these data types were called text and
memo.
 The text field is referred to as short text and your
memo field is now called long text.
Con…
Table 1. 2 Specialized data types in Access
Type of Data Description Size
Attachment Files, such as digital photos. Multiple files can be Up to about 2 GB.
attached per record. This data type is not
available in earlier versions of Access.
OLE objects OLE objects can store pictures, audio, video, or Up to about 2 GB.
other BLOBs (Binary Large Objects)
Hyperlink Text or combinations of text and numbers stored Up to 8,192 (each part of a
as text and used as a hyperlink address. Hyperlink data type can contain
up to 2048 characters).

Lookup Wizard The Lookup Wizard entry in the Data Type column Dependent on the data type of
in the Design view is not actually a data type. the lookup field.
When you choose this entry, a wizard starts to
help you define either a simple or complex
lookup field.
Calculated You can create an expression that uses data from You can create an expression that
one or more fields. You can designate different uses data from one or more
result data types from the expression. fields. You can designate different
result data types from the
expression.
Con…
 These are all the different data types that
you can choose from when creating fields in
a Microsoft Access table.
Create Database Relationship
Table Relationship
 Newcomers to the world of databases often have a hard time
seeing the differences between a database and a spreadsheet.
 They see tables of data and recognize that databases allow you
to organize and query data in new ways, but fail to grasp the
significance of the relationship that gives relational database
technology & its name.
 Relationships allow you to describe the connections between
different database tables in powerful ways. Once you’ve
described the relationships between your tables, you can later
leverage that information to perform powerful cross-table
queries, known as joins.
 A relationship is a logical connection between two tables. Keys
are fields that are part of a table relationship. There are two
kinds of keys
Con…
Primary key
 A table can have only one primary key. A primary
key is used to identify each record that you store
in the table. It will not allow a duplication of the
Primary Key thus make it unique. Primary Key is
the unique identification of one record. There is a
uniquely identification number, such as
 ID number
 A serial number
 A code that serves as a primary key
Con…
Foreign key
 A table can also have one or more foreign key. A
foreign key contains values that correspondent to
values in the primary key of another table.
 You use table relationship to combine data from
related table.
Con…
Types of Database Relationships
One to One Relationship
 In a one-to-one relationship, each row in one
database table is linked to 1 and only 1 other row
in another table.
 In a one-to-one relationship between Table A and
Table B, each row in Table A is linked to another
row in Table B.
 The number of rows in Table A must equal the
number of rows in Table B.
 To illustrate the one-to-one relationship consider
the sample table design and data below:
Con…

Customer name table

cust_id (primary key - link to cust_id of customer details table)


first name
last name

Customer details table


cust_id (primary key - link to cust_id of customer name table)
height
weight
date of birth
Con…
cust_id firstname last name cust_id height weight dateofbirth

0001 Abebe Tekalign 0001 181 75 03/05/1960

0002 Sintayehu Balcha 0002 179 82 06/08/1974

0003 Kebede Daba 0003 171 65 04/01/1955

0004 Simehar Belay 0004 185 93 05/05/1980

0005 Makida Teka 0005 168 71 09/09/1975


Con…
 Notice that each row in the customer name table is
related to 1 and only 1 other row in the customer details
table.
 Similarly, each row in the customer details table is
related to 1 and only 1 other row in the customer name
table.
 However, if you think about it carefully, the above
relationship does not really bring any design benefits.
 In fact, it would cause performance overheads to the
database engine for having to link the table rows
together to service user queries related to customers.
 The 2 tables can actually be combined into a single table
as illustrated below:
Con…

Customer name table


cust_id
First name
last name
height
weight
date of birth
Con…

cust_id firstname last name height weight dateofbirth

0001 Abebe Tekalign 181 75 03/05/1960

0002 Sintayehu Balcha 179 82 06/08/1974

0003 Kebede Daba 171 65 04/01/1955

0004 Simehar Belay 185 93 05/05/1980

0005 Makida Teka 168 71 09/09/1975


Con…
 However, there are some situations in which the
one-to-one relationship may improve
performance.
 For our example above, if the height, weight and
date of birth columns are rarely used, it may
make sense to separate them out into a separate
database table that is linked to the original table
using a one-to-one relationship.
 This would reduce the overhead needed to
retrieve the height, weight and date of birth
columns whenever a query is performed on the
last name and first name fields.
One to Many Relationships
 In a one-to-many relationship, each row in the related
to table can be related to many rows in the relating
table.
 This allows frequently used information to be saved
only once in a table and referenced many times in all
other tables.
 In a one-to-many relationship between Table A and
Table B, each row in Table A is linked to 0, 1 or many
rows in Table B. The number of rows in Table A is
almost always less than the number of rows in Table
B.
 To illustrate the one-to-many relationship consider
the sample table design and data below:
Con…

Authors table Books table

author_id (primary book_id (primary key)


key) title
first name author_id (foreign key - link to
last name author_id of author table)
Con…

author_id first name last name book_id title author_id

b1 a database primer 0001


0001 Abebe Tekalign
b2 building data 0001
0002 Sintayehu Balcha warehouse
b3 teach yourself sql 0001

0003 Kebede Daba


b4 101 exotic recipes 0002

0004 Simehar Belay b5 visiting ethiopia 0003


Con…
 Notice that each row in the authors table is related to
0, 1 or many rows in the books table. This makes
intuitive sense because an author can write 0, 1 or
more than 1 books.
 In our example above, Aebe tekalign has written 3
books, Sintayehu balacha has written 1 book, Kebede
daba has written 1 book and Simhar belay has not
written any books.If you notice carefully, the above
relationship between the authors table and the books
table is a one-to-many relationship.
 Turning around, the relationship between the books
table and the authors table is a many-to-one
relationship.
Many to Many Relationships
 In a many-to-many relationship, one or more
rows in a table can be related to 0, 1 or many
rows in another table.
 In a many-to-many relationship between Table A
and Table B, each row in Table A is linked to 0, 1
or many rows in Table B and vice versa.
 A 3rd table called a mapping table is required in
order to implement such a relationship.
To illustrate the many-to-many relationship
consider the sample table design for a bank
below:
Con…

Customers table Products table Mapping table


cust_id (primary key)
product_id (primary cust_id
last name
key)
first name
name
product_id
Con…
 Assume that the bank has only 2 customers and 2
products:
Customer Table
cust_id firstname last name

0001 Abebe Tekalign


0002 Sintayehu Balcha

Products Table
product_id Name

P0001 Savings

P0002 credit card


CON…
Mapping Table
cust_id product_id

0001 P0001
0001 P0002
0002 P0002

 Notice from the mapping table, Abebe tekalign has 2


facilities with the bank - a Savings account and a Credit
Card. Also, notice that both the customers own Credit
Cards issued by the bank. This means that with the way
the database tables are designed:
 One customer can have 0, 1 or many products
 One product can be owned by 0, 1 or many customers

You might also like