Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    10

    Exclamation One to one relationship

    Hi

    I have these two tables and I want a one to one relationship between them but when I create both tables in Access it shows them as 1 to many relationship in the relationship database. Could you please tell me whats wrong?

    This project is about a company which is a light recovery operator offering a package of towing services and roadside recoveries. The job could be an accident or a breakdown. The vehicle would be either fixed at the roadside or towed to the company. If towed, we have to store details of what happened to the vehicle next. In order not to have blanks I created a table called: 'TowedInformation' which stores the notes when it is towed.


    CREATE TABLE Job(
    JobID AUTOINCREMENT PRIMARY KEY,
    ArrivalTime TIME,
    DepartureTime TIME,
    JobDate DATE,
    AddressLine1 TEXT,
    POSTCODE TEXT,
    City TEXT,
    GPSCoordinates NUMBER,
    Cost NUMBER,
    TransporterPlateID TEXT NOT NULL REFERENCES Transporter(TransporterPlateID),
    VehiclePlate TEXT NOT NULL REFERENCES Vehicle(VehiclePlate));


    CREATE TABLE TowedInformation(
    JobID AUTOINCREMENT PRIMARY KEY REFERENCES Job(JobID) ,
    Notes TEXT);

    Thanks a lot
    Last edited by AccessDatabase; 04-13-11 at 13:31.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    two things...

    first, a one-to-one relationship will, for all intents and purposes, look just like a one-to-many relationship, since it requires a foreign key

    however, if you make the foreign key also its own table's primary key, you cannot then have many

    second, you do ~not~ want to make the foreign key an autoincrement, because it will get completely out of step with the referenced key

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2011
    Posts
    10
    thanks a lot

Posting Permissions

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