Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

FUNDAMENTALS OF DATABASE SYSTEM DATABASE MANAGEMENT SYSTEM (DBMS) - A software

package/system to facilitate the creation and


CHAPTER 1: Introduction to Database
maintenance of a computerized database.
DATABASE
DATABASE SYSTEM: The DBMS software together with
• A database is a collection of related data. the data itself. Sometimes, the applications are also
• A database is an organized collection of structured included.
information, or data, typically stored electronically in
a computer system.
• A database is usually controlled by a database CHARACTERISTICS OF THE DATABASE APPROACH
management system (DBMS).
 Self-Describing Nature of a Database System
• A database system is referred to as self-
describing because it not only contains the
The DBMS is a general-purpose, application-independent
database itself, but also METADATA which
software system that facilitates the processes of: DCMS
defines and describes the data and relationships
a) DEFINING - A database involves specifying data between tables in the database. (MESA = TABLE)
types, structures and constraints for the data to
be stored in the database. The database  Insulation between Programs and Data, and Data
definition or descriptive information is also Abstraction
stored by the DBMS in a form of database catalog • In the database approach, the data structure is
or dictionary. stored in the system catalogue and not in the
b) CONSTRUCTING - The database is the process of programs. Therefore, one change is all that is
storing the data itself on some storage medium needed to change the structure of a file. This
that is controlled by the DBMS. insulation between the programs and data is
c) MANIPULATING - A database includes such also called PROGRAM-DATA INDEPENDENCE.
functions as querying the database to retrieve
DATA ABSTRACTION - a data model is used to hide
specific data, updating the database to reflect storage details and present the users with a conceptual
changes in the mini-world, deleting data, and view of the database.
generating reports from the data
d) SHARING - A database allows multiple users and  Support of Multiple Views of the Data
application programs to access the database • Each user may see a different view of the
simultaneously. An application program accesses database, which describes only the data of
the database by sending queries or requests for interest to that user.
data to the DBMS
 Sharing of Data and Multiuser Transaction
Processing
EXAMPLE OF A DATABASE(WITH A CONCEPTUAL DATA • Allowing a set of concurrent users to retrieve and
MODEL) to update the database. CONCURRENCY
CONTROL within the DBMS guarantees that each
Mini-world for the example: Part of a UNIVERSITY
transaction is correctly executed or completely
environment.
aborted. OLTP (Online Transaction Processing) is
Some mini-world entities: a major part of database applications.

• STUDENTs
• COURSEs
DATABASE USERS - ACTORS ON THE SCENE (ADSE)
• SECTIONs (of COURSEs)
• (academic)DEPARTMENTs a) Database Administrators - responsible for
• INSTRUCTORs authorizing access to the database, for coordinating
and monitoring its use, acquiring software, and
Note: The above could be expressed in the ENTITY-
hardware resources, controlling its use and
RELATIONSHIP data model.
monitoring efficiency of operations
Some mini-world relationships:
b) Database Designers - responsible to define the
• SECTIONs are of specific COURSEs content, the structure, the constraints, and functions
• STUDENTs take SECTIONs or transactions against the database. They must
• COURSEs have prerequisite COURSEs communicate with the end-users and understand
• INSTRUCTORs teach SECTIONs their needs.
• COURSEs are offered by DEPARTMENTs
• STUDENTs major in DEPARTMENTs c) System Analysts and Application Programmers
(Software Engineers) - responsible for the design,
structure and properties of the database and
DATA - Known facts that can be recorded and have an responsible for writing application programs that
implicit meaning. interact with the database.

© claiming uno for ebriwan – misyel


A BRIEF HISTORY OF DATABASE APPLICATIONS
d) End User - they use the data for queries, reports and
A. Early Database Applications Using Hierarchical and
some of them update the database content.
Network Systems
CATEGORIES OF END USERS (CNSSA)
 The HIERARCHICAL AND NETWORK MODELS
i. Casual End Users - They occasionally access the were introduced in mid 1960’s and dominated
database but may need different information during the seventies.
each time. These users have great knowledge of  A bulk of the worldwide database processing still
query language. They do not write programs, occurs using these models.
but they can interact with the system by writing
B. Providing Data Abstraction and Application Flexibility
queries.
with RELATIONAL DATABASES
ii. Naïve End Users - They are the users who does • The model that was originally introduced in 1970
not have any knowledge about database. Their was heavily researched and experimented with in
task is to just use the developed application and IBM and the universities.
get the desired results. • Relational DBMS Products emerged in the 1980’s.

iii. Sophisticated End Users - These are engineers, C. Object-Oriented Applications and the Need for More
scientists, business analysts and others who Complex Databases
thoroughly familiarize themselves with the • OODBMSs were introduced in late 1980’s and
facilities of DBMS to implement their own early 1990’s to cater to the need of complex data
application to meet their complex requirements. processing in CAD and other applications. Their
use has not taken off much. (OODBMS – Object-
iv. Standalone Users - They are the users who oriented Application and the need for more
interacts with the database directly via on-line complex databases)
terminal or indirectly through Menu or graphics-
based interfaces. D. Interchanging Data on the Web for E-Commerce
Using XML

• Web contains data in HTML (Hypertext Markup


DATABASE USERS - WORKERS BEHIND THE SCENE (STO) Language) with links among pages. This has given
a) DBMS system designers and implementers - Designs rise to a new set of applications and E-commerce
and implement the DBMS modules and interfaces as is using new standards like XML (eXtended
a software package. Markup Language).

D. Extending Database Capabilities for New Applications


b) Tool developers - Design and implement the TOOLS –
the software packages that facilitate database New functionality is being added to DBMSs in the
modelling and design following areas:

• Scientific Applications
c) Operators and maintenance personnel - They are • Image Storage and Management
responsible for the actual running and maintenance • Audio and Video data management
of the hardware and software environment for the • Data Mining
database system. Also called the system • Spatial data management
administration personnel. • Time Series and Historical Data Management

ADVANTAGES OF USING THE DBMS APPROACH


WHEN NOT TO USE A DBMS
1. Controlling Redundancy
2. Restricting Unauthorized Access Main inhibitors (costs) of using a DBMS:
3. Providing Persistent Storage for Program Objects
 High initial investment and possible need for
4. Providing Storage Structures and Search
additional hardware.
Techniques for Efficient Query Processing
 Overhead for providing generality, security,
5. Providing Backup and Recovery
concurrency control, recovery, and integrity
6. Providing Multiple User Interfaces
functions.
7. Representing Complex Relationships among Data
8. Enforcing IntegrityConstraints9 When a DBMS may be unnecessary:
9. Permitting Inferencing and Actions using Rules
 If the database and applications are simple, well
and Triggers
defined, and not expected to change.
10. Additional Implications of Using the Database
 If there are stringent real-time requirements that
Approach
may not be met because of DBMS overhead.
 If access to data by multiple users is not required.

When no DBMS may suffice:

© claiming uno for ebriwan – misyel


 If the database system is not able to handle the  Provide concepts that describe details of how
complexity of data because of modeling data is stored in the computer.
limitations  This Data Model describes HOW the system will
 If the database users need special operations not be implemented using a specific DBMS system.
supported by the DBMS.  This model is typically created by DBA and
developers.
 The purpose is actual implementation of the
CHAPTER 2: Database System Concepts and Architecture database.
 Describes a database-specific implementation of
DATA MODEL: A set of concepts to describe the structure
the data model.
of a database, and certain constraints that the database
 It offers database abstraction and helps generate
should obey.
the schema.
– A data model (or data model) is an abstract model that  The physical data model also helps in visualizing
organizes elements of data and standardizes how they database structure by replicating database
relate to one another and to the properties of real-world column keys, constraints, indexes, triggers, and
entities. The term data model can refer to two distinct other RDBMS features.
but closely related concepts.

The two types of Data Modeling Techniques are: (EU)

1. Entity Relationship (E-R) Model


2. UML (Unified Modelling Language)

DATA MODEL OPERATIONS: Operations for specifying c) IMPLEMENTATION (representational, external) data
database retrievals and updates by referring to the models:
concepts of the data model. Operations on the data  Provide concepts that fall between the above
model may include BASIC OPERATIONS and USER- two, balancing user views with some computer
DEFINED OPERATIONS. storage details.

CATEGORIES OF DATA MODELS (CPID) d) LOGICAL Data Model:


 Defines HOW the system should be implemented
a) CONCEPTUAL (high-level, semantic) data models: regardless of the DBMS.
 Provide concepts that are close to the way many  This model is typically created by Data Architects
users perceive data. and Business Analysts.
 Also called entity-based or object-based data  The purpose is to develop technical map of rules
models. and data structures.
 This Data Model defines WHAT the system  Used to define the structure of data elements
contains. and to set relationships between them.
 created by Business stakeholders and Data  Adds further information to the conceptual data
Architects. model elements.
 The purpose is to organize, scope and define  Its advantage is to provide a foundation to form
business concepts and rules. the base for the Physical model
3 BASIC TENANTS:  However, the modeling structure remains
generic.
 Entity: A real-world thing
 Attribute: Characteristics or properties of an
entity
 Relationship: Dependency or association
between two entities

*sa physical, how it is stored; sa logical, how it is


implemented

HISTORY OF DATA MODELS

b) PHYSICAL (low-level, internal) data models: a) RELATIONAL MODEL:


• Proposed in 1970 by E.F. Codd (IBM) – first
commercial system in 1981-82.
© claiming uno for ebriwan – misyel
• Now in several commercial products (DB2,  Additionally, systems like O2, ORION (at MCC -
ORACLE, SQL Server, SYBASE, INFORMIX). then ITASCA), IRIS (at H.P.- used in Open OODB).

b) NETWORK MODEL:
 the first one to be implemented by Honeywell in e) OBJECT-RELATIONAL MODELS:
1964-65 (IDS System).  Most Recent Trend.
 Adopted heavily due to the support by CODASYL  Started with Informix Universal Server.
(CODASYL - DBTG report of 1971).  Exemplified in the latest versions of Oracle-10i,
 Later implemented in a large variety of systems - DB2, and SQL Server etc. systems.
IDMS (Cullinet - now CA), DMS 1100 (Unisys),
IMAGE (H.P.), VAX -DBMS (Digital Equipment
Corp.) Schemas versus Instances
ADVANTAGES: DATABASE SCHEMA:
 Network Model can model complex relationships and • The overall description of a database.
represents semantics of add/delete on the • Includes database structure and the constraints
relationships. that should hold on the database.
 Can handle most situations for modeling using record • The term "SCHEMA" refers to the organization of
types and relationship types. data as a blueprint of how the database is
 Language is navigational; uses constructs like FIND, constructed and stored (divided into database
FIND member, FIND owner, FIND NEXT within set, tables in the case of relational databases).
GET etc. • sketch of a planned database
 Programmers can do optimal navigation through the • doesn’t have any data in it
database. • static
DISADVANTAGES: TWO TYPES:
 Navigational and procedural nature of processing a. LOGICAL SCHEMA
 Database contains a complex array of pointers that  It describes the database designed at logical
thread through a set of records. Little scope for level.
automated “query optimization”  the programmers, as well as the database
administrator (DBA), work
 data can be described as certain types of data
c) HIERARCHICAL DATA MODEL: records that can be stored in the form of data
 implemented in a joint effort by IBM and North structures.
American Rockwell around 1965.  Internal details (such as an implementation of
 Resulted in the IMS family of systems. data structure) will be remaining hidden at this
 The most popular model. level.
 Other system based on this model: System 2k  The logical schema that the user sees depends on
(SAS Inc.) the type of database management system.
ADVANTAGES:  The basic models are: hierarchical, network,
relational, object-oriented.
 Hierarchical Model is simple to construct and operate
on b. PHYSICAL SCHEMA
 Corresponds to several natural hierarchically  It describes the database designed at physical
organized domains – e.g., assemblies in level.
manufacturing, personnel organization in companies  Expressed how data is stored in blocks of
 Language is simple; uses constructs like GET, GET storage.
UNIQUE, GET NEXT, GET NEXT WITHIN PARENT etc.

DISADVANTAGES:
 VIEW SCHEMA: can be defined as the design of the
 Navigational and procedural nature of processing database at the view level, which generally describes
 Database is visualized as a linear arrangement of end-user interaction with database systems.
records  SCHEMA DIAGRAM: A diagrammatic display of
 Little scope for “query optimization” (some aspects of) a database schema.
 SCHEMA CONSTRUCT: A component of the schema
or an object within the schema, e.g., STUDENT,
d) OBJECT-ORIENTED DATA MODEL(S): COURSE.
 One set comprises models of persistent O-O
Programming Languages such as C++ (e.g., in
DATABASE INSTANCE: The actual data stored in a
OBJECTSTORE or VERSANT), and Smalltalk (e.g.,
database at a particular moment in time. Also called
in GEMSTONE).
database state (or occurrence).

© claiming uno for ebriwan – misyel


 snapshot of a database as it existed at a  If there is any change in the internal or physical
particular time schema, it needs to be addressed to the interface
 instances can change over time between the conceptual and internal schema. But
 Data state can be changed there is no need to change in the interface of a
 The instances can be changed by certain CRUD conceptual and external schema. It means that the
operations as like addition, deletion of data. changes in physical storage devices such as hard
 It may be noted that any search query will not disks, and the files organized on storage devices, are
make any kind of changes in the instances. transparent to application programs and users.

Example – Let’s say a table TEACHER in our database


whose name is School, suppose the table has 50 records
CONCEPTUAL OR LOGICAL LEVEL: The conceptual level
so the instance of the database has 50 records for now
describes the structure of the whole database. This level
and tomorrow we are going to add another fifty records
acts as a middle layer between the physical storage and
so tomorrow the instance have total 100 records. This is
user view. It explains what data to be stored in the
called an instance.
database, what relationship exists among those data,
and what the datatypes are. There is only one conceptual
schema per database.
Database Schema Vs. Database State
 Database administrator and the programmers work
DATABASE STATE: Refers to the content of a database at at this level. This level does not provide any access or
a moment in time. storage details but concentrates on the relational
 INITIAL DATABASE STATE: Refers to the database model of the database. The conceptual schema also
when it is loaded includes features that specify the checks to retain
 VALID STATE: A state that satisfies the structure and integrity and consistency.
constraints of the database.

Difference EXTERNAL OR VIEW LEVEL: This is the highest level of


• The database SCHEMA changes very database abstraction. External or view level describes the
infrequently. actual view of data that is relevant to the particular user.
• The database STATE changes every time the This level also provides different views of the same
database is updated. database for a specific user or a group of users. An
• SCHEMA is also called INTENSION, whereas external view provides a powerful and flexible security
STATE is called EXTENSION. mechanism by hiding the parts of the database from a
particular user.

THREE-SCHEMA ARCHITECTURE
Advantages of Three-schema Architecture
Proposed to support DBMS characteristics of:
 This architecture makes the database abstract. It
• Program-data independence. is used to hide the details of how data is
• Support of multiple views of the data. physically stored in a computer system, which
Defines DBMS schemas at three levels: makes it easier to use for a user.
 This architecture allows each user to access the
i. INTERNAL SCHEMA: at the internal level to same database with a different customized view
describe physical storage structures and access of data.
paths. Typically uses a physical data model.  This architecture enables a database admin to
ii. CONCEPTUAL SCHEMA: at the conceptual level change the storage structure of the database
to describe the structure and constraints for the without affecting the user currently on the
whole database for a community of users. Uses a system.
conceptual or an implementation data model.
iii. EXTERNAL SCHEMAS: at the external level to
describe the various user views. Usually uses the Mappings among schema levels are needed to transform
same data model as the conceptual level. requests and data. Programs refer to an external schema
and are mapped by the DBMS to the internal schema for
execution.
INTERNAL OR PHYSICAL LEVEL: This is the lowest level of
database abstraction. It describes how the data is MAPPING - Process of transforming request and results
actually stored in the database and provides methods to between three level.
access data from the database. It allows viewing the
physical representation of the database on the computer
system. The interface between the conceptual schema DATA INDEPENDENCE
and the internal schema identifies how an element in the
conceptual schema is stored and how it may be accessed.

© claiming uno for ebriwan – misyel


• LOGICAL DATA INDEPENDENCE: The capacity to change • Example: Entering SQL queries at the DBMS
the conceptual schema without having to change the interactive SQL interface (e.g. SQL*Plus in
external schemas and their application programs. ORACLE)

• PHYSICAL DATA INDEPENDENCE: The capacity to Programmer interfaces for embedding DML in
change the internal schema without having to change programming languages:
the conceptual schema.
• Pre-compiler Approach
When a schema at a lower level is changed, only the • Procedure (Subroutine) Call Approach
mappings between this schema and higher-level schemas
– Embedded Approach: e.g embedded SQL (for C, C++,
need to be changed in a DBMS that fully supports data
etc.), SQLJ (for Java)
independence. The higher-level schemas themselves are
unchanged. Hence, the application programs need not be – Procedure Call Approach: e.g. JDBC for Java, ODBC for
changed since they refer to the external schemas. other programming language

– Database Programming Language Approach: e.g.


ORACLE has PL/SQL, a programming language based on
DBMS Languages
SQL; language incorporates SQL and its data types as
1) Data Definition Language (DDL): Used by the DBA integral components
and database designers to specify the conceptual
schema of a database.
• In many DBMSs, the DDL is also used to define USER-FRIENDLY INTERFACES:
internal and external schemas (views).
• In some DBMSs, separate storage definition  Menu-based Interface - popular for browsing on the
language (SDL) and view definition language web; These interfaces presents the user with list of
(VDL) are used to define internal and external option called MENUS. Pull down menus are the very
schemas. important technique.
 Forms-based Interface - designed for naïve users;
2) DATA MANIPULATION LANGUAGE (DML): Used to These interface displays a form to each user. User
specify database retrievals and updates. can fill out all the entries to insert new data.
• DML commands (data sublanguage) can be  Graphics-based or Graphical User Interface (Point
embedded in a general-purpose programming and Click, Drag and Drop etc.) - It displays a schema
language (host language), such as COBOL, C or an to the user in diagrammatic form. Most GUIs use
Assembly Language. pointing device such as a mouse, drag and drop.
• Alternatively, stand-alone DML commands can be  Natural language: accept requests in written English
applied directly (query language). or some other language.
 Combinations of the above
SQL queries vs. DML statements vs. DDL commands
SOL QUERIES – Retrieve data from a database; FROM,
WHERE, ORDER BY or SELECT PARAMETRIC INTERFACES: parametric user such as bank
DQL COMMANDS – Create new database objects or tellers, often have a small set of operations that they
tables; ALTER, CREATE, DROP, TRUNCATE or RENAME must perform repeatedly. For this a small set of
DML STATEMENTS – Modify or update existing data in a abbreviated commands is included, with the goal of
table; CALL, DELETE, INSERT, MERGE or UPDATE minimizing the number of keystrokes required for each
request.

2 TYPES OF DML

o HIGH LEVEL OR NON-PROCEDURAL Interface for DBA: most database systems contain
LANGUAGES:, SQL, are set-oriented and specify privileged commands that can be used only by the DBA
what data to retrieve than how to retrieve. Also staff.
called Declarative Languages. Other DBMS Interfaces
o LOW LEVEL OF PROCEDURAL LANGUAGES:
record-at-a-time; they specify how to retrieve • Speech as Input and Output
data and include constructs such as looping. • Web Browser as an interface

Procedural Language: c, pascal, fortran, basic, cobol, ada,


lisp, assembly language, etc. DATABASE SYSTEM UTILITIES
Non-procedural: Java, c++, python, JavaScript, Ruby, • Loading data stored in files into a database.
Scala, Ocaml, PHP, C#, MYSQ2L, LISP Includes data conversion tools.
• Backing up the database periodically on tape.
• Reorganizing database file structures.
DBMS INTERFACES • Report generation utilities.
Stand-alone query language interfaces. • Performance monitoring utilities.

© claiming uno for ebriwan – misyel


• Other functions, such as sorting, user monitoring,  Printer Servers
data compression, etc.  Web Servers
 LOADING – A loading utility is used to load existing  E-mail Servers
text/sequential files into the database. Source  Clients can access the specialized servers as
format and desired target file are specified to the needed
utility, and the utility reformats the data to load into  DBMS Server
a table.
 BACKUP – A backup utility creates a backup copy of
the database, usually by dumping database onto CLIENTS:
tape. Can be used to restore the database in case of
failure. Incremental backup can be used which • Provide appropriate interfaces and a client-version of
records only the changes since the last backup. the system to access and utilize the server resources.
 FILE REORGANIZATION – This utility reorganize • Clients maybe diskless machines or PCs or Workstations
database files into different file organizations to with disks with only the client software installed.
improve performance.
 PERFORMANCE MONITORING – monitors database • Connected to the servers via some form of a network.
usage and provides statistics to the DBA. DBA uses (LAN: local area network, wireless network, etc.)
the statistics for decision-making. The DBA uses the
statistics in making decisions such as whether or not
to reorganize files or whether to add or drop indexes DBMS SERVER
to improve performance.
• Provides database query and transaction services to
the clients

OTHER TOOLS • Sometimes called Query and Transaction Servers

DATA DICTIONARY / REPOSITORY:

• Used to store schema descriptions and other TWO TIER CLIENT-SERVER ARCHITECTURE
information such as design decisions, application program
• User Interface Programs and Application Programs run
descriptions, user information, usage standards, etc.
on the client side
 Active data dictionary is accessed by DBMS
• Interface called ODBC (OPEN DATABASE
software and users/DBA.
CONNECTIVITY) provides an Application program
 Passive data dictionary is accessed by users/DBA
interface (API) allow client-side programs to call the
only.
DBMS. Most DBMS vendors provide ODBC drivers.

Application Development Environments and CASE


THREE TIER CLIENT-SERVER ARCHITECTURE
(computer-aided software engineering) tools:
• Common for Web applications
• Examples –Power builder (Sybase), Builder (Borland),
JDeveloper 10G (Oracle) • Intermediate Layer called Application Server or Web
Server:

• stores the web connectivity software and the rules and


Centralized and Client-Server Architectures
business logic (constraints) part of the application used to
CENTRALIZED DBMS: access the right amount of data from the database server

• combines everything into single system including- • acts like a conduit for sending partially processed data
DBMS software, hardware, application programs and between the database server and the client.
user interface processing software.
Additional Features-Security:
• A centralized database is stored at a single location
such as a mainframe computer. • encrypt the data at the server before transmission
• It is maintained and modified from that location only • decrypt data at the client
and usually accessed using an internet connection
such as a LAN or WAN.
• The centralized database is used by organizations CLASSIFICATION OF DBMSs
such as colleges, companies, banks etc.
Based on the data model used:

• Traditional: Relational, Network, Hierarchical.


Basic Client-Server Architectures
• Emerging: Object-oriented, Object-relational.
Specialized Servers with Specialized functions
Other classifications:
 Print Server
 File Servers • SINGLE-USER (typically used with micro-computers) vs.
multi-user (most DBMSs).
© claiming uno for ebriwan – misyel
• CENTRALIZED (uses a single computer with one ENTITY SET: a set of entities of the same type
database) vs. DISTRIBUTED (uses multiple computers,
Example: CAR Registration (RegistrationNumber, State),
multiple databases)
VehicleID, Make, Model, Year, (Color)

DISTRIBUTED DATABASE
ENTITIES are represented by means of rectangles.
• known as client server-based database systems Rectangles are named with the entity set they represent.
• they do not support a totally
ATTRIBUTES are the properties of entities. They are
distributed environment, but rather a set of
represented by means of ellipses. Every ellipse represents
database servers supporting a set of clients.
one attribute and is directly connected to its entity
• A distributed database is a collection of multiple
(rectangle).
interconnected databases, which are spread
physically across various locations that communicate  COMPOSITE ATTRIBUTES are further divided in a
via a computer network. tree-like structure. Every node is then connected
to its attribute. That is, composite attributes are
VARIATIONS:
represented by ellipses that are connected with
• Homogeneous DDBMS – all sites use identical DBMS an ellipse.
and OS  MULTIVALUED ATTRIBUTES are depicted by
double ellipse.
• Heterogeneous DDBMS - different sites have different
 DERIVED ATTRIBUTES are depicted by dashed
OS, DBMS products and data models.
ellipse.

CHAPTER 3: Data Modeling Using Entity-Relationship


KEY ATTRIBUTES: An attribute that are distinct/unique
(ER) Model
for each individual entity in the entity set
TYPE OF ATTRIBUTES
Example: ID_Number of Employee
1) COMPOSITE ATTRIBUTES: Can be divided into
WEAK ENTITY TYPES – an entity that cannot be uniquely
smaller subparts, which represent more basic
identified by its attribute. It is indicated by a double-
attributes with independent meaning
lined rectangle (entity) connected by a double-lined
Example: Name (FirstName, MiddleName, LastName) diamond (relationship).

2) SIMPLE/ATOMIC ATTRIBUTES: Attributes that are


not divisible
RELATIONSHIP – represents an association between two
Example: SSN or Sex or more entities.

3) MULTI-VALUED ATTRIBUTES: Can contain multiple Example: EMPLOYEE works on PROJECT


values
RELATIONSHIP TYPE is an concept of relationship.
Example: Color of a CAR
RELATIONSHIP DEGREE is the number of entities involved
4) STORED ATTRIBUTES: Attribute which are physically in the relationship.
stored in the database
ROLE NAMES: signifies the role that a participating entity
Example: Date of Birth from the entity type plays in each relationship instance.

5) DERIVED ATTRIBUTES: Attributes from which the RECURSIVE RELATIONSHIP: same entity type participate
value is calculated from other attributes. more than once in a relationship type in different roles.

Example: Age

6) NULL VALUES: A particular attribute may not have an Relationships are represented by diamond-shaped box.
applicable value for an attribute. Name of the relationship is written inside the diamond-
7) COMPLEX ATTRIBUTES: Formed by nesting box. All the entities (rectangles) participating in a
composite attributes and multi-valued attributes in relationship, are connected to it by a line.
arbitrary way.
Binary Relationship and Cardinality

A relationship where two entities are participating is


ENTITY TYPE: Defines a collection (or set) of entities that called a BINARY RELATIONSHIP.
have the same attributes.
CARDINALITY is the number of instance of an entity from
 Each entity type in the database is described by a relation that can be associated with the relation.
its name and attributes.
ONE-TO-ONE - When only one instance of an entity is
Example: PROJECT, EMPLOYEE entity type associated with the relationship, it is marked as '1:1'.

© claiming uno for ebriwan – misyel


ONE-TO-MANY - When more than one instance of an 6. Add additional constraints (cardinality and
entity is associated with a relationship, it is marked as participation) – Chen Style
'1:N'.

MANY-TO-MANY - More than one instance of an entity


on the left and more than one instance of an entity on
the right can be associated with the relationship. It is
marked as ‘M:N'.

CHAPTER 4: The Relational Data Model and Relational


Database Constraints

RELATIONAL MODEL – A database model developed by


E.F. CODD in the 1970s.

 It represents data as a set of tables, with each table


consisting of rows and columns. The relational model
is widely used in database management systems.
 It provides a structured way to store, manage and
retrieve data.

1. TABLE: In the relational model, data is stored in tables,


which are composed of rows and columns. Tables are
also known as relations.

2. ROWS: Each row in a table represents a single record


or instance of an entity, and is also known as a tuple.

3. COLUMNS: Columns represent the attributes or


properties of the entity being represented. Each column
contains data of a specific type, such as text, number, or
date.

4. PRIMARY KEY: A primary key is a column or set of


columns that uniquely identifies each row in a table. It is
used to enforce data integrity and ensure that each row
can be uniquely identified.

5. FOREIGN KEY: A foreign key is a column or set of


CARDINALITY CONSTRAINT corresponds to maximum columns in one table that refers to the primary key of
cardinality; how many times an entity occurs another table. It is used to create relationships between
tables.
Example: one to many, one to one, many to many
6. RELATIONSHIP: A relationship is a connection between
two or more tables, typically created using foreign keys.
PARTICIPATION CONSTRAINTS There are different types of relationships, including one-
to-one, one-to-many, and many-to-many.
TOTAL PARTICIPATION - Each entity is involved in the
relationship. Total participation is represented by double
lines. DOMAIN refers to the set of allowable values for a
PARTIAL PARTICIPATION - Not all entities are involved in particular attribute or column in a table. A domain has a
the relationship. Partial participation is represented by logical definition because it represents a set of values
single lines. that are valid for a specific attribute or column.

RELATION is a mathematical concept that is used to


represent the structure of data in a database. In the
GUIDELINES FOR CREATING ER DIAGRAM relational model, a relation is a set of tuples (or rows)
that have the same attributes (or columns).
1. Identify the entities – ALL Capital (Singular)
2. Identify the relationships
3. Describe the relationship – CAPITAL LETTERS
4. Add attributes (First Letter of a word is Capital) INFORMAL TERM FORMAL TERM
5. Refine diagram Table Relation

© claiming uno for ebriwan – misyel


Column Header Attribute dates might have a domain integrity constraint that
only allows dates in the format "YYYY-MM-DD".
All possible common values Domain
4. CHECK CONSTRAINTS: These constraints are used to
Row Tuple specify a condition that must be true for data to be
entered into a table. For example, a table of products
Table Definition Schema of a Relation
might have a check constraint that ensures that the
Populated Table State of a Relation price of a product is greater than zero.
5. ASSERTION CONSTRAINTS: These constraints are
used to ensure that more complex conditions are
CHARACTERISTICS OF RELATIONS met. For example, an assertion constraint could
ensure that the sum of all orders for a given customer
 Rows and columns: A relation is composed of rows
does not exceed their credit limit.
and columns. Each row represents a single record or
instance of an entity, while each column represents
an attribute or property of the entity.
KEY CONSTRAINTS is a type of integrity constraint that
 Unique Rows: Each row in a relation must be unique,
ensures that data in a table is unique and can be
meaning that no two rows can have exactly the
identified using a specific set of attributes or columns.
same values for all columns. This is enforced by the
use of a primary key, which ensures that each row TWO TYPES OF KEY CONSTRAINTS:
can be uniquely identified.
 Attribute Domains: Each column in a relation has a  PRIMARY KEY: is a column or set of columns in a
defined domain, which specifies the allowable values table that uniquely identifies each row in the table. It
and data type for the attribute. This helps ensure must be unique and not null. Each table in a database
data consistency and integrity. must have one and only one primary key. It can be a
 No Duplicate Columns: Each column in a relation single column or a combination of columns.
must be unique, meaning that no two columns can  FOREIGN KEY: is a column or set of columns in a table
have the same name and domain. that refers to the primary key of another table. It
 Order Independence: The order of the rows and establishes a relationship between two tables in a
columns in a relation is not significant. This means database. A foreign key can have the same values as
that the same data can be represented in different the primary key it refers to or it can be null if the
ways without affecting its meaning. relationship is optional.
 Operations: Relational databases support a set of
operations that can be applied to relations, including
selecting, projecting, joining, and aggregating data. RELATIONAL DATABASE SCHEMA is the blueprint or plan
These operations can be used to query and that defines the structure of a database, including the
manipulate data in a relational database. tables, columns, keys, and relationships between tables.
It is a visual representation of the database structure
that helps developers and database administrators to
RELATIONAL INTEGRITY CONSTRAINTS are rules that are understand the database and its components.
applied to data in a relational database to ensure that
the data is consistent, accurate, and complete. They are
used to maintain the quality and integrity of data in a POPULATED DATABASE STATE refers to a state of a
database, and to prevent data from being entered or database where it already contains data. In other words,
modified in ways that violate the rules of the database a populated database is a database that has already been
schema. populated with data, usually through data entry or
import from external sources.
1. ENTITY INTEGRITY CONSTRAINTS: These constraints
are used to ensure that each row in a table is unique
and can be identified using a primary key. For The basic operations for changing the database include:
example, a table of employees might have a primary
key of employee ID, which would ensure that each Insert: INSERTION is the process of adding new data to a
employee is uniquely identified. database.
2. REFERENTIAL INTEGRITY CONSTRAINTS: These
Update: UPDATING is the process of modifying existing
constraints are used to ensure that relationships
data in a database.
between tables are maintained. For example, if a
table of orders has a foreign key that references a Delete: DELETION is the process of removing data from a
table of customers, the referential integrity constraint database.
would ensure that every order is associated with a
Select: SELECTION is the process of retrieving data from a
valid customer.
database.
3. DOMAIN INTEGRITY CONSTRAINTS: These
constraints are used to ensure that data entered into Create: CREATING is the process of adding new database
a column of a table meets certain criteria or falls objects such as tables, views, indexes, and constraints.
within a specific domain. For example, a column of

© claiming uno for ebriwan – misyel


Alter: ALTERING is the process of modifying existing
database objects such as tables, views, indexes, and
constraints.

© claiming uno for ebriwan – misyel

You might also like