Results 1 to 9 of 9

Thread: Entity Relationship diagrams

  1. #1
    Join Date
    Sep 2008
    Posts
    5

    Entity Relationship diagrams

    A car rental company has several car rental agencies across the country. The agencies rent several classes of vehicles:compact, midsize, full size, sport utility. Each vehicle is managed by one agency. Customers rent vehicles from the different agencies. When a vehicle is rented, a new rental record is added to the Rental table with dateout as the current date and dateReturned is left null. When a vehicle is returned the record is updated by filling in the DateReturned field. A portion of the car rental table is given below.

    Vehicle(VehicleId, VehicleClassId, AgencyId)
    Rental( RentalId, VehicleId, CustomerId, DateOut , DateReturned)
    Customer( CustomerId, CustomerName, CustomerBalance)
    Agency( AgencyId, AgencyLocation)
    vehicleClass(VehicleClassId, VehicleClass, RentalRate)


    help needed in creating an entity relationship diagram

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,926
    You are almost there. You just need to draw diagram and link different entities by the lines depicting cardinality.

  3. #3
    Join Date
    Sep 2008
    Posts
    5

    ER diagram

    I have done by diagram, but not comfortable it is correct. Here are my relations, am I on the correct path?

    Vehicle 1 1 1 * Rental
    Vehicle 1 1 1 1 Agency
    Vehicle 1 1 1 1 VehicleClass
    Customer 1 1 1 * Rental

    Above is how I look at the Cardinality. Is there any way I can check, any tecnique I can apply to know for sure that my answer is correct.

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,926
    I don't understand 1 notations.

    You can have 1-to-many, 1-to-1 or many-to-many relations. Best way to identify them is looking at the data you might have. For example, one vehicle may be rented many times, so vehical has 1-to-many relation to rental (assuming one rental does not have many vehicles).

  5. #5
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,926
    Also you need to figure out whether the relation is identifying or non-identifying, meaning whether every tuple in target entity must have a correponding source tuple.

  6. #6
    Join Date
    Sep 2008
    Posts
    5
    what i mean is
    Vehicle 1 to 1 (min and max cardinalities) 1 -* Rental

  7. #7
    Join Date
    Dec 2008
    Posts
    10

    The ERD to the Agency Vehicle Rentals

    Dear Chetah,

    Let's see now. We assume that

    1 - One Agency can have Many Customers but One Customer has to belong to only to One Agency - Relationship No. 1 (1-to-many)

    2 - One Customer can have Many Rentals but One Rental has to belong to only one Customer - Relationship No. 2 - (1-to-many)

    3 - One Rental can have Many Vehicles but One Vehicle has to belong to only One Rental at One Time since you can not rent one vehicle at the same time - Relationship No. 3 - (1-to-many)

    4 - One Vehicle Class can have many Vehicles but one Vehicle has to have only One Vehicle Class - Relatioship No. 4 - (1-to-many)

    And so we have:

    Agency Vehicle Rental Model.jpg

    I have come across the problem and can not understand why rental has to be connected to Agency while it is already connected to Agency through the Customer (As I have Done Above). If we connect Rental to Agency Than we also have to connect The Rental to Customer. So we will have two relationships as below.

    Agency Vehicle Rental Model - Two Relationships.jpg


    Which is right? Anu Body.

    Regards

    Jawad

  8. #8
    Join Date
    Dec 2008
    Posts
    10
    Sorry there is a mistake in the ERD. Just remove the Vehicle ID Column from the Rentals Table in both the images. It was a problem with the CASE tool (Microsoft Visio) I was using. Everything else seems fine. I hope so. But If some body can explain the difference between the Model 1 and Mode 2 with 2 relationships Please

    Regards

    Jawad

  9. #9
    Join Date
    Nov 2008
    Location
    London
    Posts
    12

    Exclamation Important...

    chetah, I'm sure you've figured it out already and i might be a bit too late in replying but it's important for you to know that for a relationship database to work you need to create one-to-many relationships throughout your database.

    All one-to-one relationships must be combined and all many-to-many relationships need to be broken down.

    Good Luck, Rushy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •