Download Customers Preferences Orders

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Oracle Database wikipedia , lookup

Open Database Connectivity wikipedia , lookup

IMDb wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Concurrency control wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database wikipedia , lookup

ContactPoint wikipedia , lookup

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Database model wikipedia , lookup

Transcript
Database System Concepts and Architecture
Different Database Models:
The relational database model is the most widespread and used of all the
database models. In relational databases, data is stored in tables (rows and
columns) and data is extracted from them by selecting columns and rows that
satisfy user-specified conditions.
Other major and older database models are:
Hierarchical Model:
Data is stored hierarchically with parent-child relationships between data items.
A hierarchical database consists of sets of records called record types organized as
nodes of a tree. Record types and records correspond to tables and rows in
relational databases
Example of simple databases that stored information about customers, their
orders and their preferences:
Customers
Customers
Orders
Preferences
Customers is a record type that stores customer information in records, one
record per customer. Each customer record is associated with records of two
types –Orders and Preferences. Each customer can have multiple orders and
preferences. Each record in Orders is associated with an order of the associated
customer and each record in Preferences corresponds to a preference of the
associated customer.
Consider the example of a student/course/grade data as described in:
Mr. Eric Tachibana 123 Kensington Chemistry 102 C+
Name
Mr. Eric Tachibana
Mr. Eric Tachibana
Mr. Eric Tachibana
Mr. Eric Tachibana
Ms. Tonya Lippert
Mrs. Tonya Ducovney
Ms. Tonya Lippert
Ms. Tonya Lippert
Address
123 Kensington
123 Kensington
123 Kensington
123 Kensington
88 West 1st St.
100 Capitol Ln.
88 West 1st St.
88 West 1st St.
Course
Chemistry 102
Chinese 3
Data Structures
English 101
Psychology 101
Psychology 101
Human Cultures
Chemistry 102
Grade
C+
A
B
A
A
A
A
A
Represent the following information using a hierarchical model? What problem
do you see?
How can we create a record for Ms Sharon Wood 23 East Avenue, who has not
enrolled for any courses yet?
Types of relationships: Redundancy would occur because hierarchical databases
handle one-to-many relationships well but do not handle many-to-many
relationships well.
This is because a child may only have one parent. However, in many cases you will
want to have the child be related to more than one parent. For instance, the
relationship between student and class is a "many-to-many". Not only can a
student take many subjects but a subject may also be taken by many students.
How would you model this relationship simply and efficiently using a hierarchical
database? The answer is that you wouldn't.
Network Databases:
The network database model is based on set theory. A network database consists
of a family of sets and each set consists of data called records. Sets and records
correspond to the tables and rows in a relational model. A record can belong to
more than one set and this defines a relationship. The network formed by these
relationships is what gives this database model its name.
The network model is very similar to the hierarchical model actually. In fact, the
hierarchical model is a subset of the network model. However, instead of using a
single-parent tree hierarchy, the network model uses set theory to provide a treelike hierarchy with the exception that child tables were allowed to have more
than one parent. This allowed the network model to support many-to-many
relationships, but it also made it more difficult to implement and maintain. But
they increase the complexity of the database.
Object Databases
The object database paradigm allows users to structure retrieve and update data
in terms of objects in the application domain. The object database model, based
on C++ or Java, does not have the simplicity or theoretical underpinning of the
relation database model.
XML databases:
The Extensible Markup Language (XML) is a text markup language designed for
specifying the syntax of data and electronic documents. XML is particularly useful
in describing semi-structured data. However, XML has proved to be so versatile
that it is being used extensively in a wide variety of domains such as e-commerce,
and other online applications.
Relational Model:
Representational models are the most widely used data models are the relational
models. This model is also a record-based data model based on relations (Tables)
in which data is represented as records. We will focus on this model from now on.
Data Models, Schemas, and Instances
DBMS provides some level of data abstraction by hiding details of data storage
that are not needed by most database users.
A data model – a collection of concepts that can be used to describe the structure
of a database. It provides the necessary means to achieve this abstraction.
Structure of the database means the data types, relationships and constraints
that should hold on the data. Most data models also include a set if basic
operations for specifying retrievals and updates on the database.
It is also common to define a set of valid user-defined operations that are allowed
on the database objects.
Categories of Data Models:
Data Models are categorized according to the types of concepts they use to
describe.
High-level or conceptual data models provide concepts that are close to the way
many users perceive data.
Low-level or physical data models provide concepts that describe the details of
how data is stored in the computer. These concepts are generally meant for
computer specialists.
Representational (implementation) data models: This model is between the
two, in that it can hide some details of storage but can be implemented on a
computer system in a direct way.
Conceptual data Models: use concepts such as entities, attributes and
relationships.
An entity represents a real-world object, such as employee, student, project, etc...
An attribute represents some property of interest that describes the entity, such
as the employee’s name or salary.
A relationship among two or more entities represents an interaction between
entities, for example worksOn is a relationship between an employee and a
project.
Physical data models describe how data is stored in the computer by representing
information such as record formats, record orderings and access paths.
An access path is a structure that makes the search of particular database records
efficient.
Schemas, Instances and Database State:
It is important to distinguish between the description of the database and the
database itself. The description of a database is called the database schema,
which is specified during database design and is not expected to change
frequently.
A diagram schema: is a way to display the database schema.
Consider the following example of a database that stores student records and
their grades.
STUDENT
Name
Smith
Brown
Student Number
17
8
COURSE CourseName
Intro to Computer
Science
Data structures
Discrete Mathematics
Database
SECTION
GRADEREPORT
SectionIdentifier
85
92
102
112
119
135
PREREQUISITE
Major
CS
CS
CourseNumber CreditHours
CS1310
4
Department
CS
CS3320
MATH2410
CS3380
CS
MATH
CS
CourseNumber
Math2410
CS1310
CS3320
MATH2410
CS1310
CS3380
StudentNumber
17
17
8
8
8
8
Class
1
2
4
3
3
Semester
Fall
Fall
Spring
Fall
Fall
Fall
SectionIdentifier
112
119
85
92
102
136
CourseNumber
CS3380
CS3380
CS3320
Year
98
98
99
99
99
99
Instructor
King
Anderson
Knuth
Chang
Anderson
Stone
Grade
B
C
A
A
B
A
PrerequisiteNumber
CS3320
MATH2410
CS1310
Corresponding schema diagram:
STUDENT
Name
Student Number
Class
Major
COURSE
CourseName
CourseNumber CreditHours
Department
PREREQUISITE
CourseNumber
PrerequisiteNumber
SECTION
SectionIdentifier CourseNumber Semester
Year
Instructor
GRADE_REPORT
StudentNumber SectionIdentifier Grade
A schema diagram displays only some aspects of a schema, such as the names of
record types and data items and some type of constraints. Other aspects, such as
the data type of each data item or constraints such as “a student majoring in
computer science must take CS1310 before the end of their sophomore year” are
not represented.
The actual data in the database may change quite frequently, each time we add a
student or enter a grade.
Database State: The data in the database at a particular moment is called
database state or snapshot. It is also called the current set of occurrences or
instances in the database.
When we define a new database, we specify its database schema only to the
DBMS. At this point the corresponding database state is the empty state with no
data. We get the initial state of the database when the database is first populated
or loaded with the initial data.
A valid state of the database is a state that satisfies the structure and constraints
specified in the schema.
The DBMS stores the description of the schema constructs or constraints- metadata- in the DBMS catalog.
DBMS Architecture and Data Independence:
The three schema Architecture: The goal of this architecture is to separate the
user applications from the physical database. Schemas are defined at the
following three levels:
1- The internal level has an internal schema, which describes the physical
storage structure of the database and access paths for the database.
2- The conceptual level has a conceptual schema, which describes the
structure of the whole database for a community of users. The conceptual
schema hides the details of the physical storage structures and focuses on
describing entities, data types, relationships, user operations and
constraints.
3- The external or view level includes a number of external schemas or user
views. Each external schema describes the part of the database that a
particular user group is interested in and hides the rest of the database
from that user group. A high-level data model or implementation data
model can be used at this level.
TRANSCRIPT
StudentName
Smith
Brown
Student Transcript
CourseNumber Grade Semester Year
CS1310
B
Fall
99
MATH2410
C
Fall
99
MATH2410
A
Fall
98
CS1310
A
Fall
98
CS3320
B
Spring
99
CS3380
A
Fall
99
SectionID
112
119
85
92
102
136
Transcript view
PREREQUISITE
CourseNumber
CS3380
CS3380
CS3320
PrerequisiteNumber
CS3320
MATH2410
CS1310
Prerequisite view
Data Independence:
Logical Data Independence: is the capacity to change the conceptual
schema without changing the external schema or application programs.
That is we can change the conceptual schema to expand the database (by
adding a record type or a data item) or to reduce the database (by
removing a record type).
GRADEREPORT
StudentNumber
17
17
8
8
8
8
StudentName
Smith
Smith
Brown
Brown
Brown
Brown
SectionIdentifier
112
119
85
92
102
136
CourseNumber
MATH2410
CS1310
MATH2410
CS1310
CS3320
CS3380
Grade
B
C
A
A
B
A
Only the view definition and the mapping need be changed in a DBMS.
Application programs that reference the external schema constructs must work as
before, after the conceptual schema undergoes a logical reorganization.
Physical Data independence: is the capacity to change the internal schema
without having to change the conceptual (or external) schemas. Internal schemas
or the physical data might be needed to re-organize the data to improve access
time for updates or other.
These multiple-level databases also require that the catalog be expanded to
include information on how to map requests and data among different levels.
Database Languages and Interfaces:
Data Definition Language (DDL): Used to define both the conceptual and internal
schemas.
Data Manipulation Language (DML): used to query the database for retrieval,
insertion, deletion, and modification of the data.
DBMS Interfaces:
Menu based Interfaces for Browsing: Present the user with lists of options, called
menus that lead the user through the formulation of a request. Menus do away
with the need to memorize the specific commands or syntax of query languages.
Form Based Interfaces: Displays a form to users. Users fill out all the form entries
to insert new data.