Download database - Home - portalsainskomputerperak

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

DBase wikipedia , lookup

Commitment ordering wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Serializability wikipedia , lookup

Btrieve wikipedia , lookup

Microsoft Access wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Oracle Database wikipedia , lookup

IMDb wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Ingres (database) wikipedia , lookup

Functional Database Model wikipedia , lookup

Concurrency control wikipedia , lookup

Database wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

ContactPoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
DATABASE
6.2
Basic Concept of Database
Learning Outcome
At the end of this topic,
students should be able to:
1. explain the basic concepts of database
1
DATABASE
6.2
Basic Concept of Database
2
DATABASE
6.2
Basic Concept of Database
3
DATABASE
6.2
Basic Concept of Database
Data Hierarchy
4
DATABASE
6.2
Basic Concept of Database
●
Data Hierarchy
–
refers to the organization of data in a database.
●
table/s or file/s
●
record/s (in rows)
●
field/s (in columns)
●
character
5
DATABASE
6.2
Basic Concept of Database
●
Data Hierarchy
–
a database contains one or more
tables. A table contains a number of
records. A record contains one or
more fields.
6
DATABASE
6.2
Basic Concept of Database
●
Data Hierarchy
–
a database files stored on disk (usually
stored in the form of tables) , each files
has its own records and each records
has its own fields.
7
DATABASE
6.2
Basic
Concept
of
Database
6.2 Basic Concept of Database
Adding new contact in
Samsung Galaxy S III
DATABASE
6.2
Basic Concept of Database
1
1●
touch on the Apps icon
–
2●
The one with rectangle grid
touch on Contact icon
2
DATABASE
6.2
Basic Concept of Database
3
5
4
5
3
touch on plus
symbol
(+) to open up
a new Create
contact screen
4
User will able to see the Create
contact screen, and fill in the
Name’s field and etc
and user have
the option to
add another
field, such as
Mobile, Home,
Address, Email’s
field and etc
DATABASE
6.2
Basic Concept of Database
6
Explains
•
6
touch on Save to
keep the new
contact (that
you’ve just
added) in your
phone
•
•
Contact Management features in any
mobile phone is an example of database
in your device (because it is an organized
collection of data – your friend’s contact
number stored in your phone)
Create contact enable you to see many
field (NAME, MOBILE, HOME .. ) – in that
case it is a table with a lot of fields
(depends on user to add or to remove
fields)
When you Save, you actually saving – a
record in your phone.
DATABASE
6.2
Basic Concept of Database
Contact Management features in any mobile
phone is an example of database in your
device (because it is an organized collection of
data – your friend’s contact number stored in
your phone)
Create contact enable you to see many field
(NAME, MOBILE, HOME .. ) – in that case it is
a table with a lot of fields (depends on user to
add or to remove fields)
When you Save, you actually saving – a record
in your phone.
DATABASE
6.2
Basic Concept of Database
TABLE
•
•
•
•
also known as database
file/s.
organized data in rows
and columns.
contain fields (column)
and records (row).
Data file – collection of
related records, stored in
any available storage
medium.
RECORD
•
•
•
•
also known as rows.
Contains data values
(name for a person, of a
product, an ID for
student).
a collections of related
fields in a database.
also represent a data
attributes (describing an
entity).
FIELD
•
•
•
•
•
also known as a columns
contains a specific
category of data within a
record.
single category of data to
be stored in database.
field name – uniquely
identifies each field.
field size – defines the
maximum of characters a
field can contain.
13
DATABASE
6.2
Basic Concept of Database
Table
14
DATABASE
6.2
Basic Concept of Database
15
DATABASE
6.2
Basic Concept of Database
Field
16
DATABASE
6.2
Basic Concept of Database
Data Dictionary
and
Data Type
17
DATABASE
6.2
Basic Concept of Database
a *repository in database,
contains data about files in the
database and each field in those files
- Shelly & Vermaat, 2012
DATABASE
6.2
Basic Concept of Database
a *repository in the form
of book,
contains visual data and
information about certain
topics – SeAm 2014
DATABASE
6.2
Basic Concept of Database
List 3-4 examples of data
that can be extract from
student.
Imagine you are at the bus stop,
suddenly one female student that
you’ve already admire, walk to the bus
stop and sit near you. Ok man, what
will you do ?
NAME
PHONE NUMBER
CLASS
STATUS
DATABASE
6.2
Basic Concept of Database
Microsoft Access 2007
Table Design View
Table Design View is Data Dictionary for MS Access 2007
DATABASE
6.2
Basic Concept of Database
Microsoft Access 2007
Table Design View
1
2
Data Dictionary
has a field name
for DBA to set a
name for
specific field
and for each
Field Name
DBA need to set
the type of data
(data values) for
the field name
3
Descriptions is
a brief
information
about field
name
Table Design View is Data Dictionary for MS Access 2007
DATABASE
6.2
Basic Concept of Database
Microsoft Access 2007
Table Design View
Data Type (in database) - specifies the kind of
data a field can contain and how the field is
used
DATABASE
6.2
Basic Concept of Database
DATA TYPE
DESCRIPTIONS
Text
store data that is not manipulated arithmetically
Number
store numeric data, arithmetically can be manipulated (integer, decimal –
are available)
Currency
special for numeric data that represents money (output with currency
signs, decimal points and commas.)
Yes/No
store logical data, can only contains one from two-values (often appear as
checkboxes)
Date/Time
store dates and times as values, can be sorted, added, or manipulated (has
several formats to choose from)
Memo
store large block of text, can’t be arithmetically manipulated or compared,
but can be edited and displayed.
Hyperlink
store hyperlinks to web pages, email addresses, or even a files.
Attachment
contains images, documents, other types of files supported by the DBMS
program being used.
List of Data Type commonly available in MS Access 2007
DATABASE
6.2
Basic Concept of Database
Primary Key
and
Foreign Key
25
DATABASE
6.2
Basic Concept of Database
Microsoft Access 2007
Primary Key in
Table Design View
Primary Key field in
Table View
26
DATABASE
6.2
Basic Concept of Database
Microsoft Access 2007
Primary Key in
Table Design View
Primary Key (in database) – a field, uniquely
identifies each record in a file.
•
•
•
also known as a key field
data (in the field) is unique.
can be used to integrate data in database.
27
DATABASE
6.2
Basic Concept of Database
Primary Key (PK) (in database) – should
follow the listed rules (in order to use it in
database)
•
•
•
Primary Key’s Symbol in
Microsoft Access 2007
PK must contain a value – that is must be declared
(NOT NULL).
PK value must be unique for each record (row).
PK value must no change or become NULL
Benefits of using primary key (in database) ;
• ensuring there’s no duplicate records in
database.
• preventing a NULL value being entered in
unique field.
28
DATABASE
6.2
Basic Concept of Database
Foreign Key (in database) – a field in
relational table, that matches primary key
column of another table.
Explains
1
2
1
1st Table
2 2nd Table
3
3
Relational /
Relationships
Line
Connecting 1st
and 2nd Table
Example of Relational Table in
Microsoft Access 2007
29
DATABASE
6.2
Basic Concept of Database
•
Foreign Key (in database) – a field in
relational table, that matches primary key
column of another table.
From the image, there are 2 tables. #1
Contact_Samsun.. And #2 is Hostel Info.
Both has been connected, thus makes the
table is a relational table.
•
In Table #1, Contact_Samsun… , field
Matric_Num is the PK , and there are not
Foreign Key in table 1.
•
In Table #2, Hostel Info, field Room Num is
the PK (for that table), and Matric_Num
is the Foreign Key (because it matches
primary key form another table ,Table #1).
Example of Relational Table in
Microsoft Access 2007
Remember !
Explains
30
DATABASE
6.2
Basic Concept of Database
Conclusions
Example of Relational Table in
Microsoft Access 2007
Remember !
A foreign key (sometimes called a
referencing key) is ;
• key used to link two tables
together.
• taking primary key field from
one table and insert it into
the other table (where it
becomes a foreign key ).
Foreign Key (in database) – a field in
relational table, that matches primary key
column of another table.
31
DATABASE
6.2
Basic Concept of Database
32
DATABASE
6.2
Basic Concept of Database
33
DATABASE
6.2
Basic Concept of Database
Primary Key & Foreign Key
Differences of primary key and foreign key;
primary can contain only unique value while foreign key
may contain duplicate value.
Importance of relationship between the Primary Key
and Foreign Key
● the primary key of one table becomes a foreign of other
table (by matching a foreign key with a primary key, there
is no need to enter data repeatedly)
● making the process (query, form, reports) easier.
● improves data performance by relating smaller tables
into meaningful databases.
34
DATABASE
6.2
Basic Concept of Database
Entity Relationship
a data model that describes data and
information, implemented in a relational
database.
35
DATABASE
6.2
Basic Concept of Database
Entity
Relationship
•
something of importance to the
organization.
•
an association between data that's
stored in different record types.
•
entities that the organization wants to
store data about typically becomes a
database table.
•
important because typically describes
an association between two or more
entities.
•
Cardinality
person, place, object, event or
concept in the user environment
• important aspect of the relationship
about which the organization wishes
between record types.
to maintain data.
• number of associations that can exist
“thing” or object that contain data.
between two record types.
represented by a rectangle in E-R
Attributes
(entity-relationship) diagrams
• characteristic of an entity.
•
•
•
property of an entity set
36
DATABASE
6.2
Basic Concept of Database
TERM
EXAMPLES
Entity (a noun)
Product, Name, Book, Student, Model,
Lecturer, Staff.
Relationship (a verb)
order, register, claim, enroll, pay.
Cardinality (type of relationship)
One-to-One (1:1)
One-to-Many (1:M)
Many-to-One (M:1)
Many-to-Many (M:N)
Attribute (entity’s property)
product_serial_num,
product_price,
product_name,
37
DATABASE
TERM
DIAGRAM SYMBOL
Entity (a noun)
rectangle/square
Relationship (a verb)
a diamond shape
Cardinality (type of
relationship)
writing type of relationship on each relationship lines
1
1
example : one-to-one, 1:1
Attribute (entity’s
property)
an oval shape
38
DATABASE
6.2
Basic Concept of Database
Identify
•
•
•
•
Example of ER-Diagram
(Entity-Relationship Diagram)
How many entity are
there in the ER-diagram
?
Which entity has the
most attributes ?
List the attributes for
entity label Mark
What is the
relationship between
Student and Teacher ?
39
DATABASE
6.2
Basic Concept of Database
Types of Entity-relationships (Cardinality) in database
One-to-One (1:1)
One-to-Many (1:M)
Many-to-One (M:1)
Many-to-Many (M:N)
a record in one record
type is related to one
record in another record
type
when one record is
related to many records
(and vice versa)
multiple record in a
particular record type can
be related to many
records in another record
type, and vice versa
1
1
M
1
M
M
N
1
40
DATABASE
6.2
Basic Concept of Database
Example 1
2 entity, Teacher and Subject, the
relationship is supervise,
Cardinality is 1:1
1
Teacher
1
Example 2
2 entity, Student and Module, the
relationship is enroll,
Cardinality is 1:1
1
Student
Subject
supervise
1
enroll
Module
41
DATABASE
6.2
Basic Concept of Database
Example 1
Football
Team
2 entity, Football Team and Player,
the relationship is join,
Cardinality is 1:M
1
M
Example 2
2 entity, Person and Location,
the relationship is birthplace,
Cardinality is M:1
M
Person
Player
join
1
birthplace
Location
42
DATABASE
6.2
Basic Concept of Database
Example 1
2 entity, Book and Author,
the relationship is written,
Cardinality is M:N
M
Book
N
Example 2
2 entity, Student and Course,
the relationship is register,
Cardinality is M:N
M
Student
Author
written
1
register
Course
43