You are on page 1of 13

Definitions

 Waste of space to have duplicate data


 Database: organized collection of logically related data  Causes more maintenance headaches
 Data: stored representations of meaningful objects and  The biggest problem:
events o Data changes in one file could cause
o Structured: numbers, text, dates inconsistencies
o Unstructured: images, video, documents o Compromises in data integrity
 Information: data processed to increase knowledge in
the person using the data SOLUTION:
 Metadata: data that describes the properties and The DATABASE Approach
context of user data
 Central repository of shared data
 Data is managed by a controlling agent
Disadvantages of File Processing  Stored in a standardized, convenient Form

 Program-Data Dependence Database Management System


o All programs maintain metadata for each file  A software system that is used to create, maintain, and
they use provide controlled access to user databases
 Duplication of Data
o Different systems/programs have separate manages data resources like an operating system manages
copies of the same data hardware resources
 Limited Data Sharing
o No centralized control of data
 Lengthy Development Times Advantages of the Database Approach
o Programmers must design their own file formats
 Excessive Program Maintenance  Program-data independence
o 80% of information systems budget  Planned data redundancy
 Improved data consistency
Problems with Data Dependency  Improved data sharing
 Increased application development productivity
 Each application programmer must maintain his/her  Enforcement of standards
own data  Improved data quality
 Each application program needs to include code for the  Improved data accessibility and responsiveness
metadata of each file  Reduced program maintenance
 Each application program must have its own processing  Improved decision support
routines for reading, inserting, updating, and deleting
data Costs and Risks of the Database
 Lack of coordination and central control Approach
 Non-standard file formats
 New, specialized personnel
Problems with Data Redundancy  Installation and management cost and complexity
 Conversion costs  End Users–people who use the applications and
 Need for explicit backup and recovery Databases
 Organizational conflict
Enterprise Database Applications
Elements of the Database Approach
 Enterprise Resource Planning (ERP)
 Data models o Integrate all enterprise functions
o Graphical system capturing nature and (manufacturing, finance, sales, marketing,
relationship of data inventory, accounting, human resources)
o Enterprise Data Model–high-level entities and  Data Warehouse
relationships for the organization o Integrated decision support system derived
o Project Data Model–more detailed view, from various operational databases
matching data structure in database or data
warehouse Information Systems Architecture
 Relational Databases (ISA)
o Database technology involving tables (relations)
representing entities and primary/foreign keys  Conceptual blueprint for organization’s desired
representing relationships information systems structure
 Use of Internet Technology
o Networks and telecommunications, distributed  Consists of:
databases, client-server, and 3-tier architectures o Data (e.g. Enterprise Data Model–simplified ER
 Database Applications Diagram)
o Application programs used to perform database o Processes–data flow diagrams, process
activities (create, read, update, and delete) for decomposition, etc.
database users o Data Network–topology diagram
o People–people management using project
Components of the management tools (Gantt charts, etc.)
Database Environment o Events and points in time (when processes are
performed)
 CASE Tools–computer-aided software engineering o Reasons for events and rules (e.g., decision tables)
 b–centralized storehouse of metadata
 Database Management System (DBMS) –software for Information Engineering
managing the database
 Database–storehouse of the data  A data-oriented methodology to create and maintain
 Application Programs–software using the data information systems
 User Interface–text and graphical displays to users
 Data/Database Administrators–personnel responsible  Top-down planning–a generic IS planning methodology
for maintaining the database for obtaining a broad understanding of the IS needed by
 System Developers–personnel responsible for designing the entire organization
databases and software
 Four steps to Top-Down planning:
o Planning and IS Development
o Analysis
o Design  SDLC
o Implementation o System Development Life Cycle
o Detailed, well-planned development process
Information Systems Planning o Time-consuming, but comprehensive
o Long development cycle
 Purpose–align information technology with
organization’s business strategies  Prototyping
 Three steps: o Rapid application development (RAD)
o Identify strategic planning factors o Cursory attempt at conceptual data modeling
o Identify corporate planning objects o Define database during development of initial
o Develop enterprise model prototype
o Repeat implementation and maintenance
Identify Strategic Planning activities with new prototype versions
Factors
Systems Development Life Cycle
 Organization goals–what we hope to accomplish
 Critical success factors–what MUST work in order for us Planning
to survive Purpose–preliminary understanding
 Problem areas–weaknesses we now have
Deliverable–request for study
Identify Corporate Planning
Objects Database activity–

 Organizational units–departments enterprise modeling and


 Organizational locations early conceptual data
 Business functions–groups of business modeling
 processes
 Entity types–the things we are trying to model for the Analysis
database Purpose–thorough requirements analysis and
 Information systems–application programs structuring

Develop Enterprise Model Deliverable–functional system specifications

 Functional decomposition Database activity–Thorough


o Iterative process breaking system description and integrated conceptual
into finer and finer detail data modeling
 Enterprise data model
Logical Design
Two Approaches to Database Purpose–information requirements elicitation
and structure database implementation,
including coded programs,
Deliverable–detailed design specifications documentation,
installation and conversion
Database activity–
Maintenance
logical database design Purpose–monitor, repair, enhance
(transactions, forms,
displays, views, data Deliverable–periodic audits
integrity and security)
Database activity–
Database activity–
database maintenance,
logical database design performance analysis
(transactions, forms, and tuning, error
displays, views, data corrections
integrity and security)
CASE
Physical Design
Purpose–develop technology and  Computer-Aided Software Engineering (CASE)–software
organizational specifications tools providing automated support for systems
development
Deliverable–program/data
structures, technology purchases,  Three database features:
organization redesigns o Data modeling–drawing entity-relationship
diagrams
Database activity– o Code generation–SQL code for table creation
o Repositories–knowledge base of enterprise
physical database design (define Information
database to DBMS, physical
data organization, database Managing Projects
processing programs)
 Project–a planned undertaking of related activities to
Implementation reach an objective that has a beginning and an end
Purpose–programming, testing, training,
installation, documenting  Involves use of review points for:
o Validation of satisfactory progress
Deliverable–operational programs, o Step back from detail to overall view
documentation, training materials o Renew commitment of stakeholders

Database activity–
 Incremental commitment–review of
systems development project after each o Attribute–property or characteristic of an entity
development phase with rejustification or relationship type (often corresponds to a field
after each phase in a table)

Managing Projects: People Involved What Should an Entity Be?


 SHOULD BE:
 Business analysts o An object that will have many instances in the
 Systems analysts database
 Database analysts and data modelers o An object that will be composed of multiple
 Users attributes
 Programmers o An object that we are trying to model
 Database architects  SHOULD NOT BE:
 Data administrators o A user of the database system
 Project managers o An output of the database system (e.g., a
 Other technical experts report)

Attributes
A Good Business Rule is:  Attribute–property or characteristic of an entity or
relationship type
 Declarative–what, not how  Classifications of attributes:
 Precise–clear, agreed-upon meaning o Required versus Optional Attributes
 Atomic–one statement o Simple versus Composite Attribute
 Consistent–internally and externally o Single-Valued versus Multivalued Attribute
 Expressible–structured, natural language o Stored versus Derived Attributes
 Distinct–non-redundant o Identifier Attributes
 Business-oriented–understood by business people
Characteristics of Identifiers
E-R Model Constructs
 Entities:  Will not change in value
o Entity instance–person, place, object, event,
concept (often corresponds to a row in a table)  Will not be null
o Entity Type–collection of entities (often
corresponds to a table)  No intelligent identifiers (e.g., containing locations or
 Relationships: people that might change)
o Relationship instance–link between entities
(corresponds to primary key-foreign key Degree of Relationships
equivalencies in related tables)  Degree of a relationship is the number of entity types
o Relationship type–category of relationship…link that participate in it
between entity types o Unary Relationship
o Binary Relationship
o Ternary Relationship
 Weak entity
Cardinality of Relationships
 One-to-One o dependent on a strong entity (identifying
o Each entity in the relationship will have exactly owner)…cannot exist on its own
one related entity
 One-to-Many o does not have a unique identifier (only a partial
o An entity on one side of the relationship can identifier)
have many related entities, but an entity on the
other side will have a maximum of one related o Partial identifier underlined with double-line
entity
 Many-to-Many o Entity box has double line
o Entities on both sides of the relationship can
have many related entities on the other side
Associative Entities
Cardinality Constraints
 An entity–has attributes
 Cardinality Constraints - the number of
instances of one entity that can or must be  A relationship–links entities together
associated with each instance of another
entity  When should a relationship with attributes instead be an
associative entity?
 Minimum Cardinality o All relationships for the associative entity should
be many
o If zero, then optional o The associative entity could have meaning
independent of the other entities
o one or more, then mandatory o The associative entity preferably has a unique
identifier, and should also have other attributes
 Maximum Cardinality o Ternary relationships should be converted to
associative entities
o The maximum number
Supertypes and Subtypes

Strong vs. Weak Entities  Subtype: A subgrouping of the entities in an entity


type that has attributes distinct from those in other
 Strong entities subgroupings

o exist independently of other types of entities  Supertype: A generic entity type that has a
o has its own unique identifier relationship with one or more subtypes

o identifier underlined with single-line  Attribute Inheritance:


o Subtype entities inherit values of all attributes of Disjointness constraint
the supertype
 Disjointness Constraints: Whether an
o An instance of a subtype is also an instance of instance of a supertype may
the Supertype simultaneously be a member of two (or
more) subtypes
Relationships and Subtypes
o Disjoint Rule: An instance of the supertype
Relationships at the supertype level can be only ONE of the subtypes
indicate that all subtypes will participate in
the relationship o Overlap Rule: An instance of the supertype
could be more than one of the subtypes
The instances of a subtype may participate
in a relationship unique to that subtype. Constraints in Supertype/
In this situation, the relationship is shown Subtype Discriminators
at the subtype level
 Subtype Discriminator: An attribute of the
Generalization and supertype whose values determine the target
Specialization subtype(s)

 Generalization: The process of defining a o Disjoint – a simple attribute with alternative


more general entity type from a set of values to indicate the possible subtypes
more specialized entity types. BOTTOM-UP
o Overlapping – a composite attribute whose
 Specialization: The process of defining subparts pertain to different subtypes. Each
one or more subtypes of the supertype subpart contains a boolean value to indicate
and forming supertype/subtype whether or not the instance belongs to the
relationships. TOP-DOWN associated subtype
Relation
Constraints in Supertype/
Completeness Constraint  Definition: A relation is a named, two-dimensional table
of data
 Completeness Constraints: Whether  Table consists of rows (records) and columns (attribute
an instance of a supertype must also be or field)
a member of at least one subtype  Requirements for a table to qualify as a relation:
o It must have a unique name
o Total Specialization Rule: Yes (double line) o Every attribute value must be atomic
o Every row must be unique (can’t have two rows
o Partial Specialization Rule: No (single line) with exactly the same values for all their fields)
o Attributes (columns) in tables must have
Constraints in Supertype/ unique names
o The order of the columns and rows must be 3. Multivalued Attribute–Becomes a separate relation
irrelevant with a foreign key taken from the
superior entity
Key Fields
Transforming EER Diagrams into
Relations (cont.)
 Keys are special fields that serve two main purposes:
 Primary keys are unique identifiers of the Mapping Binary Relationships
relation.
 Foreign keys are identifiers that enable a  One-to-Many–Primary key on the one side becomes a
dependent relation (on the many side of a foreign key on the many side
relationship) to refer to its parent relation (on  Many-to-Many–Create a new relation with the primary
the one side of the relationship). keys of the two entities as its primary key
 Keys can be simple (a single field) or composite (more  One-to-One–Primary key on the mandatory side
than one field) becomes a foreign key on the optional side
 Composite key – a primary key consisting of more than  Identifier Not Assigned
one column in a relation. o Default primary key for the association relation
is composed of the primary keys of the two
Integrity Constraints
entities (as in M:N relationship)

 Referential Integrity–rule states that any foreign key


 Identifier Assigned
value (on the relation of the many side) MUST match a
o Use the surrogate identifier as well as the
primary key value in the relation of the one side.
primary keys of the two entities which would
DELETE RULE:
become the foreign key in the relation.
o Restrict–don’t allow the deletion of “parent”
 One-to-Many–Recursive foreign key in the same
side if related rows exist in “dependent” side
relation
o Cascade–automatically delete “dependent”
 Many-to-Many–Two relations:
side rows that correspond with the “parent”
o One for the entity type
side row to be deleted
o One for an associative relation in which the
o Set-to-Null–set the foreign key in the
primary key has two attributes, both taken
dependent side to null if deleting from the
from the primary key of the entity
parent side 🡪 not allowed for weak entities

Transforming EER Diagrams into


Relations

Mapping Regular Entities to Relations

1. Simple attributes: E-R attributes map directly onto the


relation
2. Composite attributes: Use only their simple,
component attributes
Data Normalization Year 1979, the first commercially available implementation of
SQL was introduced by
 Primarily a tool to validate and improve Relational Software, Inc which was now the Oracle Corporation.
a logical design so that it satisfies
certain constraints that avoid SQL is now accepted as the standard RDBMS language.
unnecessary duplication of data
SQL is a language used to write programs that will allow the
 The process of decomposing relations user to create, manipulate
with anomalies to produce smaller, and query databases.
well-structured relations
The database system such as the SQL Server, executes your SQL
codes and displays your
requested information.

Well-Structured Relations SQL follows some syntax and defined by semantics.

 A relation that contains minimal data redundancy and CHARACTERISTICS OF SQL


allows users to insert, delete, and update rows
without causing data inconsistencies Easy to Learn

 Types of anomalies: Nonprocedural

o Insertion Anomaly– occurs when certain Versatile


columns cannot
be inserted into the database without the Set-oriented
presence of other columns
Interactive or embedded
o Deletion Anomaly–deleting rows may cause a
loss of data that would be needed for other Standardized
future rows
RDBMS
o Modification Anomaly–changing data in a row
forces changes to other rows because of Relational Database Management System
duplication
Stores, manages and presents data to users in the form of
named tables related to other tables
HISTORY OF SQL according to relational model.

SQL was initially named as SEQUEL and was developed by the Some of the most popular RDBMS that supports SQL are:
IBM Corporation Inc in
California in the year 1970 and was later called as SQL. Oracle
One of the first database products to run on a variety of - words with special meaning therefore these are considered
platforms reserved and cannot be used as identifiers.

Developed by Oracle Corporation Example: SELECT, DATABASE

SQL*Plus and Developer SQL CONCEPTS

MySQL SQL Statement

One of the most popular open source database - a grammatically acceptable and valid combination of
indivisible parts such as keywords, identifiers,
Usually used with PHP operators, punctuation marks, or constants of the SQL
language.
MS SQL Server
Example: SELECT * FROM COLLEGE
Runs in Microsoft Windows OS
Clause
Supports numerous transactions and computer applications
stored - is a fragment of an SQL statement that is usually introduced
by a keyword.
SQL CONCEPTS
Example: ORDER BY FName
Comment
Expression
- a word, clause, or statement added by the programmer to
remind him of what a particular part of code - refers to any legal combination of keywords and numeric
does. symbols that evaluates to a single data value.

- two consecutive hyphens for single line comment. Example: SALARY * 12

- backslash asterisk ( /* */ ) for multiple line comment. SQL CONCEPTS

Identifiers Functions

- names given to the database objects such as tables, columns, - are section of codes that take zero, one, or more input values,
views, and databases. perform a specific assignment and return a
scalar or tabular set of values.
Example: COLLEGE which is a name given to a table.
Example: SUM(), UPPER()
Keywords
Operators
- work with one or more simple expression to form a more image – used to store images in binary format
complex expression.
bit – an integer data type which can store only 0 or 1 and can
Example: AND, +, > consume only a single bit of
storage space.
Semicolon
xml – used to store xml data.
Used to end SQL statements
CATEGORIES OF SQL STATEMENTS
In some variants of the SQL semicolon is optional
Data Definition Language (DDL) Statements
SQL DATA TYPES
These are statements that define, modify, and destroy the
INT – holds whole numbers structure of database and
the tables within the database.
DECIMAL(size,d) or NUMERIC(size,d) – holds numbers
containing decimal point. Statements included under the DDL:

FLOAT – holds numbers containing decimal point and uses 8 CREATE DATABASE – creates a new database
bytes for storage with up to
15 digits precision. DROP DATABASE – removes an existing database

VARCHAR(size) – holds a string. CREATE TABLE – creates a new database table

CHAR(size) – holds fixed-length character string where the ALTER TABLE – modifies the structure of a database table
exact length of the data to be
stored is already determined. DROP TABLE – destroys a database table

DATE – holds date values in YYYY-MM-DD format. CATEGORIES OF SQL STATEMENTS

SQL DATA TYPES Data Manipulation Language (DML) Statements

SMALL DATETIME – holds time values in HH:MI:SS.[nnnnnnnnn] Used to control the contents of the tables and do not have an
format. effect on the structure
of the database.
DATETIME – holds date and time values in YYYY-MM-DD
HH:MI:SS.[nnn] format. Statements included under the DML:

VARBINARY(max) – used to store images in binary format and INSERT INTO – inserts new data into the database table
holds up to 2 gigabytes
of binary data. SELECT – retrieves data from the database tables
UPDATE – modifies the data stored in the database tables column_name1 datatype,

DELETE – removes a row/record from a database table. column_name2 datatype,

CATEGORIES OF SQL STATEMENTS column_name3 datatype,

Data Control Language (DCL) Statements …

These are statements used to control a database including [table constraints, if any]
administering privileges by
authorizing certain users to view, change, or delete database )
objects and/or the data
within the database. Example:

Statements included under the DCL: create table COLLEGE(

GRANT – assigns privileges to users and roles ColCode varchar(10) primary key,

REVOKE – removes privileges ColName varchar(20)

DDL SYNTAX )

Creating a database: DDL SYNTAX

Syntax: CREATE DATABASE database_name Deleting a Table:

Example: CREATE DATABASE samplelecture Syntax: DROP TABLE table_name

Removing a database: Example: DROP TABLE COLLEGE

Syntax: DROP DATABASE database_name DML SYNTAX

Example: DROP DATABASE samplelecture INSERT INTO Statement

DDL SYNTAX SYNTAX:

Creating the database table: INSERT INTO table_name

Syntax: ( column_name1…column_namen )

CREATE TABLE table_name( VALUES ( value1…valuen )


Or

INSERT INTO table_name

VALUES ( first_value…last_value )

DML SYNTAX

UPDATE Statement

SYNTAX:

UPDATE table_name

SET Column_name=newvalue

WHERE condition

DELETE Statement

SYNTAX:

DELETE from table_name

WHERE condition

You might also like