Anda di halaman 1dari 9

Conventional Files versus the Database

*File – a collection of similar records.


– Files or conventional files are unrelated to each other
except in the code of an application program.
– Data storage is built around the applications that use
the files.

DATABASE DESIGN
*Database – a collection of interrelated files
– Records in one file (or table) are physically related to
Analisis dan Perancangan Sistem Informasi records in another file (or table).
– Applications are built around the integrated database
Universitas Katolik Parahyangan
2019 14-2

Files versus Database *Pros and Cons of Conventional Files


Pros Cons
• Easy to design because of • Harder to adapt to sharing
their single-application across applications
focus • Harder to adapt to new
• Excellent performance due requirements
to optimized organization • Need to duplicate
for a single application attributes in several files.

14-3 14-4

1
Fields
*Pros and Cons of Databases
Field – the smallest unit of meaningful data
Pros Cons to be stored in a database
• Data independence from • More complex than file
technology – the physical implementation of a data attribute
applications increases
adaptability and flexibility • Somewhat slower Primary key – a field that uniquely identifies a record.
performance
• Superior scalability Secondary key– a field that identifies a single record or a
• Investment in DBMS and subset of related records.
• Ability to share data across database experts
applications Foreign key– a field that points to records in a different file.
• Need to adhere to design
• Less, and controlled principles to realize Descriptive field– any nonkey field.
redundancy (total non- benefits
redundancy is not • Increased vulnerability due
achievable) to consolidating data in a
centralized database
14-5 14-6

Records Files and Tables


Record – a collection of fields arranged in a File – the set of all occurrences of a given record structure.
Table – the relational database equivalent of a file.
predetermined format.
– Fixed-length record structures • Six (6) types of conventional files and tables
– Variable-length record structures – Master files– Records relatively permanent though values may change
– Transaction files– Records describe business events
– Document files– Historical data for review without overhead of
regenerating document
Blocking factor– the number of logical records – Archival files– Master and transaction records that have been deleted
included in a single read or write operation – Table lookup files– Relatively static data that can be shared to
maintain consistency
(from the computer’s perspective). – Audit files – Special records of updates to other files

14-7 14-8

2
Files and Tables Data Architecture
• Previous file design methods required that the Data architecture– a definition of how:
– Files and databases are to be developed and used to store data
analyst specify precisely how the records in a – The file and/or database technology to be used
database should be: – The administrative structure set up to manage the data resource
– Sequenced (File organization) Data is stored in some combination of:
– Accessed (File access) – Conventional files
– Operational databases– databases that support day-to-day operations
• Database technology usually predetermines and transactions for an information system. Also called transactional
databases.
and/or limits this – Data warehouses– databases that store data extracted from operational
databases.
– Trained database administrator may be given some • To support data mining
– Personal databases
control over organization, storage location, and access – Work group databases
methods for performance tuning.

14-9 14-10

A Modern Data Architecture


Administrators
Data administrator– a database specialist
responsible for data planning, definition,
architecture, and management.

Database administrator – a specialist responsible


for database technology, database
design,construction, security, backup and recovery,
and performance tuning.
– A database administrator will administer one or more
databases

14-11 14-12

3
Database Architecture Typical DBMS Architecture
Database architecture– the database technology used to
support data architecture
– Including the database engine, database utilities, CASE tools, and
database development tools.

Database management system (DBMS) – special software used


to create, access, control, and manage a database.
– The core of the DBMS is its database engine.
– A data definition language (DDL) is that part of the engine used to
physically define tables, fields, and structural relationships.
– A data manipulation language (DML) is that part of the engine used to
create, read, update, and delete records in the database, and navigate
between different records in the database.

14-13 14-14

Relational Databases From Logical Data Model …


Relational database– a database that implements
stored data in a series of two-dimensional tables
that are “related” to one another via foreign keys.
– The physical data model is called a schema.
– The DDL and DML for a relational database is called
SQL (Structured Query Language).
– Triggers– programs embedded within a database that
are automatically invoked by updates.
– Stored procedures– programs embedded within a
database that can be called from an application
program.
14-15 14-16

4
… To Physical Data Model (Relational User Interface for a Relational PC
Schema) DBMS

14-17 14-18

What is a Good Data Model? Database Normalization


*Three (3) characteristics of a good data model. *Three (3) steps of normalization:
• A good data model is simple • An logical entity (or physical table) is in first normal form if there
– The data attributes that describe an entity should are no attributes (fields) that can have more than one value for a
describe only that entity single instance (record).
• A good data model is essentially non-redundant • An logical entity (or physical table) is in second normal form if it is
– Each data attribute exists in at most one entity (except already in first normal form and if the values of all nonprimary key
for foreign keys) attributes are dependent on the full primary key.
• A good data model should be flexible and • An logical entity (or physical table) is in third normal form if it is
adaptable to future needs already in second normal form and if the values of all nonprimary
key attributes are not dependent on other nonprimary key
These goals are achieved through database normalization. attributes .

14-19 14-20

5
Conventional File Design Goals of Database Design
• Output and input designs typically completed first • A database should provide for efficient storage,
• Fundamental entities from data model designed update, and retrieval of data.
as master or transaction records
– Master files are typically fixed-length records • A database should be reliable—the stored data
– Associative entities from data model are joined into should have high integrity and promote user trust
transaction records as variable-length records
in that data.
• File access and organization selected
– Sequential
– Indexed • A database should be adaptable and scalable to
– Hashed new and unforeseen requirements and
– ISAM/VSAM applications.

14-21 14-22

Logical data Model in Third Normal


Database Schema
Form
• Database schema – a model or blueprint
representing the technical implementation of
the database.
– Also called a physical data model

14-23 14-24

6
Data Types for Different Database
A Method for Database Design Logical Data Type
Technologies
to be stored in field)
Physical Data
Type MS Access
Physical Data Type
Microsoft SQL Server
Physical Data Type
Oracle

Fixed length character data TEXT CHAR (size) or CHAR (size)


1. Review the logical data model. (use for fields with relatively character (size)
2. Create a table for each entity. fixed length character data)
Variable length character data TEXT VARCHAR (max size) or VARCHAR (max size)
3. Create fields for each attribute. (use for fields that require character varying (max
character data but for which size)
4. Create an index for each primary and secondary key. size varies greatly--such as
ADDRESS)
5. Create an index for each subsetting criterion. Very long character data (use LONG VARCHAR or
MEMO TEXT
6. Designate foreign keys for relationships. for long descriptions and notes-
-usually no more than one such
LONG VARCHAR2

7. Define data types, sizes, null settings, domains, and field per record)
defaults for each attribute. Integer number NUMBER INT (size) or
integer or
INTEGER (size) or
NUMBER (size)
8. Create or combine tables to implement supertype/ smallinteger or
tinuinteger
subtype structures. Decimal number NUMBER DECIMAL (size, decimal DECIMAL (size, decimal
9. Evaluate and specify referential integrity constraints. places) or
NUMERIC (size, decimal
places) or
NUMERIC (size, decimal
places) places) or
NUMBER
14-25 14-26

Data Types for Different Database


Physical Database Schema
Logical Data Type
Technologies (cont.)
Physical Data Physical Data Type Physical Data Type
to be stored in field) Type MS Access Microsoft SQL Server Oracle

Financial Number CURRENCY MONEY see decimal number


Date (with time) DATE/TIME DATETIME or DATE
SMALLDATETIME
Depending on precision
needed
Current time (use to store the not supported TIMESTAMP not supported
data and time from the
computer’s system clock)
Yes or No; or True or False YES/NO BIT use CHAR(1) and set a yes
or no domain

Image OLE OBJECT IMAGE LONGRAW


Hyperlink HYPERLINK VARBINARY RAW
Can designer define new data NO YES YES
types?

14-27 14-28

7
Database Schema with Referential
Database Integrity
Integrity Constraints
• Key integrity – Every table should have a primary key.
• Domain integrity – Appropriate controls must be
designed to ensure that no field takes on an
inappropriate value
• Referential integrity – the assurance tat a foreign key
value in one table has a matching primary key value in
the related table.
– No restriction
– Delete: cascade
– Delete: restrict
– Delete: set null

14-29 14-30

Database Distribution and Replication


Data distribution analysis establishes which business locations Database Capacity Planning
need access to which logical data entities and attributes.
*Four (4) alternatives for distributed database design. • For each table sum the field sizes. This is the
– Centralization
• Entire database on a single server in one physical location record size.
– Horizontal distribution (also called partitioning)
• Tables or row assigned to different database servers/locations. • For each table, multiply the record size times the
• Efficient access and security
• Cannot always be easily recombined for management analysis
number of entity instances to be included in the
– Vertical distribution (also called partitioning) table (planning for growth). This is the table size.
• Specific columns of tables assigned to specific databases and servers
• Similar advantages and disadvantages of Horizontal • Sum the table sizes. This is the database size.
– Replication
• Data duplicated in multiple locations • Optionally, add a slack capacity buffer (e.g.
• DBMS coordinates updates and synchronization of data
• Performance and accessibility advantages 10percent) to account for unanticipated factors.
• Increases complexity
This is the anticipated database capacity.
14-31 14-32

8
SQL DDL Code
CREATE TABLE [dbo].[ClassCodes] (
[ClassID] [Integer] Identity(1,1) NOT NULL,
[DepartmentCodeID] [varchar] (3) NOT NULL ,
[SectionCodeID] [varchar] (2) NOT NULL ,
[ClassCodeID] [varchar] (5) NOT NULL ,
[GroupCodeID] [varchar] (1) NOT NULL ,
[ClassDescription] [varchar] (50) NOT NULL ,
[ValidOnLine] bit NULL ,
[LastUpdated] [smalldatetime] NULL
) ON [PRIMARY]
GO

Alter Table [dbo].[ClassCodes] Add Constraint pk_classcodes


Primary Key (ClassID)
Alter Table [dbo].[ClassCodes] Add Constraint df_classcodes_groupcodeid
Default 'A' for GroupCodeID
Alter Table [dbo].[ClassCodes] Add Constraint fk_classcodes_sectioncodes
Foreign Key (DepartmentCodeID,SectionCodeID)
References SectionCodes(DepartmentCodeID,SectionCodeID)
See You Next Week ☺
Alter Table [dbo].[ClassCodes] Add Constraint un_classcodes_Dept_Section_Class
Unique (DepartmentCodeID,SectionCodeID,ClassCodeID)
GO
14-33

Anda mungkin juga menyukai