If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > One to one relationship

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-11, 12:23
AccessDatabase AccessDatabase is offline
Registered User
 
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 12:31.
Reply With Quote
  #2 (permalink)  
Old 04-13-11, 14:06
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-13-11, 15:20
AccessDatabase AccessDatabase is offline
Registered User
 
Join Date: Apr 2011
Posts: 10
thanks a lot
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On