Data M odel4 A data model is a “description” of both a container for data and a methodology for storing and retrieving data from container.. The Relational Database• “A DBMS that manages
Trang 1GLOBAL SOFTWARE TESTER
Trang 2LI (Know-How) Topics - 4 d ay s 2
BasicTech/SQL4T - 4d 2
L2 (Industry Readiness) Topics - 22 days 3
Processi/SWR - I d 3
Process 1/Extra - I d 3
MockProjectl - 1 I d 3
Automation test - 2 5h 3
MockProject2 - 9 d 3
!
Trang 3immediately without company’s training For more details, please visit us at www.career.fsoft- software.com.
This document describes all modules in Global Software Talent program for software tester
- Know Test plan structure; understand objective of each part and which part should be focus as a test team member
- Can study software requirement, get acquainted with and know how to ask questions to clarify requirement
- Write good test cases and effective defects
- Know how to report working progress and write test report
- Know what is automation test? Why automation test? When we use automation test? Automation test scripting techniques
Training program
Trang 6Data M odel
4 A data model is a “description” of both a container for
data and a methodology for storing and retrieving data
from container
*4 “you can think of a data model as the infrastructure of the
data organizations, in other words, the way data is
presented to the user.”
Data model is
❖ Not a thing
❖You cannot touch it
❖ Data model are abstractions, mathematical algorithms &
Concepts
❖You can not touch a data model
Database Systems Models
Data base management systems follow particular
models (known as database models) to store and
manipulate
data A data base model is characterized by:
1 The way it stores data : S T R U C T U R E
2 The way data in the
structure are manipulated: O P E R A T IO N S
Trang 7The Relational Database
• “A DBMS that manages data as collection of
tables in which all data relationships are
represented by common values in related
tables.”
• “A DBMS that follows all the twelve rules of
CODD is called RDBMS”
Trang 8Tuple
s
Primary Key
* Attribute Value Set
Values currently contained in an attribute
« Relation I Table Degree:
Number o f attributes in a relation / table
« Tuples: Rows in a table / relation
« C a rd in a lity: Number of tuples in a relation / table
Trang 9Ex: Instance of Students Relation
■ Do all values in each column of a relation instance have to be distinct?
Relational Database Concepts
Artist Pink Floyd
Field
Trang 10STUDENT Name 1 SSN HomePtione Address OfliœPtoe Age GPA
/ * ■ Benjamin Bave»? Ị 305-61-2435 373-1616 2918 Bluebonnet Une nul 19 3.21
rows, of the table.
if no data exists for the relation
Trang 11Hardware and Software
requirements are High
UNIX,VAX,VMS, etc
Examples are dBase, FOXBASE,
Examples are ORACLE,
JM GRESS, SQL Server 2000 etc
Trang 12• Database design is the process of producing a detailed
data model of a database
• P rocess o f Database Design:
- Determine the relationships between the different
data elements
- Superimpose a logical structure upon the data on the
basis of these relationships
Database designs also include ER (Entity-relationship
model) diagrams
An ER diagram is a diagram that helps to design
databases in an efficient way
Trang 14Entity Relationship Modeling
Sample E-R Diagram
Entity Relationship Modeling
Basic E-R Notation
Multivalued attribute Attribute
symbols , Derived attribute
Trang 15Entity Relationship Modeling
Attributes
• Attribute - property or characteristic o f an entity type
• Classifications o f attributes:
- Simple versus Composite Attribute
- Single-Valued versus Multivalued Attribute
- Stored versus Derived Attributes
- Identifier Attributes
Entity Relationship Modeling
Identifiers (Keys)
• Identifier (Key) - An attribute (or combination of
attributes) that uniquely identifies individual
instances of an entity type
• Simple Key versus Composite Key
• Candidate Key - an attribute that could be a
key satisfies the requirements for being a key
• Characteristics of Identifiers:
- Will not change in value
- WII not be null
- No intelligent identifiers (e.g containing locations or people that might
change)
- Substitute new, simple keys for long, composite keys
Trang 16Entity Relationship Modeling
A composite attribute
■H
Entity Relationship Modeling
Simple key attribute
- ■ :: : _
Trang 17exactly one related entity
• One - to - Many: An entity on one side of the relationship can have many related entities, but an entity on the other side will have a maximum of one related entity
• Many - to - Many: Entities on both sides of the relationship can have many related entities on the other side
Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity
• Minimum Cardinality
- If zero, then optional
- If one or more, then mandatory
• Maximum Cardinality: The maximum number
Optional (zero or one)
Trang 18Entity Relationship Modeling
ER Model - Convert ER Models
to Relational schema (DB Design)
Rules for converting ER Model to
relational schema
• Basic Conversion Rules
• Entity Type Rule
• 1-M Relationship Rule
• M-N Relationship Rule
• Identification Dependency Rule
Trang 19ER Model: DB Design Rule 2 - Example
v " y
Multivalued attribute becomes a
separate relation with foreign key
Trang 20ER Model: DB Design Rule 3 - Example
Trang 21ER Model: DB Design Rule 3 - Example
EMPLOYEE entity with
EMPLOYEE relation with
recursive foreign key
EMPLOYEE
Convert Unary relationship one to many
ER Model: DB Design Rule 3 - Example
Trang 22ER Model: DB Design Rule 3 - Example
î FPT
to ^rnan
ER Model: DB Design Rule 3 - Example
A _
The Supplies
relationship will need to become a separate relation
Trang 23ER Model: DB Design Another Converting Example
Trang 24• Bad database designs results in:
- redundancy: inefficient storage
- anomalies: data inconsistency, difficulties in
maintenance
• Normalization is the process of efficiently
organizing data in a database with two goals:
- First goal: eliminate redundant data
• for example, storing the same data in more than one
table
- Second Goal: ensure data dependencies make sense
• for example, only storing related data in a table
Normalization Benefits o f Normalization
• Less storage space
• Quicker updates
• Less data inconsistency
• Clearer data relationships
• Easier to add data
• Flexible Structure
Trang 25Normalization Update Anomalies
Relations that have redundant data may have
problems called update anomalies, which are
To insert a new staff with branchNo B007 into the
Trang 26Normalization Update Anomalies - Example 2/2
Staff
s t a f f N o s N a m e p o s itio n s a la r y b r a n c e N o
between attributes in a relation
For example, if A and B are attributes of relation R, and B
is functionally dependent on A ( denoted A B), if each
value of A is associated with exactly one value of B ( A
and B may each consist of one or more attributes.)
Trang 27Normalization Functional Dependencies 2/7
Trival fu n c tio n a l dependency means that the right-hand
side is a subset ( not necessarily a proper subset) of the left-
hand side
For example: (See Figure 1)
staffNo, sName -> staffNo They do not provide any additional information about possible integrity
constraints on the values held by these attributes.
because they represent integrity constraints for the relation.
Normalization Functional Dependencies 3/7
Main characteristics of functional dependencies in
normalization
• Have a one-to-one relationship between attribute(s) on
the left- and right- hand side of a dependency;
• hold for all time;
• are nontrivial
Trang 28F u n ctio na l d e pe ndency is a property of the meaning or
semantics of the attributes in a relation When a
functional dependency is present, the dependency is specified as a
c o n s tra in t between the attributes.
An important integrity constraint to consider first is the
id e n tific a tio n o f candidate keys, one o f w h ic h is
selected to be the p rim a ry key for the relation using
functional dependency
Normalization Functional Dependencies 5/7 Inference Rules
A set of all functional dependencies that are implied by a given set of functional dependencies X is called closure
of X, written X+ A set of inference rule is needed to
Decomposition: If A -> B,C then A -> B and A-> C
Union: If A -> B and A -> C, then A-> B,C
C o n ^ ^ ^ U g m ^ ^ A - ^ B and C -> D then A.C-> B,
Trang 29Normalization Functional Dependencies 6/7 Minial Sets o f Functional Dependencies
A s e t of functional dependencies X is m inim al if it satisfies
the following condition:
• Every dependency in X has a single attribute on its right-
hand side
• We cannot replace any dependency A -> B in X with
dependency C ->B, where C is a proper subset of A,
and still have a set of dependencies that is equivalent to
X
• We cannot remove any dependency from X and still
have a set of dependencies that is equivalent to X
Normalization Functional Dependencies 7/7 Example of A Minial Sets o f Functional
Dependencies
A set of functional dependencies for the StaffBranch
relation satisfies the three conditions for producing a
Trang 30Normalization The Process o f Normalization
Normalization is often executed as a series of
steps Each step corresponds to a specific
normal form that has known properties.
As normalization proceeds, the relations become
progressively more restricted in format, and also
less vulnerable to update anomalies.
For the relational data model, it is important to
recognize that it is only first normal form (1NF)
that is critical in creating relations All the
subsequent normal forms are optional.
Normalization
First Normal Form - 1 N F
structure
• Rules
• Define the data items required, because they
become the columns in a table Place related
data items in a table.
• □ Ensure that there are no repeating groups of
data.
• □ Ensure that there is a primary key.
Trang 31Normalization 1NF Example
Trang 32Normalization 1NF Disadvantage
Các bất thường của quan hệ ở 1NF
► Thêm vào
• Không thể thêm thông tin của sinh viên mới có mã là
S4, ten là Thành, thuọc lớp có mã là L í nếu sinh viên
này chưa đăng ký học môn học nào cả
► Cập nhật
• Sửa tên của sinh viên có tên là Tiến với tên mới là
Thành sẽ phải sửa tất cả các hàng của sinh viên này.
► Xóa bỏ
• Xộa thông tin sinh viên S3 đăng ký môn học M1 sẽ làm
mất thông tin của sinh viên này~
Second Normal Form - 2NF
table is either dependent on the whole of a candidate
key, or on another non prime attribute
Trang 33Normalization 2NF Example
Lưọ'c đồ quan hệ R không ờ 2NF vì thuộc tính không khóa Họtên phụ
thuộc hàm riêng phần vào khóa {Mãsv, Mônhọc}.
Normalization 2NF Example
Khóa của Ri: Mãsv
đều phụ thuộc hàm đầy đủ vào khóa.
Trang 34Normalization 2NF Disadvantage
❖ Các bất thuửng của quan hệ ở 2NF
► Thêm vào
• Không thể thêm thông tin của lớp L3 có tên là MT03
nếu chưa có sinh viên nào học lớp này
► Cập nhật
• Sửa tên của lớp có mã /.í với tên mới là MT_1 sẽ phải
sửa tất cả các hàng của lớp này
Trang 35Normalization 3NF - Example
Lược đồ quan hệ Rì không ở 3NF vì thuộc tính không khóa Tért/óp
phụ thuộc bắc cầu vào khóa Mãsv.
Mẵlớp -/-> Măsv Tênióp Ể {Mãsv, Mălớp}
Normalization 3NF - Example
Khóa của R12: Mãsv
đều không phụ thuộc bắc cầu vào khóa.
Trang 36Paymentl Amount: currency
Paymentl Type: ehar(4)
Paymentl Description; chai{40i
Trang 37Normalization - 2NF
Trang 38D on’t d e sig n a database th a t copes w ith th e norm
C hoose m ea nin g fu l nam es fo r tables and fie ld s.
T ry to keep nam es sim ple
Be c o n s is te n t in y o u r nam ing and ch o ice o f data
type.
A nalyze y o u r data needs on paper firs t.
P ick y o u r p rim a ry key ca re fu lly.
Create an index
A d d a m u ltic o lu m n index.
A v o id u sin g reserved w o rd s as table o r fie ld names
C o n sid e r storage space requirem ents.
Q & A
_ _
Trang 39Question 1
Consider the following relations for a database that keeps track of student enrollment in courses and the books adopted for each course (Primary Key is mark post-fix with #):
STUDENT(SSN#, Name, Major, Bdate)
COURSE(Course#, Cname, Dept)
ENROLL(SSN, Course#, Quarter, Grade)
BOOK_ADOPTION(Course#, Quarter, BookJSBN)
TEXT(Book_ISBN#, Book_Title, Publisher, Author)
Draw a relational schema diagram specifying the foreign keys for this schema
rotation
Please:
Trang 40□ Data Definition Language (DDL)
□ Data Manipulation Language (DML)
Trang 41• Primary function is to store and retrieve data as requested by other software applications.
• Query Analyzer: one of the Ms SQL Server that:
- Allows us to write queries and SQL statements
- Checks syntax of the SQL statement written
- Executes the statements
- Store and reload statements
- Save the results in file
- View reports (either as grid or as a text)
Integer : Stores whole number
Float : Stores real numbers
Text : Stores characters
Decimal : Stores real numbers
Money : Stores monetary data Supports 4 places
after decimalDate : Stores date and time
Binary : Stores images and other large objects
Miscellaneous : Different types special to SQL Server (Refer to notes for more info)
Trang 42SQL (Structured Query Language) is the standard for
relational database management systems (RDBMS)
SQL-92 and SQL-99 Standards - Purpose:
- Specify syntax/sem antics for data definition and
manipulation
- Define data structures
- Enable portability
- Specify minimal (level 1) and complete (level 2) standards
- Allow for later growth/enhancem ent to standard
What Can SQL do?
- Retrieve, insert, update, and delete database records
- Create new or update database structures: table, view,
stored procedures, etc.
- Grant access permission to database objects: tables, stored
procedures, views, etc.
Trang 43SQL Overview SQL Environment
SQL Overview SQL Database Objects
• A SQL Server database has lot of objects like
Trang 44SQL Overview SQL Database Objects (Cont)
Tables Views procedures Functions
Accept parameters to perform operations
The return value can either be a single value
Based on SELECT queries
Contain statements that perform operations
Vw.
Do not return values
Triggers
Special kind
of stored procedure that automatically executes when an event occurs
in the database server
- Creates a table with tw o colum ns
Drop table tablename;
- Drops the table structure
Trang 45the type of data that can go into a table.
• We will focus on the following constraints:
to verify regular data.
• Syntax:
• Sample:
ALTER TABLE [dbo].[Products] ADD
CONSTRAINT [CK_Products_No_Nissan] CHECK ([Productname] <> 'nissan sentra')
Trang 46Data Definition Language
* PRIMARY constraint: used to specify prim ary key of
table.
• Syntax:
PRIMARY KEY [(danh_sach_cot)]
Data Definition Language Table Constraint Scope
•Column Level
CREATE TABLE [dbo].[Customers] (
[CustomerlD] [int] IDENTITY (1, 1) NOT NULL PRIMARY KEY ,
[CustomerEmail] [varchar] (30) NULL ,
[CustomerState] [varchar] (5) NULL
) ON [PRIMARY]
GO
•Table Level
ALTER TABLE [dbo] [Products] ADD
CONSTRAINT [PK_Products] PRIMARY KEY CLUSTERED
(
[ProductID], [ProductName]
GO