Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Assignment DDD

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

PROGRAM TITLE: BTEC-COMPUTING

UNIT TITLE: Database Design & Development

ASSIGNMENT NUMBER: 1

ASSIGNMENT NAME: ASSIGNMENT-AGC

SUBMISSION DATE: ……………………………………….

DATE RECEIVED: …………………………………………….

TUTORIAL LECTURER: LUONG THI THAO HIEU

WORD COUNT: ……………………………………

STUDENT NAME: TRAN BA HUNG

STUDENT ID: BKC11831


Summative Feedback:

Internal verification:
Table of Contents
I. INTRODUCTION.....................................................................................................................4
II. SYSTEM REQUIREMENTS.......................................................................................................4
1. Real-world scenario...........................................................................................................4
2. Data requirements for storage..........................................................................................5
3. Relationship between entities.........................................................................................11
III. DATABASE DESIGN...........................................................................................................13
1. Entity relationship diagram (ERD)....................................................................................13
2. Convert ERD Diagram to Relation Diagram.....................................................................13
3. Normalization...................................................................................................................14
4. Relational database system.............................................................................................15

I. INTRODUCTION
This is about the database management system. In here we have to create a database in a
proper way for the company called “AGC Company”. And it is a private construction firm in
Vietnam. So in this assignment, first we discussed the data models and their benefits and
disadvantages. Then explain about different types of technologies useful for the databases.
After that, we have identified the attributes, entities, cardinalities, and all, with the scenario
and draw ER Diagram for the company.

We created this database using SQL Server Management Studio use for creating management
reports for the company. We already added relational schema. And also we added a User
manual for how to use the database, the testing part is already done. In the final task, we
discussed how to verification and validation address to the database and some details about
access rights for the users.

P1. Design a relational database system using appropriate design tools


and techniques, containing at least four interrelated tables, with clear
statements of user and system requirements.

1. Data and Databases definition


In computing, data is information that has been converted into digital form, which make it more
efficient for processing or storing in a computer. Data requires interpretation before being
transformed into specific forms of information, such as text documents, images, audio clips, software
programs or other types of data.
A database is a collection of relevant data that is organized for the purpose of making it more easily
to be accessed, manipulated and updated. In other words, database is a data structure that allows
organizations to store, obtain and control information more efficiently.
There are different main types of databases:

1.1. Flat file databases

This is the simplest form with almost no protection for data integrity and security and often
contain redundancy.

1.2. Hierarchical Databases

Organized in tree-like structures, have same problems of redundancy, data integrity, and
comparability of data.

1.3. Relational Databases

Data is organized in tables that are related to each other. Each table has one or more columns
assigned as primary key.
1.4. Others

Object-oriented, Distributed, Network, etc.

2. Database Management System


Managing a huge database is an extremely complicated and arduous task. In order to deal with this
troublesome job, people came up with a technology solution called Database Management System
(DBMS). Basically, DBMS is a program or a collection of programs that is designed to optimize,
manipulate and manage the store and retrieval of data in database in a systematic way. A DBMS
allows end users to create, read, delete and update data. Users can interact with databases to
manipulate the data itself, the data format, file structure, etc. via an interface provided by a DBMS.

The actual manipulation will be handled by the DBMS.


2.1. Common Databases Management Systems

2.1.1. MySQL

MySQL is an open source relational database management system (RDBMS) that runs on a server
and is usually used for developing web-based software applications. It provides a very fast,
multithreaded and powerful SQL database server. PHP is often used along MySQL for cross-platform
applications.

Pros Cons
- Available for free - No built-in support for XML or OLAP
- Supports standard SQL - Need to pay for support
- Fast, reliable and easy to use - Difficult to debug
- Difficult to maintain
Handling a huge amount of data and good - Functionality heavily depends on add-ons
- data management.
-
Can work with other DBMSs like DB2, Oracle,
etc.
Customizable

2.1.2. Microsoft SQL Server

Microsoft SQL Server is an object-relational database management system (ORDBMS) developed,


distributed and supported by Microsoft Corporation. It is built for the basic function of storing and
retrieving data as required by other applications. This database management engine can run on local
servers as well as cloud-based servers or can be optimized to work on both at the same time. MS SQL
Server allows users to store and manipulate terra bytes of data with various types like videos, images,
text and much more.

Pros Cons
- Fast, stable and reliable - Enterprise editions is extremely expensive
- Provides excellent tools - Only run on Windows-based servers
- Easy to set up - Compatibility issues with applications running
- Work well with other MS products on non-Windows platforms
- Different editions available
- Great support for XML

2.1.3. Oracle

Oracle is one of the leading SQL relational database management systems that is commonly used
for running online transaction processing (OLTP), data warehousing (DW) and mixed (OLTP & DW)
database workloads. It is designed for the cloud and supports single/multiple server hosting. Oracle
allows control over an immensely huge amount of data with the help of latest features.
Pros Cons

- Fast, stable and convenient - Cost may be infeasible for small organizations
- Proven technology - Difficult to learn and use

- Latest innovations and features - Need specialized skills to install and maintain
- Exceedingly powerful tools - Require significant resources
- Available in a variety of versions
P2. Develop the database system with evidence of user interface, output
and data validations, and querying across multiple tables.

II. SYSTEM REQUIREMENTS

1. Real-world scenario

- The company's operations management system includes:


 AGC_Account
 AGC_Customer
 AGC_Employee
 AGC_Categories
 AGC_Product
 AGC_BillInfo
 AGC_BillProduct
 AGC_Order
 AGC_ImportProduct

2. Data requirements for storage

Entity Decription Attribute Description of Atribute


Entity

This is the unique username


Account_Username in the company
AGC_Account All account in Account_Password It is the password used to log
AGC company
into the system.
Account_Type Decentralization of accounts in
the company
Customer_ID It is the unique identifier for a
customer type
Customer_Name This is the full name of the
customer
Company_Name This is the Company name of
the customer
Company_Address This is the Company's address
AGC_Customer All customer in
Contact_Phone This is the phone number
AGC company
Company to contact

This is the email to contact the


company
Contact_Email

Customer_Username This is the unique username in


the company

AGC_Employee Employee_ID It is the unique identifier for a


employee type
All of the Employee_Name It is the full name of each
company's
employee type.
employee
BirthDate This is the employee's birthday
Employee_Address This is the employee's address
PhoneNumber This is the employee's phone
number
Employee_Email This is the employee's email
Employee_Username This is the employee's login
account to access the system

It is the unique identifier for a


AGC_Categories All of the category at the company.
Category_ID
company's
Category_Name It is the full name of each
categories
category type.
Descriptions This is the category
description

AGC_Product All products Product_ID It is the unique identifier for a


product
Category_ID It is the unique identifier for a
category at the company.
Product_Name It is the full name of each
product type.
Brand It is the brand of each product
type.
Year_Produce This is the year the product
was manufactured
Unit_Price This is the price of the product
Quantity This is the total output of the
product
Picture This is a place to store of
image of product

AGC_BillInfo It is the unique identifier for a


bill info at the company.
Bill_ID
All bill info for
the company
Bill_Date This is the time when you buy
the product.
Employee_ID It is the unique identifier for a
employee type.
Customer_ID It is the unique identifier for a
customer type.

It is the unique identifier for a


bill product at the company.
Bill_ProductID
AGC_BillProduct All bill product
It is the unique identifier for a
for the company
bill info at the company.
Bill_ID

Product_ID It is the unique identifier for a


product
Is_Setup This is used to see if customers
have setup it when they buy it.
Order_ID It is the unique identifier for a
AGC_Order All customer order ID at the company.
orders Customer_ID It is the unique identifier for a
customer type.
Product_ID It is the unique identifier for a
product
Quantity This is the total output of the
orders
Is_Setup This is used to see if customers
have setup it when they buy it.

All import Import_ID It is the unique identifier for a


AGC_ImportProduct product import ID at the company.
Detailed Import_Date This is the date when you
quotation of import products
each product
Customer_ID It is the unique identifier for a
customer type.
Employee_ID It is the unique identifier for a
employee type.
Product_ID It is the unique identifier for a
product
Quantity This is the total output of the
product
Total_Price This is the price of the product

3. Relationship between entities

- Product - Category: 
o A category will have many products. A product belongs to one category. So, the
relationship between category and product is the One - Many relationships. 

- Product - Supplier: 
o A supplier will have many products. A product belongs to one supplier. So, the
relationship between product and supplier is the One - Many relationships. 

- Invoice - Employee: 
o An employee will have many invoices. An invoice belongs to one employee. So,
the relationship between employee and invoice is the One - Many
relationships. 

- Invoice - Customer: 
o A customer will have many invoices. An invoice can only belong to one
customer. So, the relationship between customer and invoice is the One -
Many relationships. 

- Invoice – Invoice detail - Product: 


o An invoice will have many products. A product can belong to many invoice. So,
the relationship between invoice and product is Many – Many
relationships. Therefore, I create invoice detail entity. An invoice will have
many invoice detail. Each invoice detail can contain one product. So the
relationship between invoice and invoice detail is the One - Many relationships
and the relationship between invoice detail and product is the One - One
relationships. 

- Import - Employee: 
o An employee will have many import invoices. An import invoice belongs to one
employee. So, the relationship between employee and invoice is the One -
Many relationships. 

- Import - Supplier: 
o A customer will have many import invoices. An invoice can only belong to one
supplier. So, the relationship between supplier and import is the One - Many
relationships. 

- Import – Import detail - Product: 


o An import invoice will have many products. A product can belong to many
invoice. So, the relationship between invoice and product is Many – Many
relationships. Therefore, I create import detail entity. An import invoice will
have many import detail. Each import detail can contain one product. So the
relationship between import and import detail is the One - Many relationships
and the relationship between import detail and product is the One - One
relationships. 

III. DATABASE DESIGN

1. Entity relationship diagram (ERD)


-đưa ra định nghĩa ERD? ERD dùng để làm gì

- There are many tools for drawing ERD. I use the ERDPlus.com system to plot the ERD
diagram.
- My ERD:

2. Convert ERD Diagram to Relation Model

Relation Diagram là gì? Convert ERD sang Relation Diagram để làm gì?

- AGC_Employee (Employee_ID, Employee_Name, Birthdate, Employee_Address,


Phone_Number, Employee_Email, Employee_Username)
- AGC_Customer (Customer_ID, Customer_Name, Company_Name,
Company_Address, Contact_Phone, Contact_Email, Customer_Username) 
- AGC_Account (Account_ID, Account_Username, Account_Password, Account_Type) 
- AGC_Categories (Category_ID, Category_Name, Descriptions) 
- AGC_Product (Product_ID, Category_ID, Product_Name, Brand,
Year_Produce, Unit_Price, Quantity, Picture) 
- AGC_BillInfo (Bill_ID, Employee_ID, Customer_ID, Bill_Date) 
- AGC_BillProduct (Bill_Product_ID , Bill_ID, Product_ID, Is_Setup) 
- AGC_Order (Order_ID, Customer_ID, Product_ID, Quantity, Is_Setup) 
- AGC_ImportProduct (Import_ID Customer_ID, Employee_ID, Product_ID,
Import_Date, Quantity, Total_Price) 

3. Normalization

- Normalization is a database design technique that reduces data redundancy and


eliminates undesirable characteristics like Insertion, Update, and Deletion
Anomalies. Normalization rules divide larger tables into smaller tables and link them
using relationships. The purpose of Normalisation in SQL is to eliminate redundant
(repetitive) data and ensure data is stored logically.
- The three main types of normalization are listed below. Note: "NF" refers to "normal
form."
 First normal form (1NF):
Tables in 1NF must adhere to some rules:
 Each cell must contain only a single (atomic) value.
 Every column in the table must be uniquely named.
 All values in a column must pertain to the same domain.
 Second normal form (2NF):
Tables in 2NF must be in 1NF and not have any partial dependency (e.g. every
non-prime attribute must be dependent on the table’s primary key).
 Third normal form (3NF):
Tables in 3NF must be in 2NF and have no transitive functional dependencies on
the primary key.
- Now I will apply data normalization to the AGC company database:
 Table DEPARTMENTS (DEPARTMENT_ID, DEPARTMENT_NAME)
 Các bảng đã thỏa mãn chuẩn 1NF, 2NF, 3NF chưa vì sao?

4. Relational database system

a. Design Database.

DBMS Definition
A Database Management System (DBMS) is software designed to store, retrieve, define, and manage
data in a database.
Có các hệ quản trị cơ sở dữ liệu nào? Kể tên, có thể nói về ưu/nhược điểm và sau đó chọn hệ QT nào
để làm (SQLSERVER)

What is DBMS?

DBMS software primarily functions as an interface between the end user and the database,
simultaneously managing the data, the database engine, and the database schema in order to
facilitate the organization and manipulation of data.

Though functions of DBMS vary greatly, general-purpose DBMS features and capabilities should
include: a user accessible catalog describing metadata, DBMS library management system, data
abstraction and independence, data security, logging and auditing of activity, support for concurrency
and transactions, support for authorization of access, access support from remote locations, DBMS
data recovery support in the event of damage, and enforcement of constraints to ensure the data
follows certain rules.

A database schema design technique that functions to increase clarity in organizing data is referred to
as normalization. Normalization in DBMS modifies an existing schema to minimize redundancy and
dependency of data by splitting a large table into smaller tables and defining the relationship between
them. DBMS Output is a built-in package SQL in DBMS that enables the user to display debugging
information and output, and send messages from subprograms, packages, PL/SQL blocks, and triggers.
Oracle originally developed the DBMS File Transfer package, which provides procedures to copy a
binary file within a database or to transfer a binary file between databases.

A database management system functions through the use of system commands, first receiving
instructions from a database administrator in DBMS, then instructing the system accordingly, either to
retrieve data, modify data, or load existing data from the system. Popular DBMS examples include
cloud-based database management systems, in-memory database management systems (IMDBMS),
columnar database management systems (CDBMS), and NoSQL in DBMS.

RDBMS vs DBMS
A relational database management system (RDBMS) refers to a collection of programs and capabilities
that is designed to enable the user to create, update, and administer a relational database, which is
characterized by its structuring of data into logically independent tables. There are several features
that distinguish a Relational DBMS from a DBMS, including:

 Structure: Where data is structured in hierarchical form in a DBMS, data is structured in


tabular form in a RDBMS.
 User capacity: A RDBMS is capable of operating with multiple users. DBMS can only manage
one user at a time.
 Software/hardware requirements: A RDBMS has greater software and hardware
requirements.
 Programs managed: DBMS maintains databases within the computer network and system
hard disks. A RDBMS manages the relationships between its incorporated tables of data.
 Data capacity: A DBMS is capable of managing small amounts of data and a RDBMS can
manage an unlimited amount of data.
 Distributed databases: A DBMS does not provide support for distributed databases while a
RDBMS does.
 ACID implementation: A RDBMS bases the structure of its data on the ACID (Atomicity,
Consistency, Isolation, and Durability) model.

Difference Between Data and Information in DBMS


Data is raw, unprocessed, unorganized facts that are seemingly random and do not yet carry any
significance or meaning. Information refers to data that has been organized, interpreted, and
contextualized by a human or machine so that it possess relevance and purpose.

Information is filtered data that has been made systematic and useful, and is considered to be more
reliable and valuable to researchers as proper analysis and refinement has been conducted. A DBMS is
concerned with the manipulation of data in a database.

Difference Between Data Models in DBMS


A data model is an abstract model that organizes elements of data, documents the way data is stored
and retrieved, standardizes how different data elements relate to one another and to the properties of
real-world entities, and designs the responses needed for information system requirements. There are
three main types of DBMS data models: relational, network, and hierarchical.

 Relational data model: Data is organized as logically independent tables.


 Network data model: All entities are organized in graphical representations.
 Hierarchical data model: Data is organized into a tree-like structure.

Other data models include entity-relationship, record base, object-oriented, object relation, semi-
structured, associative, context, and flat data models. Database system architecture in DBMS is
categorized as either single tier, in which the DBMS is the only entity where the user directly sits on
the DBMS and uses it, or multi-tier, in which nearly all components are independent and can be
changed independently.

Features of Distributed Database Management System


A distributed database is a collection of related data in multiple interconnected databases that are
logically interrelated, but physically stored across multiple physical locations. Distributed databases
are categorized as either homogeneous, in which all the physical locations use the same hardware and
run the same operating systems and applications, or heterogeneous, in which each location may have
different data, software, and hardware structures.

A distributed database management system (DDBMS) refers to a centralized application that functions
to create and manipulate distributed databases, synchronize the database at regular intervals and
provide transparent access mechanisms to the user, ensure universal application of data
modifications, maintain data security and integrity of the database, can be accessed by several users
simultaneously, and is used in applications that process large volumes of data.

How is a DBMS Different from a Traditional File System?


A traditional filing system refers to early endeavors to computerize the manual filing system. File-
based systems typically use storage devices such as a CD-ROM or hard disk to store and organize
computer files and the data within with the goal of facilitating easy access.

A traditional file system is inexpensive, ideal for a small system with smaller quantity of parts, very low
design efforts, isolated data, and has a simple backup system, but is not secure, has a lack of flexibility
and many limitations, and has integrity flaws.

The benefits of DBMS over a traditional file system include: good for large systems, data-sharable,
flexible, has data integrity, and has a complex backup system. DBMS data security requirements
leverage the use of masking, tokenization, encryption, access control lists, permissions, firewalls, and
virtual private networks, making data storage and querying in DBMS a far more secure option than in a
traditional file system.

b. Database Diagram:
c. Implement a query language 

 SQL defines the following data languages to manipulate data 


of the RDBMS.  
 DDL: Data Definition Language 
 DML: Data Manipulation Language 
 TCL: Transaction Control Language 
 DCL: Data Control Language  
 DQL: Data Query Language 

 
   
 
 
 
 
 After design my database, I use DDL to create my database: 
Example: I use DDL create employee table 

- Create table AGC_Account

- Create table AGC_Customer

- Create table AGC_Employee


- Create table AGC_Categories

- Create table AGC_Product

- Create table AGC_BillInfo


- Create table AGC_BillProduct

- Create table AGC_Order

- Create table AGC_ImportProduct


a. Select 
Here are some example of how I use select query on my database: 
 Select all the record of table employee, customer and supplier 
 
 
 Select all the customers have the address “Ha Noi”. 

 
 
 
 
 Select name, phone number and address of the customers who have order
on 2020-10-22. 
 
 Select all the product with the price higher than average. 

 
 
 
 Select customers with the invoice they have. 
 
 
 
 Select information of all import invoice of supplier with employee who
created the invoice. 
 

 
 Count the number of product supplied by each company 

b. Insert 
 Insert into table customer 
 
 For example, your employee birthdate is later than date time then it
will caught error: 

 
 
c. Update 
 Update customer username of the customer with ID = 1  

 
d. Delete 
 Delete from table categories where category = 3 
Before delete 

 
 
After delete 
 
 

https://www.techopedia.com/definition/1221/normalization

You might also like