473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Table Allocation

Does anybody know of a code that will assign table numbers (10 seats
per table) randomly for people attanding two events based on these
conditions:

1- All related persons in one family sit on the same table
2- People who sit on table (#65 for example) in event 1, shouldn't sit
on the same table in the event 2
3- Families from the same city shouldn't sit together

I don't even know of a way to approch this, not even something to start
from, and I don't know coding in VBA!

Thank you

Nov 13 '05 #1
5 1635
Muneer Mikel wrote:
Does anybody know of a code that will assign table numbers (10 seats
per table) randomly for people attanding two events based on these
conditions:

1- All related persons in one family sit on the same table
2- People who sit on table (#65 for example) in event 1, shouldn't sit on the same table in the event 2
3- Families from the same city shouldn't sit together

I don't even know of a way to approch this, not even something to start from, and I don't know coding in VBA!

Thank you


I have two observations.

The first is that your conditions need more thought before they can be
implemented. For instance, what if eleven people are related? What if
three groups of greater than five related people have to sit at two
tables? Do you need to do optimization? What if the situation where
two families from the same city must sit together arises?

The second observation is that VBA coding will almost certainly be
required to solve these kinds of problems. The conditions you have are
similar to conditions I've run into with tournament and league
software. In a tournament you'd like to keep people from the same team
or league or state from meeting for as long as possible. Generating
the set of optimal solutions gets a little tricky. In a league with
x(j) pool tables available and y(j) teams for site j you want to create
league schedules that involve roughly the same number of home and away
matches. Since most leagues are handicapped thereby giving teams with
a stronger schedule early on an advantage it is also advantageous to
use power rankings to balance the schedule so that the strength of the
schedule does not vary much. For example, you could play the strongest
team one week and then the weakest team the next. Considerations such
as these are usually too much for an SQL-only solution. You'd also
want to determine if the conditions are so tight that no solution
exists. There may be other kinds of constraints also.

James A. Fortune

Nov 13 '05 #2
Hi James,
Thank you for your reply.

Each group contains two people (husband and wife), and very few will
have one guest also. For now, lets assume each group will have only two
people. The purpose of seating families from different cities on one
table is to get them to know each other, assuming the families from the
same city know each other already because they belong to the same club.

I agree that I need to code in VBA. I'm a programmer, and I have been
able to manipulate some programs written in VBA to work the way I
wanted. However, I can't start coding in VBA from scratch. I need to
see a code written to solve a situation similar to the one that I have,
and then I could start modifying it and make it work. I can't even
think of a basic way to randomly assign table numbers for people in
general attending an event.

Thank you

Nov 13 '05 #3
I'll try to outline a way to attack this problem.

tblIndividuals
IndividualID PK
LastName Text
....

tblEventTables
EventTableID PK
EventTableName Text
EventID Long
SeatsAvailable Integer

1 One 1 10
2 Two 1 10
3 Three 1 10
4 Four 1 10
5 Five 1 10
6 Six 1 10
7 Seven 1 10
8 One 2 10
9 Two 2 10
10 Three 2 10
11 Four 2 10
12 Five 2 10
13 Six 2 10

Note: Table Seven will not be available for event 2. Sorry.

tblGroupsToReserve
GRID PK
IndividualID FK
GroupID FK
CityID FK
EventID FK

1 1 1 1
2 1 1 1
3 2 1 1
4 2 1 1
5 3 1 1
6 3 1 1
7 3 1 1
8 4 2 1
9 4 2 1
10 5 2 1
11 5 2 1
12 5 2 1
13 1 1 2
....

Each time a group is added to tblGroupsToReserve (perhaps using a
subform to list the people in the group) using a form that hopefully
checks for remaining SeatsAvailable, a new record is created in
tblReservations using those lines from tblGroupsToReserve.

tblReservations
ReservationID PK
EventID FK
EventTableID FK
GroupID FK to a non-PK
CityID FK (for info only)
SeatsReserved Integer (for info only)

1 1 x 1 1 2
2 1 x 2 1 2
3 1 x 3 1 3
4 1 x 4 2 2
5 1 x 5 2 3
6 2 x 1 1 2
7 2 x 2 1 2
8 2 x 3 1 3
9 2 x 4 2 2
10 2 x 5 2 3

where x is the EventTableID that gets assigned with the reservation.
When the reservation is made the SeatsAvailable field in tblEventTables
is decremented by the number of people in the group. Note that a group
for event 1 with two people can have guests for event 2 with their own
line in tblGroupsToReserve. If a reservation is cancelled be sure to
add the seats available back into tblEventTables. tblEventTables
records can be generated by a form also if lots of events are
contemplated. You can use this incremental approach to check for
information about who's already at the tables to give you a sense of
the problem before diving into the optimal solution. For the optimal
solution you can fill tblReservations with EventTableID blank (using
total event seats available to check for availability) and have VBA do
the analysis on the final table to assign EventTableID's. For the
incremental approach a way to do randomization would be to find out
which physical tables are available and use the Rnd function (after
using Randomize) to select which physical table to assign for the
reservation. I put this idea together quickly so I could probably do
better than this but it should get you thinking about the problem in
your head where it's really easy to make design changes as opposed to
changing the design after you realize that what you designed and coded
won't handle everything.

James A. Fortune

Nov 13 '05 #4
ji********@compumarc.com wrote:
tblGroupsToReserve
GRID PK
IndividualID FK
GroupID FK
CityID FK
EventID FK

1 1 1 1
2 1 1 1
3 2 1 1
4 2 1 1
5 3 1 1
6 3 1 1
7 3 1 1
8 4 2 1
9 4 2 1
10 5 2 1
11 5 2 1
12 5 2 1
13 1 1 2
...


This should be something like:

1 1 1 1 1
2 2 1 1 1
3 3 2 1 1
4 4 2 1 1
5 5 3 1 1
6 6 3 1 1
7 7 3 1 1
8 8 4 2 1
9 9 4 2 1
10 10 5 2 1
11 11 5 2 1
12 12 5 2 1
13 1 1 1 2
14 2 1 1 2
....

James A. Fortune

Nov 13 '05 #5
The two answers to your post in microsoft.public.access were
interesting:

1) Sorry, I'm afraid I don't have an answer to that one.

2) The problem you express is not an Access problem. It's a logic ...

James A. Fortune

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: mamo74 | last post by:
Hello. I am administering a SQL Server (Enterprise Edition on Windows 2003) from some month and can't understand what is going on in the latest week (when the db grow a lot). The DB is around...
6
by: chris | last post by:
Hi all, I need to know, what is the difference between dynamic memory allocation, and stack allocation ? 1. If I have a class named DestinationAddress, when should I use dynamic memory...
7
by: Bing Wu | last post by:
Hi Folks, I have a very large table containing 170 million rows of coordinats: CREATE TABLE "DB2ADMIN"."COORDINATE" ( "FID" INTEGER NOT NULL , "AID" INTEGER NOT NULL , "X" REAL NOT NULL ,...
2
by: aaronk321 | last post by:
Look below.. I'm baffled - what is going on? db2 => select tablespace_name from table(snapshot_tbs('epmdev01', -1)) as snapshot_tbs Do you want to execute the above command ? (y/n) y ...
21
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
8
by: justin.merth | last post by:
Is there any benefit in creating seperate file groups for a partitioned table on a multi-processor server with RAID5 and 1 Logical Drive?
0
by: Marc Melancon | last post by:
On Multi partition system (EEE) when exeuting table function eventually we will get : SQL0443N Routine "SYSPROC.SNAPSHOT_DATABASE" (specific name "SNAPSHOT_DATABASE") has returned an error...
4
by: Hemant Shah | last post by:
Folks, Our client has a program that browses whole table from begining to end. The table has 1 million rows in it. REORGCHK does not show any problems. It has unique index defined on KEY0...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.