Data format design problems 
Author Message
 Data format design problems

Sorry to bother you all with this, I just don't seem to be able to get my
brain round it!

I need to write a program to maintain and access a list.
The list should be a list of resources each of which has a list of
people's names who are allowed to use it. There can be any number
of people who can use a single resource, but there may also be none.

What I can't seem to do is invent a way of storing and indexing this
list in memory. I've got all these buzzwords floating around in my head
structures, linked lists, doubly linked lists, etc...

But I don't know what I should do.

Does anyone have any bright ideas on the best way to do this.

The program will eventually be required to respond with a positive or
negative when asked whether a particular person is allowed to use a
named resource.

All help would be gratefully received.

Thanks,




Fri, 20 Dec 1996 22:25:42 GMT  
 Data format design problems
James Cronin:

    I need to write a program to maintain and access a list.
    The list should be a list of resources each of which has a list of
    people's names who are allowed to use it. There can be any number
    of people who can use a single resource, but there may also be none.

    What I can't seem to do is invent a way of storing and indexing this
    list in memory. I've got all these buzzwords floating around in my head
    structures, linked lists, doubly linked lists, etc...

Sounds like you need a linked list of resources each containing a linked
list of people who may access the resource.  If your number of resources
is predictable or small, an array of resources each containing a list
might also be sensible.  A list-of-lists is most versatile, however.

I would use a data structure such as this:

/* structure for holding information about each user */
typedef struct User_tag
{
    /* list link */
    struct User_tag* Next;

    /* data for this user */
    char Name[NAME_LENGTH];
    int  UserID;
    int  HairColour;
    int  WhatIHadForBreakfast;

Quote:
} User_t;

/* structure for building lists of arbitrary users */
typedef struct UserList_tag
{
    /* list link */
    struct UserList_tag* Next;

    /* pointer to user structure */
    User_t* User;

Quote:
} UserList_t;

/* structure for holding information about each resource */
typedef struct Resource_tag
{
    /* resource list link */
    struct Resource_tag* Next;

    /* resource data */
    char        Name[NAME_LENGTH];
    UserList_t* AccessList;
    int         ResourceID;

Quote:
} Resource_t;

This structure may be represented graphically as:

        ------     ------     ------     ------
        |user|---->|user|---->|user|---->|user|---->end-of-list
        ------     ------     ------     ------

        ----------          ----------          ----------
        |resource|--------->|resource|--------->|resource|--->end-of-list
        ----------          ----------          ----------
             |                   |                   |
             V                   V                   V
        ----------  ------  ----------  ------  ----------  ------
        |userlist|->|user|  |userlist|->|user|  |userlist|->|user|
        ----------  ------  ----------  ------  ----------  ------
             |                   |                   |
             V                   V                   V
        ----------  ------  ----------  ------  end-of-list
        |userlist|->|user|  |userlist|->|user|  
        ----------  ------  ----------  ------
             |                   |
             V                   V
        end-of-list         ----------  ------
                            |userlist|->|user|
                            ----------  ------
                                 |
                                 V
                             end-of-list

The database of users may be maintained seperately from the database
of resources this way.  When you add a new user to a resource's access
list you add a UserList_t to the AccessList and set the User pointer
to point to the User_t structure for the user.  This avoids duplication
of user data.  Be careful, however, with the User pointers in the
AccessList.  These point to the relevant users in the user database.
When scanning the AccessList, the Next field in the User_t structure
should not be used; the Next field in the UserList_t structure points
to the next user on the access list.

You might want to use doubly-linked lists as they are a bit easier to
manage when adding/deleting members, depending on how your lists are
sorted and searched.

----------------------------------------------------------------------------

Hewlett-Packard Ltd.             /_  __   Phone     : +44 (0)31 331 7895
Queensferry Telecoms Operation  / / /_/   Fax       : +44 (0)31 331 7488
South Queensferry                  /      HP Telnet : 313-2895
Scotland  EH30 9TG                        Home      : 031 447 1078
----------------------------------------------------------------------------



Fri, 20 Dec 1996 23:47:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Changing .MAT data format to binary format

2. Problem with saving data into a text file in pre-formatted form

3. Problems outputting formatted data

4. Data Grid, Windows forms, Time Data Formatting

5. Design view formatting HTML

6. Changing dialog item formatting at design time

7. Data object design question

8. Data Report Design in VC++ 6.0 Professional

9. How to present data in crosstab format?

10. Serialize / Data format?

11. Formatting data in a DataGrid

12. Exporting data from Vis C++ to table format

 

 
Powered by phpBB® Forum Software