Introduction to Data Modeling Concept with Book Store Database

advertisement
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
Introduction to Data Modeling Concept with Book Store Database
-: NOTE :Altering, printing, sharing with anybody, any training institute or commercial use without written permission is 100% prohibited.
Please see the copy right information.
Written by
Zakir Hossain, Manager – Enterprise Architecture Configuration & Database,
US Dept. of Defense
CEO, Data Group
CS Graduate (OSU), ITIL V3, OCP, OCA, MCDBA, MCIPT (Database Admin), Security+
Other Certifications:
Oracle RAC Admin, Oracle Backup & Recovery Admin, Oracle Performance & Monitoring Admin,
Oracle Application Server Admin, System Admin (Windows/RedHat), Certified Java Programmer
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
1/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
Important Note:
1. A database consist of a minimum of two (2) files
a. Data File: You need at least 1 data file. By default every database will have only one
data file. However, you can add more data files as you need.
Data file contains all objects. Example, tables, views, indexes, stored procedure,
triggers, functions, security information etc
You may want to add more data files if your databases having poor performance. This
is one way to improve performance.
b. Log File: You need at least 1 log file. By default every database will have only one log
file. However, you can add more log files as you need.
Log file contains all activities occurring against a database. For an example, your
clients are inserting record, adding book records, customer records, order record
including all activities like delete, update, create etc. In a short, this file will contain all
DDL and DML operational activities.
First all these record will stay in the log file for a temporary period of time. Every 15
minutes or if log file gets filled up before 15 minutes, at that time data will be written
to the data file. Now these data are permanent and available for other users to view,
modify, delete etc.
You may want to add more log files if your databases having poor performance. This is
one way to improve performance.
2. File Group: A file group contains data file (s). However, a file group does not contain any log
file. A log file is directly stored in the HD (Hard Disk).
Lab Assignment:
As a Database Engineer/DBA/Analyst, our duty is to manage data storage, data, and securing data
as a guardian of data.
1. Create a database with the name call, DG_Book_Store (Initial of First and Last
Name_Book_Store)
2. Create required tables to manage all data related to a book store. Say you are a DBA,
working for Burns N Nobles. You need to manage their database.
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
2/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
As a DBA, what kinds of data, do you need to manage?
1. Book Data
2. Author Data
3. Order Data
4. Customer data
5. Employee Data
6. Supplier Data
7. Inventory Data
8. Shipment Data (Shipment data from publisher and Shipment data from Burns N Nobles to
their customers)
Book:
Book_id int NOT NULL IDENTITY SEED
Book_Number INT NOT NULL NOT UNIQUE
ISBN varchar (17) NOT NULL
Title varchar (100) NOT NULL
Publication_Date Date
Type varchar (25) NOT NULL – Database, Java, PHP, Networking, Windows Admin, Linux Admin, UNIX
Admin)
Comment varchar (500) NULL
Price Numeric (5, 2) NOT NULL
Quantity INT NOT NULL
Author:
Author_id int NOT NULL IDENTITY SEED
First_Name varchar (25) NOT NULL
Last_Name varchar (25) NOT NULL
Address varchar (125) NOT NULL
APT varchar (10) NULL
City varchar (50) NOT NULL
State varchar (2) NOT NULL
ZIP varchar (5) NOT NULL
Phone varchar (12) NOT NULL
Email varchar (50) NULL
DOB Date NOT NULL
Date_Died Date NULL
Book_Author:
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
3/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
Book_id int
NOT NULL NOT UNIQUE
Author_id int NOT NULL NOT UNIQUE
Order:
Order_id int NOT NULL IDENTITY SEED
Order_Date Date NOT NULL
Final_Price Numeric (10, 2) NOT NULL
Quantity INT NOT NULL DEFAULT 1
Total_Price Numeric (10, 2)
Ship_Date Date NOT NULL
Ship_Type varchar (25) NOT NULL (In Store, Ship)
Ship_Status varchar (25) NOT NULL (Shipped, Need to ship)
Customer_id int NOT NULL
Employee_id int NOT NULL
Book_id int NOT NULL
Customer:
Customer_id int NOT NULL IDENTITY SEED
First_Name varchar (25) NOT NULL
Last_Name varchar (25) NOT NULL
Address varchar (125) NOT NULL
APT varchar (10) NULL
City varchar (50) NOT NULL
State varchar (2) NOT NULL
ZIP varchar (5) NOT NULL
Phone varchar (12) NOT NULL
Email varchar (50) NULL
Employee:
Employee_id int NOT NULL UNIQUE
First_Name varchar (25) NOT NULL
Last_Name varchar (25) NOT NULL
Address varchar (125) NOT NULL
APT varchar (10) NULL
City varchar (50) NOT NULL
State varchar (2) NOT NULL
ZIP varchar (5) NOT NULL
Phone varchar (12) NOT NULL
Email varchar (50) NULL
Hire_Date Date NOT NULL
Term_Date Date NULL
Term_Note varchar (500) NULL
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
4/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
Home work:
1. Create a database conceptual design. Here you will gather all the requirements for this
data modeling project. For an example,
A. We need to follow the following metrics for the book table:
Column Name
Book_id
Data Type
INT
Book_Number
ISBN
Title
INT
Varchar
Varchar
Length
17
50
Comments
Mandatory field,
system will assign this
ID automatically
Mandatory field
Mandatory field
Mandatory field
2. Create a database logical design. Here you will create all the entities (tables) using any of
data modeling tool like Database Diagram, VISIO, ERWin, Oracle SQL Developer.
NOTE: Database Diagram cannot isolate between logical and physical design
3. Create a database physical design. Here you use the forward engineering technique
implement the database logical design to database physical design
4. Insert at least 10 records in each table. However, more is better. So, insert as many as you
can.
5. Smile  since you have completed the hardest of a database to become a DBA
Notes on Data Modeling:
Data Modeling Definition:
Data modeling is a process analyze data requirements needed to support a business processes. Therefore,
the process of data modeling requires professional data modelers. Data modelers/DBA/Database
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
5/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
Engineer/Database Developer work closely with business stakeholders and potential users of the
information system.
Data models are progressive; there is no such thing as the final data model for a business or application.
Instead a data model should be considered a living document that will change in response to a changing
business. The data models should ideally be stored in a repository so that they can be retrieved, expanded,
and edited over time.
Data modeling defines not just data elements, but their structures and relationships between them. Data
modeling techniques and methodologies are used to model data in a standard, consistent, predictable
manner in order to manage it as a resource. The use of data modeling standards is strongly recommended
for all projects requiring a standard means of defining and analyzing data within an organization, e.g.,
using data modeling
Types of Data Model:
There are three different types of data models while progressing from requirements to the actual database
to be used for the information system.
All three perspectives of data modeling are to be relatively independent of each other. Storage technology
can change without affecting either the logical or the conceptual schema. The table/column structure can
change without (necessarily) affecting the conceptual schema. In each case, of course, the structures must
remain consistent across all schemas of the same data model.
1. Conceptual data model: The data requirements are initially recorded as a conceptual data model
which is essentially a set of technology independent specifications about the data and is used to
discuss initial requirements with the business stakeholders.
Conceptual schema describes the semantics of a domain (the scope of the model). For example, it
may be a model of the interest area of an organization or of an industry. This consists of entity
classes, representing kinds of things of significance in the domain, and relationships assertions
about associations between pairs of entity classes. A conceptual schema specifies the kinds of
facts or propositions that can be expressed using the model. In that sense, it defines the allowed
expressions in an artificial "language" with a scope that is limited by the scope of the model.
Simply described, a conceptual schema is the first step in organizing the data requirements
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
6/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
6118 Franconia Rd, Suite: 217-A, Alexandria, VA 22310
Introduction to Data Modeling Concept with Book Store Database
2. Logical data model: The conceptual model is then translated into a logical data model, which
documents structures of the data that can be implemented in databases. To implement one
conceptual data model may require multiple logical data models.
Logical schema describes the structure of some domain of information. This consists of
descriptions of (for example) tables, columns, object-oriented classes, and XML tags. The logical
schema and conceptual schema are sometimes implemented as one and the same
3. Physical data model: The last step in data modeling is transforming the logical data model to a
physical data model that organizes the data into tables, and accounts for access, performance and
storage details.
Physical schema describes the physical means used to store data. This is concerned with
partitions, data files, file groups (SQL Server) or tablespaces (Oracle).
Need of Data Modeling:
1. It is a standard means of defining and analyzing data
2. to manage data as a resource
3. for the integration of information systems
4. for designing databases/data warehouses
Modeling methodologies:
There are two modeling methodologies:
1. Bottom-up data models are often the result of a reengineering effort. They usually start
with existing data structures forms, fields on application screens, or reports. These models
are usually physical, application-specific, and incomplete from an enterprise perspective.
2. Top-down data models, on the other hand, are created in an abstract way by getting
information from people who know the subject area. A system may not implement all the
entities in a logical model, but the model serves as a reference point or template.
Sometimes models are created in a mixture of the two methods: by considering the data needs
and structure of an application and by consistently referencing a subject-area model.
Unfortunately, in many environments the distinction between a logical data model and a physical
data model is blurred. In addition, some CASE tools don’t make a distinction between logical and
physical data models.
Email: info@DataGroupUSA.com Web: www.DataGroupUSA.com/helpdesk Phone: 703-986-9944
7/7
Copy Right: Printing, altering, sharing with anybody, any training institute or commercial use without written permission is a Federal Copy Right Violation of Intelligence Product.
Warning: Violators will be prosecuted with the fullest Extent of Federal Law.
Download