Connecting Tech Pros Worldwide Help | Site Map

How to insert record into one to one relationship table

tabonni
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi all

I created two tables - Employee and Folder using MS Access 2002.

Inside Employee table, I got 3 fields:

EmployeeID (Data Type:Autonumber) [primary key]
Username (Data Type: Text)
Password (Data Type: Text)

Inside Folder table, I got 3 fields

FolderID (Data Type: Autonumber) [primary key]
FolderName (Data Type: Text)
EmployeeID (Data Type: Number - Long Integer) [foreign key]

My situation is: After the user login successfully, i will save his
username into session variable. Then, they can select a folder from
the drop down box. After he press the "Add Folder" button. The name of
that folder will be add it into Folder table FolderName field. For
example:

EmployeeID Username Password
10 admin admin
11 somebody pwd

FolderID FolderName EmployeeID
1 Temp 10
2 somebody 11

Can anybody tell me how can I write the SQL for doing it?

Thank you.
Brian
Guest
 
Posts: n/a
#2: Nov 13 '05

re: How to insert record into one to one relationship table


"tabonni" <tabonni@yahoo.com> wrote in message
news:fb0148c2.0410052149.2d430e49@posting.google.c om...[color=blue]
> Hi all
>
> I created two tables - Employee and Folder using MS Access 2002.
>
> Inside Employee table, I got 3 fields:
>
> EmployeeID (Data Type:Autonumber) [primary key]
> Username (Data Type: Text)
> Password (Data Type: Text)
>
> Inside Folder table, I got 3 fields
>
> FolderID (Data Type: Autonumber) [primary key]
> FolderName (Data Type: Text)
> EmployeeID (Data Type: Number - Long Integer) [foreign key]
>
> My situation is: After the user login successfully, i will save his
> username into session variable. Then, they can select a folder from
> the drop down box. After he press the "Add Folder" button. The name of
> that folder will be add it into Folder table FolderName field. For
> example:
>
> EmployeeID Username Password
> 10 admin admin
> 11 somebody pwd
>
> FolderID FolderName EmployeeID
> 1 Temp 10
> 2 somebody 11
>
> Can anybody tell me how can I write the SQL for doing it?
>
> Thank you.[/color]

Something doesn't make sense here. Your table design implies a one-to-many
relationship between employee and folder i.e. one employee can have many
folders, but a folder has one and only one employee. But, you have
indicated that you intend to have a drop-down list of folders. This implies
either a one-to-many relationship between folders and employees (so FolderId
would need to be a foreign key on the Employee table), or a many-to-many
relationship between folders and employees (so you would need an additional
junction table with both FolderId and EmployeeId as foreign keys).

Whatever it is you want, you should be able to achieve it using bound forms
without explicitly writing any SQL, but you will need to rationalise your
design first.


Closed Thread