 |
|
 |
|
Next: Problems and questions about BULK INSERT in SQL S..
|
| Author |
Message |
External

Since: Feb 06, 2008 Posts: 26
|
(Msg. 1) Posted: Mon Oct 27, 2008 2:15 am
Post subject: VBA for Primary Key Archived from groups: microsoft>public>access>tablesdbdesign (more info?)
|
|
|
Hello,
Since a multifield primary key is more comlicated to use, therefore I plan
to have a surrogate/ 1field PK, but with the automatic fill by the VBA as
follows
1. 2 first digit will be Division ID
2. 2 next digits will be Union ID
3. 2 Next digits will be Regional ID
4. 3. Next digits will be Church ID
5. the rest will be increment by 1
So if my church has the following hierarcchy:
DvisionID: 1
Union ID : 2
Regional ID:3
ChruchID ID;4
Household/AddressID: incrment by 1, this is the first record.
What is the VBA if I would like it to show up like this:
01_02_03_004_1
I apreciate your help
--
H. Frank Situmorang >> Stay informed about: VBA for Primary Key |
|
| Back to top |
|
 |  |
External

Since: Mar 10, 2007 Posts: 89
|
(Msg. 2) Posted: Mon Oct 27, 2008 6:25 am
Post subject: Re: VBA for Primary Key [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
hi Frank,
Frank Situmorang wrote:
> Since a multifield primary key is more comlicated to use, therefore I plan
> to have a surrogate/ 1field PK, but with the automatic fill by the VBA as
> follows
> So if my church has the following hierarcchy:
> DvisionID: 1
> Union ID : 2
> Regional ID:3
> ChruchID ID;4
> Household/AddressID: incrment by 1, this is the first record.
>
> What is the VBA if I would like it to show up like this:
> 01_02_03_004_1
Yuck. This is redundancy at its best. Normally you should have this
structure using surrogate keys:
Division: ID, ...
Union: ID, Division_ID, ..
Region: ID, Union_ID, ..
Church: ID, Region_ID, ..
The key concept of surrogate keys is about _not_ to carry any information.
mfG
--> stefan <-- >> Stay informed about: VBA for Primary Key |
|
| Back to top |
|
 |  |
External

Since: Feb 06, 2008 Posts: 26
|
(Msg. 3) Posted: Mon Oct 27, 2008 6:25 am
Post subject: Re: VBA for Primary Key [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Thanks Stefan for your response. Let me tell you that the purpose of this is
to keep the address of the member PK alwasy unique when we cosolidated the
data in the upper level of organization or office.
The very low level office is local church, then chruch will send it;s member
data to higher office which is regional to consolidate data of all churches
on its region. Then Regional officie will send it's data to higher level
office wchich is Union Office...and so forth upto Division Office..and
consolidated all divisions to have the world total members.
In any of the level office, the address is always unique, therefore we know
the addresses of the members when we consolidated it.
But if we do not do like that, let me show you the sample, Address Mr. A in
church P will start with the number 1, then when I give the blank database to
church Q and the address of Mr. B will also start wtih number 1. When both
chrurches sent their data to regional office, the primary key will
conflict./duplicate. We can not assume to have it with the next number in the
regional office, but it is already said number 1 also in the Foregn Key of
the members table.
Thanks for your idea, if you stil can help me plasea. I am just a self
study, my specailty is accountancy
--
H. Frank Situmorang
"Stefan Hoffmann" wrote:
> hi Frank,
>
> Frank Situmorang wrote:
> > Since a multifield primary key is more comlicated to use, therefore I plan
> > to have a surrogate/ 1field PK, but with the automatic fill by the VBA as
> > follows
>
> > So if my church has the following hierarcchy:
> > DvisionID: 1
> > Union ID : 2
> > Regional ID:3
> > ChruchID ID;4
> > Household/AddressID: incrment by 1, this is the first record.
> >
> > What is the VBA if I would like it to show up like this:
> > 01_02_03_004_1
> Yuck. This is redundancy at its best. Normally you should have this
> structure using surrogate keys:
>
> Division: ID, ...
> Union: ID, Division_ID, ..
> Region: ID, Union_ID, ..
> Church: ID, Region_ID, ..
>
> The key concept of surrogate keys is about _not_ to carry any information.
>
>
> mfG
> --> stefan <--
> >> Stay informed about: VBA for Primary Key |
|
| Back to top |
|
 |  |
External

Since: Sep 30, 2008 Posts: 163
|
(Msg. 4) Posted: Mon Oct 27, 2008 8:59 am
Post subject: Re: VBA for Primary Key [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I would highly recommend you use an Autonumber primary key. All the other
fields now included should just be constrained to require a valid value.
"Frank Situmorang" wrote in message
> Thanks Stefan for your response. Let me tell you that the purpose of this
> is
> to keep the address of the member PK alwasy unique when we cosolidated
> the
> data in the upper level of organization or office.
>
> The very low level office is local church, then chruch will send it;s
> member
> data to higher office which is regional to consolidate data of all
> churches
> on its region. Then Regional officie will send it's data to higher level
> office wchich is Union Office...and so forth upto Division Office..and
> consolidated all divisions to have the world total members.
>
> In any of the level office, the address is always unique, therefore we
> know
> the addresses of the members when we consolidated it.
>
> But if we do not do like that, let me show you the sample, Address Mr. A
> in
> church P will start with the number 1, then when I give the blank database
> to
> church Q and the address of Mr. B will also start wtih number 1. When both
> chrurches sent their data to regional office, the primary key will
> conflict./duplicate. We can not assume to have it with the next number in
> the
> regional office, but it is already said number 1 also in the Foregn Key of
> the members table.
>
> Thanks for your idea, if you stil can help me plasea. I am just a self
> study, my specailty is accountancy
> --
> H. Frank Situmorang
>
>
> "Stefan Hoffmann" wrote:
>
>> hi Frank,
>>
>> Frank Situmorang wrote:
>> > Since a multifield primary key is more comlicated to use, therefore I
>> > plan
>> > to have a surrogate/ 1field PK, but with the automatic fill by the VBA
>> > as
>> > follows
>>
>> > So if my church has the following hierarcchy:
>> > DvisionID: 1
>> > Union ID : 2
>> > Regional ID:3
>> > ChruchID ID;4
>> > Household/AddressID: incrment by 1, this is the first record.
>> >
>> > What is the VBA if I would like it to show up like this:
>> > 01_02_03_004_1
>> Yuck. This is redundancy at its best. Normally you should have this
>> structure using surrogate keys:
>>
>> Division: ID, ...
>> Union: ID, Division_ID, ..
>> Region: ID, Union_ID, ..
>> Church: ID, Region_ID, ..
>>
>> The key concept of surrogate keys is about _not_ to carry any
>> information.
>>
>>
>> mfG
>> --> stefan <--
>> >> Stay informed about: VBA for Primary Key |
|
| Back to top |
|
 |  |
External

Since: Mar 10, 2007 Posts: 89
|
(Msg. 5) Posted: Mon Oct 27, 2008 9:26 am
Post subject: Re: VBA for Primary Key [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
hi Frank,
Frank Situmorang wrote:
> The very low level office is local church, then chruch will send it;s member
> data to higher office which is regional to consolidate data of all churches
> on its region. Then Regional officie will send it's data to higher level
> office wchich is Union Office...and so forth upto Division Office..and
> consolidated all divisions to have the world total members.
So you have
Division: ID, ... PK(ID)
Union: ID, Division_ID, .. PK(ID)
Region: ID, Union_ID, .. PK(ID)
Church: ID, Region_ID, .. PK(ID)
1, 1, "Church P"
1, 2, "Church Q"
as invariant structural tables.
Your local offices fill data in your address table:
Address: ID, Church_ID, ...
> But if we do not do like that, let me show you the sample, Address Mr. A in
> church P will start with the number 1, then when I give the blank database to
> church Q and the address of Mr. B will also start wtih number 1. When both
> churches sent their data to regional office, the primary key will
> conflict./duplicate.
Address (Church P): 1, 1, "Mr. A"
Address (Church Q): 1, 2, "Mr. B"
The surrogat key ID in church is sufficent for your local office, but
when you are consolidating the data your are copying data into another
structural scheme which has _other_ primary keys. For the table Church
it is then a combined key consisting of ID and Region_ID or you need an
other table to hold the consolidated data:
Address (Consolidated): ID, Original_ID, Church_ID, ...
Depending on your needs you may consider using a GUID as unique id, e.g.
http://www.devx.com/dbzone/Article/10167/0/page/3
mfG
--> stefan <-- >> Stay informed about: VBA for Primary Key |
|
| Back to top |
|
 |  |
| Related Topics: | Primary and Alternate project managers - I am trying to set up my database so I can show primary and alternate project managers. I have both as a columns in ProjectInfo as Integers linking to the PK in ProjectManagers. I cannot retrieve names for both sets. So far I can only retrieve the....
How to prevent duplicates of non-primary key - I am using Access as a front-end to an SQL database. I need to be able to prevent having duplicate keys without using a composite primary key. I have a table that allows an employee to have multiple skill sets: SkillID - as my primary uniqu...
Primary key to prevent duplicates - I have an invoice DB and the primary key field is for the invoice number which is unique and should not be duplicated. I have just received duplicate invoices from differnt vendors so how does one work around this scenario? invoiceID field=primary ke...
Two-Field Primary Key with one Null Value - Hi all, I'm new to databases and have a question that's hard for me but may be easy for someone else. I have a database where patients are assigned two unique IDs (hospital- wide and clinic-specific). I would like to create a primary key based on both...
Composite Key vs Primary Secondary Keys - Hello, Can you give me a plain description of the difference between Composite Keys and Primary and Secondary keys? I thank you for taking time to help me. -- Thank you... Elaine |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|