How do I add tags to the taxonomy data via node and the fields? I need to store the tags which newly created in the taxonomy_term_data table, and also in the node field. I created the node field as field_beaches_tags (term reference) using "Select list" as widget.

I need to store the value in this and also in the taxonomy term data table with reference vid as the tags. I have the location name field in the form; when I submit the form the location, I must store the tags in the taxonomy table and also in the node field.

 function My_beaches_create_submit($form, &amp;$form_state) {
    $node = new stdClass();
    $node-&gt;language = LANGUAGE_NONE;
    $node-&gt;promote = 0;
    $node-&gt;uid = 1;
    $node-&gt;type = 'content_type';
    $node-&gt;taxonomy[1] = $values['location_name'];
}


1 is the vid of the tags in the taxonomy, but I am able to store the value in the database table.
In drupal 7, Taxonomy terms are attached as regular fields. So $node-&gt;taxonomy is no longer a standard property that Taxonomy module picks up. 

If your field name is field_beaches_tags, assign tags to the node as below. 

$node-&gt;field_beaches_tags[$node-&gt;language][]['tid'] = 23;


Note that the 23 above is the term ID of the taxonomy term. 
If you have an array of terms, you can assign all of them like below:

$terms = array(23, 45, 678, 1212);
foreach ($terms as $tid) {
  $node-&gt;field_beaches_tags[$node-&gt;language][]['tid'] = $tid;
}


Keys in the $node-&gt;field_beaches_tags[$node-&gt;language] array will be used as delta values of the field. 

Create a new taxonomy term

$term = new stdClass();
$term-&gt;name = ‘My New Term Name’;
$term-&gt;vid = 'vocabulary_id'; 
taxonomy_term_save($term);


Now, $term-&gt;tid will be populated with the new term ID that you can use. 
See taxonomy_term_save() for the API doc. 

taxonomy_get_term_by_name() can be used to load terms by a given name. 

$term = taxonomy_get_term_by_name('my existing term name', 'beach_terms');
// $term-&gt;tid will now be in place. 


Your overall code can be like the following.

$terms_given = array('Miami', 'Colombo', 'Pizza');
$node = new stdClass();
$node-&gt;language = LANGUAGE_NONE;
$node-&gt;promote = 0;
$node-&gt;uid = 1;
$node-&gt;type = 'content_type';

foreach ($terms_given as $term_name) {
  $terms_matched = taxonomy_get_term_by_name($term_name, 'beach_terms'); // "beach_terms" is the machine name of vid 1.
  if ($terms_matched) {
    //We blindly use the first match. Not very elegant.
    $first_term = current($terms_matched);
    $node-&gt;field_beaches_tags[$node-&gt;language][] = (array) $first_term;
  }
  else {
    $term = new stdClass();
    $term-&gt;name = term_name;
    $term-&gt;vid = 1; // Vid from the question. 
    taxonomy_term_save($term);
    $node-&gt;field_beaches_tags[$node-&gt;language][] = (array) $term;
  }
}