Need some help with access...

Associate
Joined
21 May 2003
Posts
1,008
Hi. I'm making a database for a property letting company and am having some trouble.

I've made a table called houses, and a table called flats. Each house can have upto five flats in it.

all i want to do is when i create a house, have a box there to say how many flats it has, and then write say 5 entries in the flats table pointing to one entry in the house table.

i know i can do this manually but i'd much rather have it automatically enter as many as it has.

any help is appreciated :)
 
To be honest if you did that it'd be bad database design as you'd be building in duplicate data.

The whole point of having the Flats table is to separate the data for each entirely - which is good. Where you need to know the count of flats in a house in your system I'd just do a query to count the number of flats related to the house.

If you'd still prefer to have a count of flats in your houses table, just increment the count by 1 every time a flat is added and then decrement it when one is deleted.

HTH.
 
Back
Top Bottom