I'm not sure if to or how achieve this with Drupal. I want to a small and simply database for use within the site. The database would have two tables e.g. Person & Monthly Status

The person table should be:
ID > automatically generated number
Name > text
Gender > select from values
D.O.B > date

The Monthly Status table should be:
ID > Select an ID from the person table
Status > select from values
Notes > text

Am I going above and beyond Drupal here? I think possible I'm getting confused by looking at it in terms of a database (as per how it was explained to me) I might really just need to link two custom content types by a certain field, and then figure out how to get he ID to autogenerate.

Scott

Comments

gavin_s’s picture

I really rushed that - sorry for all the spelling mistakes!!

nevets’s picture

The Content Construct Kit (CCK) module allows you to build custom content types and would make this a snap. You could use CCK to make two content types, person and monthy status. After you have installed and enabled CCK (note there is more than one module to enable) you can create new content types under "Administer" -> "Content Managment" -> "Content Types". The first step is to click "Add content type" tab.

For the person type, we will give it a name of 'Person' and a type of 'person'.
Set 'Title field label' to 'Name' (We will use it for the name field)
Set 'Body field label' to blank (we are not going to use the body)
Set other values as want and save.

Now find your new content type and click edit so we can add the other fields. Click "Add field'.
For gender, set name to 'Gender' and under 'Text' select 'Check boxes/radio buttons' for the type.
Save the form and on the next page there are some more choices to make, for now the important one is 'Allowed values list:' where you will provide the values for the radio buttons. Save the form.
Repeat for D.O.B repeat. You can either use a text box or add the date widget". Note for birthdays you will likely need the optional adodb date library.

You will do something similiar for the monthy status table, I will let you try that out. Some hints thought, you can use the body for the 'Notes' and use a node reference field for select someone from the person table (this is why we used the title field for name, you will be able to select by name).

On the ID's those are handle by Drupal for you.

gavin_s’s picture

Sounds like CCK is the way to go. Thanks for the detailed reply. Just trying it now. While I do it, do you have any idea how I can get an auto generated number field to use as the 'link' between nodes?

Cheers, Scott

nevets’s picture

It lets you pick a title (from a set of select types) but uses the nid (an auto generated index).

gavin_s’s picture

Ah. Not sure I am following you on that one. I have successfully managed to pick a value (feild) from the first content type in the second. What I want is to be able to generate a random, or at least unique value in the first content type to be selected in the second. Something like a User ID allocated by the system, not the user.

Does what you say still stand for the above scenario? I'll try again :)

Scott

nevets’s picture

You are approaching it from the point of viiew of exposing the generated id and people needing to know that to reference a person. I am suggesting the id is unimportant, that you can do the same thing with the users name. By using the title field as the name for person, those nodes will have a person's name as the title. So you might have person nodes with titles like "Bill Smith" and "Mary Jones", they also happen to have an id (the node id or nid) but generally it is not information users need to be aware of. For your second content type if you add a "node reference" field and limit the type to "people" (your first content type), then when creating content of that type people would type for example "Bill Smith". If you set the field up as automplete it will show possible matches as you type. You can also set it up as a drop down list but I do not recommend that if there are a large number of people nodes.

gavin_s’s picture

Yes - see exactly what you mean and I agree this would work under 99% of scenarios. One key feature I did not mention (sorry, but I was trying to keep it simple), is I need to reference an anonymous ID. So a view looking at a summary of the second content types would list ID against monthly status's.

I think I need to use PHP code in the allowed values section of this ID field. The PHP would check to see what values are present against the 1st content type and auto increment by 1, thus providing a unique and anonymous ID.

I'm happy that you have got me 99% of the way there. If I can figure this last bit out, then Bingo!

gavin_s’s picture

I am sure this is the answer - see here http://drupal.org/project/computed_field - just trying to figure out how the hell to use it now! :) Will update here if you don't beat me to it.

gavin_s’s picture

I still need help with this... :( I can't get computed field to display either the nodes NID or a random/sequention unique number. Basically I can't get anything to display.

gavin_s’s picture

Bumped post over to here http://drupal.org/node/192987 to be specific to CCK's Computed Content field.