+ All Categories
Home > Documents > By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant...

By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant...

Date post: 09-Jul-2020
Category:
Upload: others
View: 11 times
Download: 0 times
Share this document with a friend
44
Module Title: Databases & SQL Assignment Title: Case Study: Server database Example Module Leader: M. Nawaz Module Code: HSQ A Taxi Company Database (Partial) – Text a Taxi and Vehicle Servicing By: David Grylls F6106630 Date: 11/01/2008
Transcript
Page 1: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Module Title: Databases & SQL Assignment Title: Case Study: Server database Example Module Leader: M. Nawaz Module Code: HSQ

A Taxi Company Database (Partial) – Text a Taxi and Vehicle Servicing

By: David Grylls F6106630 Date: 11/01/2008

Page 2: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Table of Contents Section 1. Introduction 2. Entity Relationship Diagram & Entity 3. Entities Registered Customer Customer Address Address Employee Staff Type Taxi Pickup Points Taxi Destination Journey Charges Tariff Rates Tariff Types Taxi Driver Vehicle Vehicles Service History Service Booking Vehicle Parts Parts Supplier 4. Microsoft SQL Server (Query Analyzer) Insert script example – Tariff Types Drop table Select, From, Where Count Insert Like Update Delete Order By Joining Tables Create Table Alter Table Drop Column Distinct Create index Drop Index In Not In 5. Linking MS SQL to MS Access 6. Detach & Attach MS SQL Server Database 7. Conclusion 8. Appendix & Reference

Page 3: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

1. Introduction A database has been developed for a taxi hire company. The Taxi company uses a service called ‘Text a Taxi’ and the database has been developed for this service and the servicing of its vehicles only. The database will hold registered customer details, employee details, vehicle details, vehicle service details and supplier details. Initial Design When designing the initial data model I used databaseanswers.org for ideas of various models before designing final data model. The Taxi Service model was initially used and the certain aspects of the Car Service Centre were incorporated into Taxi Service model. See appendix for design. From the initial design it was necessary that several tables should be incorporated into one table as to avoid clutter and unnecessary tables. The Mechanic’s Taxi Drivers and Call handler’s tables were all removed and Employee table was created. The Frequently Visited Address & Regular Customers were also removed as this would not be appropriate for the ‘Text a Taxi’ service that this database is designed on. Internet Registration was also removed and replaced with Registered Customers as customers have to register details by phone to use this service. The internet registration service will available at some point in the future. The Journey and Charges table were also incorporated together as no need to have separate tables. The registered customer will be able to text a location where they would like to be picked up from and a taxi will be dispatched to the address held on the database for the specified location. The vehicle servicing aspect of the database will show which mechanic completed a service on the vehicle, what parts were used and who the supplier was for the parts. The Taxi Company will also be able to identify which driver was involved in a customer pick up, what address they were picked up from, the time of pick up and drop off and the journey cost and distance.

Page 4: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

2. Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text a location where they would like picking up from. The Taxi Company can then obtain the customers details and send the relevant taxi to the address held.

Page 5: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

2. Entity Below I have attempted to illustrate all of the tables and relationships present im the Taxi Company Database. MS SQL was used to create the tables and produce the diagram below. Here you can see the relationships between the tables. (Please see database diagrams for a clearer copy).

Page 6: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

3. Entities

Registered Customer Entity Registered Customer Diagram 1

Customer Address Entity Customer Address Diagram 2

Entity’s left Registered Customer Diagram 1, Customer Address Diagram 2 and overleaf Address Diagram 1 were created for customers who have currently registered with taxi company by phone and for customers who will be added in the future by integrating database to a Website. Once customers have registered, customers can then use the ‘text a taxi’ service. Customers can provide multiple addresses and by simply texting ‘home’, ‘work’, ‘friend’ ect…to the taxi company, a taxi is dispatched to the relevant address. .

Page 7: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Address Entity Address Diagram 1

Many customers may provide the same address as other customers, for example friends addresses, this can be done easily using the Address_id.

Page 8: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Employee Entity Employee Diagram 1

The entity in Employee Diagram 1 stores all current employee information.

Page 9: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Staff Type Entity Staff Type Diagram 1

Staff Type Diagram 1 stores the employee job title information. This should have been incorporated within the Employee Entity instead of creating an unnecessary table.

Taxi Pickup Points Entity Taxi Pickup Points Diagram 1

Taxi pickup points stores customer pick up time information

Page 10: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Taxi Destination Entity Taxi Destination Diagram 1

Taxi Destination stores all customer destination

drop off times.

Journey Charges Entity Journey Charges Diagram 1

The Journey Charges Entity holds all journey charges information, distance travelled, tariff rate and driver information.

Page 11: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Tariff Rates Entity Tariff Rates Diagram 1

The Tariff Rates entity contains vehicle information to determine a tariff amount.

Tariff Types Entity Tariff Types Diagram 1

The Tariff Types entity holds all tariff charges added to each journey when destination reached.

Page 12: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Taxi Driver Vehicle Entity Taxi Driver Vehicle Diagram 1

The Taxi Driver Vehicle entity store taxi driver and vehicle information.

Page 13: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Vehicles Entity Vehicles Diagram 1

Vehicles entity holds all vehicle information currently availableincluding, road tax, insurance, MOT and next service date information. Also which driver is currently assigned to which vehicle. Further vehicles can be added or removed when necessary.

Page 14: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Service History Entity Service History Diagram 1

Service History stores details of vehicles last service, including which mechanic undertook the last service.

Service Booking Entity Service Booking Diagram 1

Service Booking entity holds information about a vehicles next service, including date and time vehicle is booked in for and which mechanic is due to complete service.

Page 15: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Vehicle Parts Entity Vehicle Parts Diagram 1

Vehicle Parts entity stores the part number used in service of a vehicle.

Parts Entity Parts Diagram 1

Parts entity stores all parts information and stores supplier details for re-ordering.

Page 16: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Supplier Entity Supplier Diagram 1

Supplier entity holds all supplier’s used by taxi company.

Page 17: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

4. Microsoft SQL Server (Query Analyzer) Code used to insert data – all other insert scripts can be found in the appendix

Tariff Types Table

Page 18: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Drop Table SQL code used to delete table not being used.

Page 19: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Select, From, Where

Tables – employee Condition – to select all mechanic’s working for Taxi Company

Page 20: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Count

Tables – Registered Customers Condition – To count the total number of customers currently registered with Taxi Company

Page 21: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Insert

Tables – Registered Customers Condition – Insert a new customer into the database

Page 22: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Like

Tables – Address Condition – Search for customers whose postcode contains ‘DL’

Page 23: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Update

Tables – Vehicles Condition – update vehicle ‘EX05 PYR’ detail, tax expiry date and insurance expiry dates

Page 24: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Delete

Table – Employees Condition – Delete employee whose employee id is ‘CH010’ and mobile number is ‘07767568995’

Page 25: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Order By

Table – Employees Condition – Search in employees detail, display results in order by surname’s.

Page 26: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Joining Tables

Table – Vehicles, Service_booking Condition – select fields from both tables and display results from both tables. In this example, all make Ford vehicles are displayed with the date if service.

Page 27: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Create Table

Table – Driver_Waiting_List Condition – create a new table Driver Waiting List Table for drivers seeking employment.

Page 28: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Alter Table

Table – Registered Customers Condition – ADD a new field in registered customers table, name this field ‘special requirements’ which will contain information about the customer i.e wheel chair vehicle required.

Page 29: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Drop Column

Table – Vehicles Condition - Drop column named vehicle condition from ‘vehicles’ table

Page 30: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Distinct

Table – Employees Condition – select and display all records of ‘staff type id’

Page 31: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Create index

Table – Driver_Waiting_List Condition – Create and set DW_no to be Primary Key of table

Page 32: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Drop Index

Table – Driver_Waiting_List Condition – Disable current Primary Key DW_no

Page 33: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

In

Table – Address Condition – display address id’s for customers who live in Hartlepool

Page 34: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Not In

Table – Address Condition - display address id’s for customers who do not live in Hartlepool.

Page 35: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

5. Link Taxi database from MS SQL to MS Access A new MS Access was selected and Project (existing data) selected

Page 36: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

The server name is entered and name of database taxi selected.

Page 37: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

All information is now available in MS Access.

Page 38: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Having now connected the tables to MS Access I am now able to develop the tables either in MS Access or in MS SQL. Any changes will be reflected in both platforms.

Using MS Access gives a quick and easy way to modify and insert records in to a database.

Page 39: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

6. Detach & Attach the taxi MS SQL Database Select the database taxi

Select ok to detach

Page 40: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Locate the Taxi database which has now been detached and it can now be moved, copied, deleted etc..

To attach to another server/computer network the open MS SQL Server and then the following is completed

Page 41: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

Select the Taxi mdf file.

Database to be attached are now shown, selecting OK will attach database to server.

Page 42: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

The Taxi Database is now attached.

Page 43: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

7. Conclusion When I had finished the ISA I realised that the ERD I had developed had many faults, I should have used auto increment ID's on tables (for id fields). This would have made it easier to manage and be more efficient. The Taxi service data model I had originally based my design on was overly simple and incorrect which caused many problems when I was completing the relationship and primary key constraints. Tables and contents were deleted and further tables added in order to correct the problems with the relationships. Due to these problems much of my time was spent trying to correct them problems that I was unable to complete more extensive SQL Server Code and create more structured queries. I also should have incorporated a more in depth database to fulfil all the requirements for a Taxi company, and could have also expanded on the tariff structure to include times and calendars to incorporate double / treble time on after-hours / bank holidays etc. I had also intended to create a website in order for a customer to register their details online, this however was not possible due to :

The version of MS SQL Server Management Studio Express I only able to install on my computer. & I do not have access to any web design software to be able to link the database to Macromedia

Dreamweaver.

It was also not possible to complete this task in the university labs.

Page 44: By: David Grylls F6106630 · Entity Relationship Diagram (ERD) The ERD below shows all relevant tables used in the database. A customer who has registered details can simply text

8. Appendix & Reference Insert Scripts for all tables: Insert scripts\address.rtf Insert scripts\customer address.rtf Insert scripts\employees.rtf Insert scripts\journey charges.rtf Insert scripts\parts.rtf Insert scripts\registered customers.rtf Insert scripts\service booking.rtf Insert scripts\service history.rtf Insert scripts\staff type.rtf Insert scripts\suppliers.rtf Insert scripts\tariff rates.rtf Insert scripts\tariff types.rtf Insert scripts\taxi destination.rtf Insert scripts\taxi driver vehicle.rtf Insert scripts\taxi pickup points.rtf Insert scripts\vehicle parts.rtf Insert scripts\vehicles.rtf Websites used: http://www.databaseanswers.org/data_models/index.htm - used to identify possible data models http://www.databaseanswers.org/data_models/taxi_service/index.htm - used to get initial design of data model http://www.databaseanswers.org/data_models/car_svc_center/index.htm - partly used for data model

Data Models: Initial data model design HSQ Databases & SQL by Mansha Nawaz Introduction to SQL by Rick F.van der Lans SQL User Guides University of Teeside SCM


Recommended