Docsity

Database Design and Management: ERD, Normalization, and SQL, Study Guides, Projects, Research of Database Programming

Toggle sidebar
bg1
Database assignments solution
report
Student id: 23110083
Student name: Mohammed Al-haj
Section number: 7
Table of Contents
Technical Documentation......................................................................................2
1 Introduction.....................................................................................................2
2 Database Requirement....................................................................................3
2.1 User and System Requirement................................................................3
2.2 Data Requirements..................................................................................3
3 Database Design.............................................................................................3
3.1 Conceptual Design...................................................................................3
3.2 Schema and Mapping............................................................................... 4
3.3 Logical Design..........................................................................................7
3.3.1 What is a logical design?......................................................................7
3.4 Physical Design........................................................................................7
3.4.1 What is a physical design?...................................................................7
3.5 Effectiveness of the design......................................................................8
4 Normalization..................................................................................................8
4.1 1st NF........................................................................................................8
4.2 2nd NF.......................................................................................................8
4.3 3rd NF........................................................................................................ 8
5 Physical Schema..............................................................................................8
6 Database Development...................................................................................8
6.1 Database Overview..................................................................................8
6.2 Security....................................................................................................9
6.3 User Interface..........................................................................................9
6.3.1 Flowchart and Data Movement Diagrams.............................................9
6.3.2 Interfaces Development.......................................................................9
7 Maintenance..................................................................................................10
7.1 Database recovery & backups...............................................................10
7.2 Database maintenance in general.........................................................10
8 Testing..........................................................................................................10
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

Partial preview of the text

Download Database Design and Management: ERD, Normalization, and SQL and more Study Guides, Projects, Research Database Programming in PDF only on Docsity!

Database assignments solution

 -  Student id: report -  Section number:  Student name: Mohammed Al-haj 
  • Technical Documentation...................................................................................... Table of Contents
  • 1 Introduction.....................................................................................................
  • 2 Database Requirement....................................................................................
    • 2.1 User and System Requirement................................................................
    • 2.2 Data Requirements..................................................................................
  • 3 Database Design.............................................................................................
    • 3.1 Conceptual Design...................................................................................
    • 3.2 Schema and Mapping...............................................................................
    • 3.3 Logical Design.......................................................................................... - 3.3.1 What is a logical design?......................................................................
    • 3.4 Physical Design........................................................................................ - 3.4.1 What is a physical design?...................................................................
    • 3.5 Effectiveness of the design......................................................................
  • 4 Normalization..................................................................................................
    • 4.1 1 st NF........................................................................................................
    • 4.2 2 nd NF.......................................................................................................
    • 4.3 3 rd NF........................................................................................................
  • 5 Physical Schema..............................................................................................
  • 6 Database Development...................................................................................
    • 6.1 Database Overview..................................................................................
    • 6.2 Security....................................................................................................
    • 6.3 User Interface.......................................................................................... - 6.3.1 Flowchart and Data Movement Diagrams............................................. - 6.3.2 Interfaces Development.......................................................................
  • 7 Maintenance..................................................................................................
    • 7.1 Database recovery & backups...............................................................
    • 7.2 Database maintenance in general.........................................................
  • 8 Testing..........................................................................................................

8.1 Data Validation...................................................................................... 10 8.2 Output Validation................................................................................... 10 8.3 Security Validation................................................................................. 11 8.4 GUI Validation........................................................................................ 11 8.5 Assess whether meaningful data has been extracted............................ 11 8.6 Assess the effectiveness of testing........................................................ 11 9 Evaluation of database solution.................................................................... 11 9.1 Effectiveness of the database solution based on user and system requirement...................................................................................................... 11 9.2 Suggested improvements...................................................................... 11 9.3 Evaluation based on improvements needed.......................................... 11 10 User Documentation.................................................................................. 11 10.1 System Overview................................................................................... 11 10.2 Using the system................................................................................... 11 10.3 Frequently asked questions................................................................... 12 10.4 Contact information............................................................................... 12

Technical Documentation

1 Introduction

After getting the Task as a junior in the “EDU Youth Foundation” to create a system for the donor tracking contributions. This document shows the details of creating a donor tracking database system. This system works on solving the issue of tracking things like event participation, and Donor’s contributions. Our aim is to make adding, deleting and manipulating data as easy and as efficient as possible. (make sure DBMS is implemented right) The donor tracking system will increase productive workflow and a decrease in errors related to data process like for example inserting new details or changing member details. Moreover, security will be improved by giving privileges to each user and personalizing permissions. This document will mention and provide the details and benefits of each table, the views, and procedures with the user privileges, and not to mention how the user interface the donor tracking system will work in detail. Although, I will take you with me in the process of thoroughly and carefully testing the database to ensure nothing goes wrong.

3.2 Schema and Mapping

Before we start mapping, why shall we do mapping? Mapping allows us to understand the complex Data, by converting the complex information into an understandable information [1]. What’s the primary key? A fundamental rule of storing data in a relational database is that you must be able to uniquely identify each row of data you store Therefore, each table is required to have a column that is known as the Primary Key for the table. Moreover, the primary key cannot have null as a value. Donors (Donor-ID, Full name, phone, email, career details) Event (Event-ID, Event name, Event date, Event begins, Attendance status) Donations (Donation-ID, Donation Amount, Donation type, payment method) Employees (Employee-ID, full name, email, phone, gender, salary, annual salary) Branches (Branch-ID, Branch address, status) Every underline attribute in the entities is called a primary key. 1- The first step in mapping is identifying weak entities and strong entities. However, all the entities we have are strong so we can skip this step. How can we know if it’s a strong or weak entity? if the entity had nonprimary keys or more than one primary key then it’s considered a weak entity, if it had one primary key it’s considered a strong entity. 2- The second step is mapping derived attributes. Derived attributes are the attribute that can be calculated. Donors (Donor-ID, Full name, phone, email, career details) Event (Event-ID, Event name, Event date, Attendance status) Donations (Donation-ID, Donation Amount, Donation type, payment method) Employees (Employee-ID, full name, email, phone, gender, salary) Branches (Branch-ID, Branch address, status) Note: - event begins, annual salary were the derived attributes, so we removed them 3- The third step is mapping composite attributes. Composite attribute is the attribute that can be broken down into parts. Donors (Donor-ID, first name, last name, phone, email, career details)

Event (Event-ID, Event name, Event date, Attendance status) Donations (Donation-ID, Donation Amount, Donation type, payment method) Employees (Employee-ID, first name, last name, email, phone, gender, salary) Branches (Branch-ID, Street name, building number, status) Note: - our composite attributes were the full name of both attributes, the donor and employee and the address in the branch entity. 4- The fourth step is mapping of multivalued attributes. Multivalued attributes are the attribute that may hold more than one value. Donors (Donor-ID, first name, last name, career details) Event (Event-ID, Event name, Event date, Attendance status) Donations (Donation-ID, Donation Amount, Donation type, payment method) Employees (Employee-ID, first name, last name, email, gender, salary) Branches (Branch-ID, Street name, building number, status) Donors-phone (Donor-ID, phone) Donors-email (Donor-ID, email) Employee-phone (Employee-ID, phone) note: - we had multivalued attributes, so we separated them into two tables (the phone for both the employee and the donor and the email for just the donor). The coloured attribute in the multivalued table is considered a foreign key and primary key. 5- Mapping of 1-N Relationship Types. Donors (Donor-ID, first name, last name, career details,) Event (Event-ID, Event name, Event date, Attendance status) Donations (Donation-ID, Donation Amount, Donation type, payment method, Donor-ID) Employees (Employee-ID, first name, last name, email, gender, salary) Branches (Branch-ID, Street name, building number, status, Employee-ID) Donors-phone (Donor-ID, phone) Donors-email (Donor-ID, email) Employee-phone (Employee-ID, phone) Note: - there’s a 1: N relation between the branch entity and the employee so we put the Primary key of the employee entity which is Employee-ID in the branch table and the primary key of the employee became a foreign key in the branch table. Also, 1:N relation between the donor with the donations

components is the ERD (Entity-relationship-diagram), Defines data models, tables (entities), columns (attributes), and relationships between entities. Haere’s a figure of the logical design we have for the donor tracking system: - Here is what the logical design looks like, as we see all the relations are a 1:M relations ships that’s what does the mapping and the normalization changes which make a difference which makes the database more scalable. As we can see, the design accurately represents the identified user and system requirements. A donor full info, donor-engagement and how scalable the system would be according to the database.

3.4 Physical Design

3.4.1 What is a physical design? the physical design is basically how the logical design will be implemented, as we mentioned the logical design component ERD define the tables and it’s columns, so the physical model adds the data types of these columns and their constraints such as the primary key. Moreover, physical design makes sure that the data doesn’t get out of range. Furthermore, physical design grants security features for the database system including account creation, privilege granting [3]. Now let’s show a figure of the physical design: -

As we can see in this figure there’s a difference from the logical design, we have datatypes such as the (INT, Varchar and the number between the parentheses in the varchar is what ensures that the data doesn’t get out of range), also as we notice there’s a dote line which means that the strong tables relate to each other.

3.5 Effectiveness of the design

The system is to track and monitor the donor contributions from donations and events which is being monitored by different employees, for that particular reason we made sure that the database contains all the tables that must be inserted to have a logical database. Since it’s a tracking donor database we made sure that detailed information is stored in the tables columns such as the donor name and donor contact information in general, detailed information has also been applied on the employee that’s monitoring and tracking he donations which something we must do in the database since it’s a sensitive data and must be secured. In our database every relation has been mase for a reason let’s see every relation we have in our conceptual design and explain why we chose a 1:1, 1:M or M: N relationships. Let’s start with the donor and donations relation, one donor can make multiple donations in here you might ask why is it a one-to-many relationship? A donor in the system is stored as one who makes the donation, so the system doesn’t consider the people who contributed with these donations. For the second relationship the donor and event’s since the donor can contribute or attends to many events for example, donor contributing by donating a charity and an educational event the system will document the event that has been attended. For the third relationship is between the donations and employees logically it should be a many-to-many because the employees who monitors the system can manage many donations and those donations can go through by many employees.

Evaluating the effectiveness of the can lead us to see mistakes in our database design and as we saw the database design is an effective design since everything has been done according to the requirements.

4 Normalization

4.1 1 st^ NF

Relations Attributes Violation description Solution – Relations The relations schema The attribute name Describe why it is not in the 1st^ NF (the violation) Show the schema for each affected relation. Donors (Donor-ID, phone, first name, last name) phone Since the phone is a multivalued attribute we must separate it in a table, and the primary key will become foreign key Donors (Donor-ID, first name, last name) Donor-phone (Donor-ID, phone) Employees (Employee-ID, full name, email, phone, gender, salary, annual salary) Full name In here the full name is a composite attribute Employees (Employee-ID, first name, last name, email, phone, gender, salary, annual salary)

4.2 2 nd^ NF

Relations FDs Violation description Solution – Relations The relations schema Show the functional dependencies causing the violation Describe why it is not in the 2nd^ NF (the violation) Show the schema for each affected relation. Donations The donation- The fields first Donation

(Donation-ID, Donation Amount, Donation type, payment method, Donor-ID, first name, last name, career details) id(Donation amount, type, payment method) Donor-id( first name, last name, career details) name, last name, and career details, which is the non-prime attributes do not depend on the whole primary (partial dependency) key of Donations but only on Donor-ID. ( donation-id , donation amount, type, payment method) Donor ( Donor-id , first name, last name, career details) Event (Event-ID, Event name, Event date, Donor-ID, First name, last name, career details) Event-ID (event name, event date) Donor-ID (first name, last name, career details) Event name, Event date, which is the non-prime attributes depend only on Event-ID. First name and last name depend only on Donor-ID. Which leads to partial dependencies. ( Event-ID , event name, event date) ( Donor-ID , first name, last name, career details) Event Donor ( Event-id, donor-id )

4.3 3 rd^ NF

Relations FDs Violation description Solution – Relations The relations schema Show the functional dependencies causing the violation Describe why it is not in the 3rd^ NF (the violation) Show the schema for each affected relation. Donations (Donation-ID, Donation Amount, Donation type, payment method, Donor-ID, first name, last name, career details) The donation- id(Donation amount, type, payment method) Donor-id( first name, last name, career details) The nonprimary attributes (donation amount, donation type, payment method) depends on the primary key donation-id The first name and last name and career datils depends on the donor-id. However, the Donation ( donation-id , donation amount, type, payment method) Donor ( Donor-id , first name, last name, career details)

2- DML (Data manipulation language), DML is used for accessing and manipulating data in a database (select, insert, update, delete). 3- DCL(Data control language), DCL is used for granting and revoking user access on a database (Grant, Revoke). here’s an example of how to create a database: - After creating the database, it will be shown in our schemas Now we will implement our tables and columns in the (Donor_System_Track) database, first you want to make sure that you’re using the database you want to work on. How do you know which database you’re using? Looking at the schemas you’ll see a bold database, the bold database is the database where you’re implementing ERD model in, to reach the database you’ll insert this query in the workbench: - Now after knowing how to create and reach the database let’s start implementing our tables and columns. Laet’s start with tables at first, the table contains in it the columns and each column are written with appropriate primary keys, foreign keys, data types and constraints. Example of creating tables in SQL including the columns and the appropriate data: - To add a foreign key in the database there’s two ways, let’s have an example and explain them: - 1-

in here it’s the formal way to add a foreign key in the table, in the context (foreign key (name of the foreign key) reference which the foreign key is originally from (table name) and (the primary key in the table that became a foreign key)). The other way to add a foreign key is used if you already created the table and didn’t add the foreign key. The other way to add a foreign key is used if you already created the table and didn’t add the foreign key. 2- In every table that you add a foreign key on you should use the query (on update cascade on delete cascade). This query makes sure if any update happens or deletions it compiles it with the rest of the children on the table. To be more specific, every change happens in the parent happens in the child’s table. Now let’s see how our final physical schema looks like using the in MySQL: - here’s the tables using the reverse engineer after inserting our DDL database language to create, alter and drop.

the columns by going to the schematableschose table and press the arrowcolumns and press the arrow, and the order of columns will be shown: Multi valued insert: As we can see, the donor can have multiple phone numbers so you must make sure that you have a composite primary key, because you’ll have both primary keys. Here’s how it look like in the query: 1:M valued insert: In the 1:M relation before inserting value you should make sure that the value in of the foreign key already has an inserted values in the parent table. Like in the example the donation wanted to inset the number 3 which is in this case the Donor-Id but we need to make sure that the foreign key already have the ID =3 in the main table which is the donor table. M:N valued insert: In the M:N insert is like the 1:M but in here both values considered a child so you can’t insert a value unless it’s already in the parent table. update statement :

In here I inserted the email of [email protected] to the wrong donor-ID, so I used the update statement to give this email to the right donor-id which is 2 with sing the update statement as it’s shown in the figure above, Also, the where statement is very important because if I omitted the where clause of the records will be set to the same donor-ID value. Delete statement: The email isn’t useful to me anymore so I deleted it from the records using the delete clause and of course I used it along with the where clause because if I omitted where clause all of the records will be deleted along with the email. Also, because I had two conditions have the ID=2 I specified more with the AND, The AND operator gives the record if all the conditions separated by AND are TRUE. Select statement: The select statement is used to select stored data from a database. Select statement can have multiple syntaxes depending on the data results you want: 1- In here the select statement will represent all the records from all the columns in the table donors 2- In here the data will be represented are the data from the donation-id column from the donations table:

2. Donations This table is made to store details about donations made by donors. 1- Donation-ID: a unique identifier to identify each donation that happen to reach each donation faster has an (int) data type to ensure only numbers is written and to make sure these numbers are uniquely identified a primary key constrain is inserted with a Not null constrain because it’s a sensitive data that has to be inserted. 2- Donation-type: Type of donation can be done as an example, (money, clothes, books), identified with a varchar data type with a limitation of (15 characters) and of course a not null constrain. 3- Payment method: The method used for payment (visa, cash, PayPal), identified with a varchar data type with a limitation of (20 character), also a not null constrain because it’s a sensitive data that can’t left null. 4- Donation-amount: The amount of the donation that is donated by the donor, it’s defined by an int datatype to make sure only numbers is inserted with a Not null constrain to keep sensitive data secure and not kept as null. 5- Donor-ID: in here the donor that makes the donation is a foreign key constrain that Links the donation to a specific donor. 3. Donors This table is made to store information about individuals who donate to the organization. 1- Donor-ID: A unique identifier for each donor that is created to track each donor and his contributions through events and other, which is identified with a (int) datatype and a primary key constrain to make sure each donor has his own ID. 2- First name: The first name of the donor identified with a varchar datatype with limit of (10 character), and a not null constrain. 3- Last name: The last name of the donor identified with a varchar datatype with limit of (10 character), and a not null constrain.

4- Career details: a description of the donor career (occupation), identified with a varchar data type with a limit of ( characters) and a not null constrain.

4. Employees This table is made to store employee information. 1- Employee-ID: A unique identifier for each employee, to reach and manage employees faster with no complications, identified with (int) primary key and a primary key constrain to make sure not to conduct any ID with another employees-ID 2- First name: The first name of the employee identified with a varchar data type with a limit of (50 characters) and a not null constrain. 3- Last name: The last name of the employee identified with a varchar data type with a limit of (50 characters) and a not null constrain. 4- Email: The email address of the employee, identified with a varchar data type with a limit of (30 characters) and a not null constrain. 5- Gender: The gender of the employee, identified with a varchar data type with a limit of (15 characters), also it has a check constrain to make sure the insert value is inserted right in the database here’s the check constrain that also identified with a not null constrain, CHECK (gender='Male' OR gender='Female'). 6- Salary: The salary of the employee identified with int data type and a not null constrain. 5. Donor_ email This table is made to store multiple email addresses for each donor: 1- Donor-ID: Links the email to a specific donor in the parent table identified with an int datatype along with a primary key constrain the same constrain from the parent table. Also, it’s a foreign key constrain to link the email to a specific donor that connects with the parent table which is the (donors table) 2- Email: A unique email address that is