You are on page 1of 39

Database

Management
Content
 Organizing Data
 Designing Databases using Entity
Relationship Diagrams
 Identifying Keys in Tables
 Using MySQL Tools
 Querying Databases
Organizing Data
 Data Storage in a Computerized System
 For your business to be successful, fast access to
information is critical. You extract information from
existing data. Important decisions are based on the
information available to any point in time.
 In order to get the right information at the right time;
you can store data about the business on a computer
system. This aids in fast access to the information.
 Besides enabling data access, a computerized
system also helps you to manage data efficiently.
 Managing data involves storing, organizing, modifying
and deleting data.
Organizing Data
 Concept of a Database
A database is a collection of data. Two of your
major tasks, while using a computer system,
are to store and manage data.
 To handle these tasks, you need a
specialized computer program known as a
Relational Database Management System
(RDBMS)
Organizing Data
 Some popular RDBMS are:
 MicrosoftSQL Server
 Oracle Server
 Sybase
 Informix
 Postgres
 MySQL
Organizing Data
 In order to identify the data items that
needs to be stored; let us understand what
entities and attributes are.
 Entity
 The basic data item stored in a database is
called an entity.
 An entity can be any object, item, place,
person, concept, or activity about which data
can be stored.
Organizing Data
 Entity
 An entity is an object with a distinct set of
easily identifiable properties.
 Entities are building blocks of the database,
 Some exampled of entities are a product, a
student, a book, an author, a teacher, or an
applicant.
Organizing Data
 Guidelines for Identifying an Entity
 Identify the larger blocks in a scenario about
which data has to be stored.
 Identify the nouns in a problem statement.
Organizing Data
 Attribute
 An attribute is a property of an entity. It
describes a part of the entity.
 An entity could have 1 or more attributes.
 For example, some of the attributes of an
entity Product are ProductName, Price,
ExpiryDate
Organizing Data
 Guidelines for Identifying an Attribute
 Ina problem scenario, you may treat nouns
that describe the entity, as attributes.
Organizing Data
 Tables
 Data in an RDBMS is represented in the
forms of tables.
 You represent an entity in the form of a table
in the database.
 A table is a set of rows and columns.
 You represent the attributes of the entity as
column headings and the actual data about
the entity in rows.
Organizing Data
 Tables Table Name

Attribute Names
Organizing Data
 Tables
Attribute Names

Records/
Rows

Columns / Fields / Field Names


Organizing Data
 Tables
 Ifa value in any column is unknown it can be
represented by NULL
 Table and Attribute Naming Conventions
 Attribute and table names cannot contain
spaces.
Designing Databases using Entity
Relationship Diagrams
 To design a database, you need to
understand the database design
considerations and Entity Relationship
diagrams.
Designing Databases using Entity
Relationship Diagrams
 Database Design Considerations
 An understanding of business functions is an
important part of designing a database. When
you implement a database design, you have
to consider some points like the purpose of
the database, the performance needs of the
application, and the ease of maintenance.
Designing Databases using Entity
Relationship Diagrams
 Database Design Considerations
 Gathering information is one of the first steps
in designing a database. It is also important
for you to find out the expectations from the
automated system.
 The design of the database if normally a one-
time effort in the creation of the database.
You can make changes to the design at a
later stage, but it is not advisable because of
the cost you would incur, and the effort
required.
Designing Databases using Entity
Relationship Diagrams
 Database Design Considerations
 Gathering information is one of the first steps
in designing a database. It is also important
for you to find out the expectations from the
automated system.
 The design of the database if normally a one-
time effort in the creation of the database.
You can make changes to the design at a
later stage, but it is not advisable because of
the cost you would incur, and the effort
required.
Designing Databases using Entity
Relationship Diagrams
 Understanding the Need for Drawing
Entity Relationship Diagrams
 An ER diagram is a technique that you use as
a database designer to represent the logical
structure of the database of a system.
 It is a diagrammatic representation of the
database design.
 An ER diagram is like a blueprint for the
database.
Designing Databases using Entity
Relationship Diagrams
 Guidelines for Drawing ER Diagrams
 When gathering information, you have to:
1. Identify the entities in the system.
2. Identify the attributes of each entity.
3. Identify the relationships between the entities.
 In a relational database, the data items
stored for different entities can be related to
each other.
Designing Databases using Entity
Relationship Diagrams
 Guidelines for Drawing ER Diagrams
 You use an ER diagram to represent the
following three elements:
 Entities
 Relationships
 Attributes
Designing Databases using Entity
Relationship Diagrams
 Entities

Student Course
Designing Databases using Entity
Relationship Diagrams
 Attributes

StudentId StudentName

Student
Designing Databases using Entity
Relationship Diagrams
 Relationships

Name InstructorID StudentId StudentName

Instructor Teaches Student


Designing Databases using Entity
Relationship Diagrams
 Types of Relationships
 One-to-One (1:1)
 One-to-Many (1:m)
 Many-to-Many (m:m)
Designing Databases using Entity
Relationship Diagrams
 One-to-One Relationship (1:1)

1 1
Student Does Project
Designing Databases using Entity
Relationship Diagrams
 One-to-Many Relationship (1:m)

1 m
Department Has Employees
Designing Databases using Entity
Relationship Diagrams
 Many-to-Many Relationship (m:m)

m m
Customer Purchases Products
Designing Databases using Entity
Relationship Diagrams
 Deriving Tables From an ER Diagram for a
Database Structure
 One-to-One Relationship (1:1)
1 1
Student Does Project
Designing Databases using Entity
Relationship Diagrams
 One-to-Many Relationship (1:m)
1 m
Department Has Employees
Designing Databases using Entity
Relationship Diagrams
 Many-to-Many Relationship (m:m)
m m
Customer Purchases Products
Identifying Keys in Table
 Entity Integrity
Identifying Keys in Table
 Entity Integrity
 Ensures that each row can be uniquely
identified by an attribute called the primary
key.
 The primary key cannot be null.
 It is recommended that the data in the primary
key column be short.
Identifying Keys in Table
 Entity Integrity
Identifying Keys in Table
 Entity Integrity
Identifying Keys in Table
 Composite Key
 When the key that uniquely identifies the rows
of the table is made up of more than one
attribute, it is called a composite key.
Identifying Keys in Table
 Referential Integrity
 Ensuring that all values in the foreign key
match with the primary key values.
 Foreign Key
 Two tables can be related using a common
attribute.
 When a primary key of one table is also
available as an attribute in another related
table, it is called a Foreign Key
Identifying Keys in Table
Using MySQL Tools

You might also like