need your helps Very Urgent! please

dear friends,

i have created 2 tables one is for "Owner ship"and the other "House"

the relation between 2 tables in the owner ID and the relation is
one to many!!!!!!

but i want to make a relation ship between then that :
1 owner can own max of 2 houses
and 1 house can be owned by 1 person only

but my problame is that the relation is 1 to n how i can squeeze the many cluse

2- also i used the database in my application and there you can undate and edit the fields and i done that using ADO+ Datagrid!!!! so a person will enter can update the field but i want to limit that
if there is more that 2 same owner id in the house table then msqbox: (update failed more than 2 houses) so how i can do that ???
[776 byte] By [boohamad] at [2007-11-20 11:03:07]
# 1 Re: need your helps Very Urgent! please
Set up the master table like this:

ID#___+__HOUSE1__+___HOUSE2__
x ________ a1 ___________a2

so that houses can be
1 a1
2 a2
3 b1
4 b2
dglienna at 2007-11-9 19:33:58 >
# 2 Re: need your helps Very Urgent! please
i didn't undrestand how till now if you explain to me with the cods i may undrestand better!!!
and also how i can limit that in the databse??
boohamad at 2007-11-9 19:35:04 >
# 3 Re: need your helps Very Urgent! please
You are going to have to start over with your tables. You can copy old fields into new fields, but I think you have the design wrong, if you want to limit houses to 2.

You have:

Owner___+___House#
1 _____________ 1
1 _____________ 2
1 _____________ 3

Which is one-to-many
dglienna at 2007-11-9 19:36:03 >
# 4 Re: need your helps Very Urgent! please
I didn't undrestand your meaning : do i have to do againe the relation ship or the tables!!! caus ei don't have 3 tables i have only 2 tables!!!

1- for AUH_HOUSE Containes:
HOUSE_ID + OWNER_ID + OWNER NAME : Primarey key is House ID and the forighn key is Owner_ID

2- OWNER_SHIP contains:

Owner ID + OWNER Name : Primery key is Owner ID

and i made the relationship using the Owner ID (is that wrong) and the relation was 1:N

i only want to limit that if some body bought a new house but he already have 2 houses then it can't be entered to the system and gives an error or msgbox what ever!!

and the person will edit or enter new fields using VB6 Application where i used ADODC + Datagrid so if a person will enter a owner ID which already is there for 2 times then it gives a msgbox 'can't enterd , already have 2 houses"

SO how i will specify that ??
boohamad at 2007-11-9 19:37:07 >
# 5 Re: need your helps Very Urgent! please
Change #2:

2- OWNER_SHIP contains:

Owner ID + OWNER Name : Primery key is Owner ID

change to:

Owner ID + OWNER Name + House1 + House2
dglienna at 2007-11-9 19:38:01 >
# 6 Re: need your helps Very Urgent! please
Do you mean that you want to limit that 1 person only can have max 2 houses from your application ?
So, when you try to enter the third house, it will return an error ?
Please advise me if i interpret it wrongly. Thx

Regards
Dock at 2007-11-9 19:39:06 >
# 7 Re: need your helps Very Urgent! please
no ur r right!!! so how i can limit that
boohamad at 2007-11-9 19:40:10 >
# 8 Re: need your helps Very Urgent! please
It has been a long time since the last time i use VB. So, i am sorry if i could not give you accurate information. Other user please advise..
Actually, from one of your other post, you can get the answer already. I think ShafaqatAli has told you how to count the record, rite ?
Just use the similar method

Select Count(*) from AUH_HOUSE Where Owner = "The Name"

execute the sql, and then use a variable to catch the result.

If VARIABLE >1 then
Msgbox "Too many house already, why dont u give me 1 ?"
else
'Update the database
end if

Hope this can help, sorry for the lousy explanation. First time for me using forum.
Dock at 2007-11-9 19:41:08 >
# 9 Re: need your helps Very Urgent! please
Hi booh,
Any update ?
Dock at 2007-11-9 19:42:07 >
# 10 Re: need your helps Very Urgent! please
Kind of hard to transfer a house with your method.
dglienna at 2007-11-9 19:43:08 >
# 11 Re: need your helps Very Urgent! please
Eh ? what do you mean by transfer a house ?
I think booh only want to make a validation for the "Add House" function, isnt it ?
So I think the method should be enough already. I dont really know anything about database though, that's why I cant really understand what do you mean. please enlight me =)
Dock at 2007-11-9 19:44:12 >