As per these instructions, i am trying to create a ER model. With
these instructions:
Total Escapes has a wide variety of tours on offer to its customers.
Each tour can be uniquely identified by a route ID. A tour also has
associated with it an estimated duration and a description of the tour
itself.
Customer details are to be recorded in the database, with a unique
customer ID generated for each customer. Additional details include a
name, date of birth and contact phone number. A Tour run is defined as
one instance of a tour, i.e. a tour has a number of tour runs. For
example, a ‘Melbourne City Tour’ runs twice every day, 8:30am and
2:30pm. In other words, a Tour run is identified by not only a
specific tour but the date and time that tour was operated.
A customer can book tour runs. The price paid for the booking is
recorded. A vehicle is used by a driver to perform his/her duties in
taking tourists on a route. Each vehicle can be identified by it
registration plates. Other attributes such as vehicle type, capacity
and colour are also recorded.
A Tour guide organizes a tour run in coordination with the driver. The
tour guide must have a unique certificate number to be recorded in the
system. Their name, mobile number and address are also required. The
driver responsible for operating the tour vehicle on a tour run can be
identified by their D/L number. A name and mobile phone number are
also recorded in the database for each driver.
Some tour guides train other tour guides to manage tours themselves.
Each trainee has one supervisor while a supervisor can guide many
trainees.
On the diagram that i have created I am wondering if the link between instance and tour would be the many to exactly one?
OR is the tour run not even a weak entity?
ER Model
I agree that Tour Run is a weak entity - the instructions are very specific about this. That means Instance is an identifying relationship, mapping Route_ID values to Route_ID,Date,Time values. This is a trivial relation that wouldn't need to be recorded separately from Tour Run keys. You're also correct that the association between Instance and Tour is many-to-one - many Route_ID,Date,Time triplets map to one Route_ID.
Related
I have a database that schedules teachers to deliver lectures that range from 15 minutes to 4 hours long. Many of these lectures take place simultaneously. Some lectures require multiple teachers to deliver due to complexity of the subject. These lectures cover topics that are categorized in one of ten areas of specialization. We have ten teams whose members are experts in one of the ten areas of specialization. Each team is responsible for delivering the lectures that are associated with their area of specialization.
Teachers are assigned to a team based on their chosen area of specialization and expertise. Teachers must pass a certification course in order to be allowed to teach in an associated area of specialization.
Some teachers have multiple certifications and as a result can be scheduled to deliver lectures that are not the responsibility of the team to which they are assigned. However, they only fill in in this capacity if all teachers from the team with responsibility for the lecture in question are busy and no one else can be assigned the lecture.
Teachers earn sick and vacation time and they can use this time as needed. In addition, teachers are from time to time required to participate in professional development events or attend meetings. Therefore, they are not always available to deliver lectures.
My task has been to develop a process where teachers can be scheduled to deliver lectures based on their certifications, team membership, and availability.
I have the following tables:
Instructor lecture assignments (which instructors have been assigned to which lecture)
Lecture schedule (name, date, start time, end time, certifications required for each lecture)
Teacher not available (teacher name, date unavailable, start time unavailable, end time of unavailability)
Teacher teams (names of teacher teams)
Teachers (first, middle, last name of each teacher)
Teacher certifications (name of each certification that can be earned by each teacher)
Teacher certification conferrals (which teachers have earned which certifications and on what date)
Teacher team assignments (which teachers are on which team)
The issue that I am trying to resolve is how to structure a query that will display, for each lecture, the teachers that are CURRENTLY certified to deliver that lecture, a member of the team that is responsible for that lecture, NOT unavailable due to professional development nor being assigned to deliver another simultaneously occurring lecture.
Can someone help me to understand how to structure this needed query, please?
Thank you in advance.
What you have to do is take it one step at a time. Forget:
"for each lecture, the teachers that are CURRENTLY certified to deliver that lecture, a member of the team that is responsible for that lecture, NOT unavailable due to professional development nor being assigned to deliver another simultaneously occurring lecture."
Start with:
List all teachers
List all teacher certifications with their start and/or end dates. Your wording does not make it clear if by "currently" you mean "has not expired" which is what the assumption is reading the word currently, or "has already earned it" which is what your description of your data indicates, or both.
Filter the above with the certification required by each lecture
Filer by each reason for unavailability
One step at a time, you can't solve the problem in one go. It is ok if you take a wrong turn or end up with some extra queries that are unneeded, you can clean up when the goal has been reached.
I am working on another project that involves a car hire company which can be summarised as followed:
A depot supplies cars to multiple hire points and acts as a service garage for repairs
A hire point can use many depots for servicing and the supply of cars
A customer makes a rental for a car from a hire point and can return the car to the same hire point or a different one of their choice. The system must keep track of where the car currently is.
Vehicle availability and repair/maintenance status must be recorded.
A discount must be able to be added to cars for promotional events
The database must keep track of employees who are either depot employees or hire point employees. a hire point employee may work at a number of hire points during the week and is given a schedule a month in advance, whereas a Depot employee remains at the same location.
I have attached an ERD of what I have so far and would like some comments on its structure please.
I am having difficulty in understanding how I am going to keep track of the cars, and how I am going to implement a shift pattern for employees for both the depot and the hire point with the above requirements.
kind regards
Im trying to build a hotel application system and now i have laid out plans for the DB. My requirements are a guest searches for availability for a room. A room could either be king or queen, and smoking or non smoking. Also the guest enters the check in and out date. Based on the search the guest enters their info and reserve a room. Based on the reservation the service agent receives the receipt(reservationId). The service agent books the room upon receiving the reservationId. A guest can reserve several rooms per reservation. Now below is how my DB looks right now.
My question is since a guest can have several rooms per reservation how could i represent multiple rooms per reservation. Note: This will be done using hibernate. And below is my actual setup now for my DB please feel free to correct me if my approach is wrong: Below is a draft of how my db looks:
Reservation(resId(PK), checkIndate, checkOutDate, roomType, roomProperties, guestId(FK)).
Guest(guestId(PK), fname, lname, email, license, address_details).
Room(roomId(PK), roomNumber, roomProperties, roomType, price).
Booking(bookId(PK), resId(Fk), roomId)
RoomOccupied(bookId(PK and FK), roomId(PK and FK), flagChecKIfOccupied(default value is 0 if not occupied or 1 if occupied)
Payment(paymentId(PK), resId(FK), finalPayment)
We are developing a platform for NGOs (N) to get their work done via Individual Volunteers (V) or Volunteers via a Company (C)
NGO
An NGO can come signup for an account and create a profile.
It creates Activities (jobs it needs help from volunteers) to which Individual Volunteers or a Company (Sub set of their Employees who are registered as Volunteers in the system) can apply.
An NGO can check the Applicants Profile and previous Work History
and accept the application. On Acceptance they become members of an
Activity.
Here While they work after regular intervals say 2weeks they need to
enter the amount of hours they have contributed towards that
particular activity.
NGO has to validate this time so that it can reflect in a Volunteers profile as credit
Company
A Company signup for a profile.
It uploads the list of all its employees in a particular formatted CSV file to add Volunteers against itself or send an invite link to to ask their employees to signup. If an Employees already exists in the system we send an email asking him to validate the company's claims
Company can search for a particular Task and apply to it by selecting all its employes or a subset of it.
While Validating time for the work done it can be done it two ways. 1 Company can centrally say V1 V2 V3 have completed 2hrs 3hrs and 2hrs and submit for validation from the NGO or allow each of its Employees handle this manually and allow them to submit it.
Where i need help?
I have created the NGO and single Volunteer relationships. I am confused as to how use the same tables but allow a new entity like Company come in between the NGO and Volunteer and manage the time validation and activity management.
The Time Validated is very important as it will be used to be shown that in the Social Equity Balance of the NGO, Company as well as Volunteers (Individual Work and also Worked for a cause through a company)
I have created the ER diagram below for the NGO and Volunteer and need to create the Company part of it.
Link: http://i.stack.imgur.com/OMY21.png
I'm not sure you need to change your schema much, or even at all. Your schema requires an application to go with it to make it do anything - you can't implement all the logic here - some/most of it will be in your application.
As I understand it, your spec says that all actual volunteer work is performed by individuals, some of whom may be associated with a Company and some aren't. Your schema captures this already.
That's pretty much all you need, I think. When you say:
While Validating time for the work done it can be done it two ways. 1 Company can centrally say V1 V2 V3 have completed 2hrs 3hrs and 2hrs and submit for validation from the NGO or allow each of its Employees handle this manually and allow them to submit it.
This is already covered - either each individual inputs their own work records or the application allows the company to do it for them - and then the NGO validates these records in the same way, regardless of who entered them.
I have created the NGO and single Volunteer relationships. I am confused as to how use the same tables but allow a new entity like Company come in between the NGO and Volunteer and manage the time validation and activity management.
Lets go through a worked example to illustrate both use cases, to make sure we've got everything covered:
Worked Examples
Individual, no company
An individual signs up, creating a row in the volunteers table. They sign-up for an activity, creating a row in the ngo_activity_applications table.
The NGO approves them, creating a row in the ngo_activity_members table - and either removing the row in the ngo_activity_applications table, or changing it's status - the spec. is unclear.
The individual does some work and logs the time in the app, creating rows in the ngo_activity_time_validations table.
The NGO validates the work done somehow, then tells the app this. This presumably changes the status of the rows in the ngo_activity_time_validations table and creates either one summary row or matching rows in the volunteer_validated_times table. Spec unclear where cost_per_hour comes from?
Company
A company signs up and uploads a CSV file with 3 volunteers in. This creates a row in the companies table, plus three rows in the volunteers table, and 3 rows in the company_volunteers linking table.
Company Volunteer 1 signs up to an activity individually and everything proceeds as above.
The Company signs up for a different activity and volunteers all 3 of it's people to work on it. This creates 3 rows in the ngo_activity_applications table.
The NGO approves all three, creating three new rows in the ngo_activity_members table - and either removing the rows in the ngo_activity_applications table, or changing their status - the spec. is unclear.
The volunteers do some work and the company logs time in the app on behalf of Company Volunteers 1 and 2 - and Company Volunteer 3 logs her own time:
Company Volunteers 1 and 2
The company uses the application to log the time on their behalf - creating 2 rows in the ngo_activity_time_validations table.
Company Volunteer 3
Company Volunteer 3 uses the application to log their own time - creating a row in the ngo_activity_time_validations table.
The NGO validates the work done somehow, then tells the app this. This presumably changes the status of the rows in the ngo_activity_time_validations table and creates either one summary row or matching rows in the volunteer_validated_times table. Spec unclear where cost_per_hour comes from?
Summary
You can see how much validated time any individual has logged by querying the volunteer_validated_times table JOINed to the volunteers table. You can also see how much validated time any Company has logged, by doing the same query but also joining on the company_volunteers table.
Possible changes & Questions:
You might want to add a company_entered flag to the ngp_activity_time_validations table, so that you can distinguish between records entered by individuals and ones entered by the company on an individuals behalf. You might also want to add the ID of the person who makes the entry in this table, if logging that is relevant to your application.
Might want to add an hourly_rate column to the volunteers table, to use as a default cost_per_hour when creating rows in the volunteer_validated_times table.
Can anyone help me to design database/table based on below criteria?
An e-commerce website is required which will allow visitors to browse, search and buy films. The following business logic applies:
Each film can be available in DVD or Blu-ray formats with different stock codes and prices. Additional formats may be added in the future by the website administrator.
Films should have a title, description, year they were released and a “star rating” out of ten stored against them.
Films are associated to none or more actor and actors can be associated to none or more films as some films may be documentaries (with no actors).
Films can be associated to one or more genre (such as action, adventure, Sci-Fi, etc).
The number of genres and actors may change so the website administrator needs to be able to add/edit as many genres and actors as they like over time.
Visitors of the website should be able to find films by browsing by actor or genre. When they do they should be able to see a list of all films that are associated to the actor/genre they have selected.
In order to buy from the website, visitors must register their details to become a user.
Users will have one or more addresses associated to their account. When they log in to the system in future all of their previously entered addresses should be available for them to select for their latest order. They should also be able to add a new address to their account at any time.
When ordering the user will select one or more items from the available films (in a particular format). They will need to select a billing and deliver address from those they have previously entered and pay for their order by credit card.
As the prices of the products can change over time the system should record what the price of each of the items in their order was at the time when they purchased as well as the total price of the entire order.
Tracking of stock levels is not required – all products can be assumed to be in stock all of the time.
If this is homework, or a class project, then you really need to start learning about normalisation. Take a look at the article on wikipedia or this introduction on the MySQL site
If this is a professional project, then you need professional help to design/develop your e-commerce site.
Here is something I could come up with, hopefully it should satisfy all the criteria mentioned in your requirements. I was designed in SQL Server as I do not have MySQL on this machine.
Steps to design the database (entity relationship modeling)
Identify the entities from the requirement. Entities are objects that hold information (usually denote real world entities like person, car, bank, employee, etc.). In your case, the entities identifiable are: Film, Actor, User, Order
Once you have identified the entities in your requirements, get down to the deciding the attributes (or properties) of the entities. The attributes are something that you associate the entity with. For example, one would identity a car by its manufacturer, model, color, engine capacity, etc. In your case, the attributes for the film entity would be Name, Genre, ActorInFilm(s), Format(s), Price
Identify the relationships between the entities. In your case, film has a relationship with actor. The relationship is: One film can have zero or more actors. And, one actor can act in one or more films. Thus film and actor are related.
Identify the cardinality of the relationships. Cardinality can be explained in simple terms as how many instance of the entity participate in the relationship.
For example, a employer can have 1 or more employees. And an employee can be employed by only one employer. In this case, there are 2 entities: Employer and Employee. They share the relationship employ. In your requirement, Film and Actor are the entities sharing the relationship Acts in (Actor(s) acts in Film). So the cardinality in this case will be one to many (Film to Actors)(one Actor can act in many Films) and zero to many (Actors to Films).
Once this part is done, you have your zero normal entity relationship diagram. Then comes the normalization. You can read about it on another post here.
After you have normalized the entity relationships (upto 3rd normal form is usually sufficient), you can implement the database design in the SQL design software (MySQL, etc.)
The best way to do the above steps is to take a sheet of paper and write the entities and attributes in a tabular format and then link them to other entities (to denote relationships).
You can refer any good book on database concepts (including normalization) or just search on google (keywords: database, normalization, database design, entity relationship modeling, etc.). What I have explained above is very brief, you will need to discover the rest of the database concepts yourself.
Entity relationship diagram is often abbreviated as ER diagram.