0% found this document useful (0 votes)
30 views

Database

The document discusses databases and relational database design. It explains that databases organize related information more efficiently than file-based systems by centralizing data. Relational databases represent data using tables with rows and columns, and relate tables using primary and foreign keys. Well-designed relational databases follow rules like having each column contain a single value and ensuring referential integrity between keys. The document also covers database concepts like schemas, queries, and structured query language (SQL).
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Database

The document discusses databases and relational database design. It explains that databases organize related information more efficiently than file-based systems by centralizing data. Relational databases represent data using tables with rows and columns, and relate tables using primary and foreign keys. Well-designed relational databases follow rules like having each column contain a single value and ensuring referential integrity between keys. The document also covers database concepts like schemas, queries, and structured query language (SQL).
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Seminar 3

Learning Objectives

Explain the importance and advantages of databases as well as the


Explain difference between database systems and file-based legacy systems.

Explain database systems, including logical and physical views, schemas, the
Explain data dictionary, and database management system (D B M S) languages.

Describe what a relational database is, how it organizes data, and how to
Describe create a set of well-structured relational database tables.

Query a relational database using visual methods as well as using structured


Query query language.
What Is a
Database?
• Efficiently and centrally coordinates
information for a related group of
files
• A file is a related group of records
• A record is a related group of fields
• A field is a specific attribute of
interest for the entity (record)

Copyright © 2021 Pearson Education Ltd.


File-Oriented
Systems
vs
Database Systems

Copyright © 2021 Pearson Education Ltd.


Figure 4.2 Basic Elements of Data
Hierarchy

Copyright © 2021 Pearson Education Ltd.


• Data warehouse is one or more very
large databases containing detailed
and summarized data for a number of

Using Data years used for analysis rather than


transaction processing.
Warehouse • Analyzing large amounts of data for
strategic decision making is referred to
for Data as data analytics.

Analytics • In data analytics, one can find a


vast array of sophisticated tools
that allow for multidimensional
analysis, complex calculations,
data projections, and simulations.
Advantages of
Databases
• Data is integrated
• Data sharing
• Minimize data redundancy and
inconsistencies
• Data is independent of the
programs that use the data
• Data is easily accessed for
reporting and cross-functional
analysis
Database Users and
Designers
• Different users of the database
information are at an external level
of the database. These users have
logical views of the data.
• At an internal level of the database
is the physical view of the data
which is how the data is actually
physically stored in the system.
• Designers of a database need to
understand users’ needs and the
conceptual level of the entire
database as well as the physical
view.

Copyright © 2021 Pearson Education Ltd.


Schemas


CEO, CFO
Conceptual-level—the
organization-wide view of the entire
database, lists all data elements
and the relationships among them.
• External-level—individual user’s
logical view of their portion of a Auditor view
database, each of which is referred
to as a subschema. - C - create new record
- R - Read
• Internal-level—low-level view of the - U - Update
- D - Delete
database, describes how the data
are stored and accessed, including
record layouts, definitions, IT
addresses, and indexes

Copyright © 2021 Pearson Education Ltd.


Three
Levels of
Schemas

Copyright © 2021 Pearson Education Ltd.


Access Rights

• Access rights are permissions


granted to create, read, update,
and delete data, database
records, or data files.
• There are four basic access rights
that can be granted in a
subschema:
• Create (C), Read (R), Update
(U), and Delete (D)

Copyright © 2021 Pearson Education Ltd.


Database Design

• To design a database, you need


to have a conceptual view of the
entire database. The conceptual
view illustrates the different files
and relationships between the
files.
• The data dictionary is a
“blueprint” of the structure of the
database and includes data
elements, field types, programs
that use the data element,
outputs, and so on.

Copyright © 2021 Pearson Education Ltd.


D BM S Languages
• Data Definition Language (DDL)
• Builds the data dictionary, creates the database, describes logical views, and
specifies record or field security constraints.
• Examples of DDL commands in structured query language (SQL) would be the
CREATE, DROP, and ALTER statements
• Data Manipulation Language (D M L)
• Changes database content, including data element creations, updates,
insertions, and deletions.
• SQL examples would include INSERT, UPDATE, TRUNCATE, and DROP
statements.
• Data Query Language (DQL)
• Contains powerful, easy-to-use commands that enable users to retrieve, sort,
order, and display data.
• An example of a DQL statement is the SELECT statement in the SQL language

Copyright © 2021 Pearson Education Ltd.


Relational
Database
• Represents the conceptual
and external schema as if
that “data view” were truly
stored in one table.
• Although the conceptual
view appears to the user
that this information is in
one big table, it really is a
set of tables that relate to
one another.

Copyright © 2021 Pearson Education Ltd.


Attributes/Fields

• Attributes are data elements that describe the characteristics


of instances/records in a table
• The full specification of attributes, i.e., a data dictionary, would
also include data type, default value (if any), constraints on
the value (such as minimum and maximum possible values),
and other descriptive information
• Attributes include the primary keys that uniquely define
instances of the class, foreign keys that support the links
between classes shown in the associations, and other data
elements for each class

3-15
Type of
Attributes
• A primary key is the
database attribute, or
combination of attributes,
that uniquely identifies a
specific row in a table.
• A foreign key is an attribute
in one table that is also a
primary key in another
table and is used to link the
two tables.

Copyright © 2021 Pearson Education Ltd.


Primary Keys

• An attribute or combination of attributes that uniquely


identifies each instance in a class or row in a table
• Possible to have more than 1 attribute as PK: Composite
Key
• A primary key cannot be NULL (blank)
• A primary key should be controlled by the organization
that assigns it so it will not change over time (consistent
structure)

3-17
Primary Keys

• Should you use social security numbers as primary keys?


• No, since there are legal restrictions and not everyone has a
social security number (so the primary key might by NULL)
• Should you use people’s names as primary keys?
• No, since names are not unique
• Should you use phone numbers as primary keys?
• No, since a person’s phone number may change over time
• Should you assign primary keys using sequential numbers?
• Yes, since it is easier to identify gaps and you control the number

3-18
Foreign Keys
• An attribute or combination of attributes that allows tables
to be linked together

3-19
Fundamentals of Relational Databases
Illustration of a Relational Database Using Primary and Foreign Keys for
Gizmos and Gadgets, a Phone Reseller

4-20
Relational Data Tables (1 of 2)

Copyright © 2021 Pearson Education Ltd.


Relational Data Tables (2 of 2)

Copyright © 2021 Pearson Education Ltd.


Why Have a
Set of Data stored in one large table can be
redundant and inefficient causing the
Related following problems:

Tables • Update anomaly


• Insert anomaly
instead of a • Delete anomaly

large table?

Copyright © 2021 Pearson Education Ltd.


Relational Database Design Rules

Every column in a row (every cell) must be single valued

Primary key cannot be null (empty), also known as entity integrity

If a foreign key is not null, it must have a value that corresponds to the value of a
primary key in another table (referential integrity)
All other attributes in the table must describe characteristics of the object
identified by the primary key

Following these rules allows databases to be normalized and solves


the update, insert, and delete anomalies.

Copyright © 2021 Pearson Education Ltd.


Class Practice
Normalization
Users might want specific information
found in a relational database and
not necessary to go through all the
files to get that information.
The answer is Data Query (ask a
question).
Queries
An example of a query might be: List
the invoice numbers, dates, and
salesperson for sales made to Lola
Doyle.

Copyright © 2021 Pearson Education Ltd.


Class Practice
Query
INTRODUCTION TO
SQL

You might also like