Creating a 1:1 relationship problems...
I have the following SQL to create tables for an access database:
CREATE TABLE PersonalDetails
(
PersonalDetails COUNTER PRIMARY KEY NOT NULL,
Forename varchar(40) NOT NULL
)
CREATE TABLE AnotherTable
(
AUniqueNumber varchar(10) PRIMARY KEY NOT NULL,
PersonalDetails_ID long NOT NULL UNIQUE,
FOREIGN KEY (PersonalDetails_ID) REFERENCES PersonalDetails(PersonalDetails_ID)
)
What I'm tring to achieve is a 1:1 relationship with these two tables. However, when I create them in Access and click on the Relationships button on the toolbar, it is showing that this is a 1:M.
Anyone have any ideas?
Regards
John
[753 byte] By [
Vaderman] at [2007-11-19 11:11:27]

# 1 Re: Creating a 1:1 relationship problems...
FOREIGN KEY (PersonalDetails_ID) REFERENCES PersonalDetails(PersonalDetails_ID) Do you mean :
FOREIGN KEY (PersonalDetails_ID) REFERENCES PersonalDetails(PersonalDetails)?
Anyway..Don't care about what access shows..It's a 1:1 since AnotherTable.PersonalDetails_ID is unique
hspc at 2007-11-9 13:41:54 >

# 2 Re: Creating a 1:1 relationship problems...
Apologies for the typo's... the tables are correct and not in error as they seem to appear here.
Thats just great that ACCESS does not seem to represent my relationships properly...
Don't you just lurve access?? :(
Thanks anyway.
Regards
John
# 3 Re: Creating a 1:1 relationship problems...
if you make AnotherTable.PersonalDetails_ID the primary key..access can show the relation the right way.
Don't you just lurve access?? :( OK..Seems you did not try to make a foreign key in mysql..then try to drop it..sometimes painful.:sick:
hspc at 2007-11-9 13:43:53 >

# 4 Re: Creating a 1:1 relationship problems...
Hi hspc,
Just one more problem in that I can't seem to create any cascades for the following table:
CREATE TABLE AnotherTable
(
AUniqueID varchar(10) PRIMARY KEY NOT NULL,
PersonalDetails_ID long NOT NULL UNIQUE,
Forename varchar(40) NOT NULL,
CONSTRAINT FKAnotherTablePersonalDetails_ID
FOREIGN KEY (PersonalDetails_ID)
REFERENCES PersonalDetails
ON DELETE CASCADE
)
Comes back with Syntax Error in Constraint Clause
Had a look at the Access online help just to re-check the syntax and after reading that, the above SQL should work.
Any ideas?
Regards
John