# Add metadata to a BigQuery table

Knowledge Catalog (formerly Dataplex Universal Catalog) lets you attach business and technical
metadata to your data assets so that you can organize, discover, and govern
your data. In Knowledge Catalog, each data asset is represented as an
*entry* , and you attach metadata by adding *aspects* ---sets of related
metadata fields defined by a reusable template called an *aspect type*.

In this quickstart, you create a BigQuery dataset and table from a
public BigQuery dataset, create an aspect type, and add an
aspect to the table entry.

## Before you begin

<br />

### Required roles


To get the permissions that
you need to add metadata to a BigQuery table,

ask your administrator to grant you the
following IAM roles on the project:

- [Dataplex Catalog Admin](https://docs.cloud.google.com/iam/docs/roles-permissions/dataplex.md.txt#dataplex.catalogAdmin) (`roles/dataplex.catalogAdmin`)
- [BigQuery Data Owner](https://docs.cloud.google.com/iam/docs/roles-permissions/bigquery.md.txt#bigquery.dataOwner) (`roles/bigquery.dataOwner`)
- [BigQuery Job User](https://docs.cloud.google.com/iam/docs/roles-permissions/bigquery.md.txt#bigquery.jobUser) (`roles/bigquery.jobUser`)


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


You might also be able to get
the required permissions through [custom
roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles) or other [predefined
roles](https://docs.cloud.google.com/iam/docs/roles-overview#predefined).

## Create a dataset and a table

1. In the Google Cloud console, go to the **BigQuery Studio** page.


   [Go to BigQuery Studio](https://console.cloud.google.com/bigquery)

   <br />

2. Create a dataset:

   1. In the left pane, click **Explorer**:

      ![Highlighted button for the Explorer pane.](https://docs.cloud.google.com/static/bigquery/images/explorer-tab.png)

      If you don't see the left pane, click **Expand left pane** to open the pane.
   2. In the **Explorer** pane, find your project. Click
      **View actions** ,
      and then click **Create dataset**.

   3. In the **Dataset ID** field, enter `catalog_demo_dataset`.

      Keep the default values for the other fields.
   4. Click **Create dataset**.

3. Copy a public table to your dataset:

   1. In the **Explorer** pane, search for the table named
      `bigquery-public-data.new_york_citibike.citibike_stations`. You
      might need to set the search scope to include the `bigquery-public-data`
      project.

      This table is part of the NYC Citi Bike Trips dataset, a public dataset
      that contains data about a bike share program.
   2. Select the `citibike_stations` table.

   3. Click **More \> Make a copy of table**, and then enter the
      following information:

      - **Project**: select your project.
      - **Dataset** : select `catalog_demo_dataset`.
      - **Table** : enter `bike_stations`.
   4. Click **Copy**.

4. In the **Explorer** pane, locate the `catalog_demo_dataset` dataset, and
   confirm that the `bike_stations` table is listed in the dataset.

## Define a metadata template: create an aspect type

1. In the Google Cloud console, go to the Knowledge Catalog **Metadata types** page.


   [Go to Metadata types](https://console.cloud.google.com/dataplex/catalog)

   <br />

2. Click the **Aspect types** tab, and then click the **Custom**
   tab.

3. Click **Create aspect type**.

4. In the **Aspect type ID** field, enter `data-governance-demo`.

5. For **Location** , select `global`.

6. In the **Template** section, click
   **Add field**. Use the information in the following table to add several
   fields to the aspect type:

   | Name | Type | Is required | Description |
   |---|---|---|---|
   | `source-of-data-asset` | Text | No | - |
   | `retention-date` | Date and time | No | - |
   | `data-classification` | Enum Add the values `Public`, `Sensitive`, and `Confidential`. | Yes | - |
   | `has-pii` | Boolean | Yes | `Whether the data asset has personally identifiable information` |

7. Click **Save**.

## Add metadata to the table: add an aspect to the entry

1. In the Google Cloud console, go to the Knowledge Catalog **Search**
   page.


   [Go to Search](https://console.cloud.google.com/dataplex/dp-search)

   <br />

2. In the search box, enter `catalog_demo_dataset`.

3. Select the **bike_stations** table.

4. Add a custom aspect to the entry:

   1. In the **Aspects** section, next to
      **Optional aspects** , click
      **Add**.

   2. Select the `data-governance-demo` aspect type.

      This creates an aspect that uses your aspect type as a template.
   3. Enter the following values:

      - **Source of data asset** : `Copied from NYC Citi Bike Trips public dataset`
      - **Retention date**: enter a date.
      - **Data classification** : `Public`
      - **Has PII** : `False`
   4. Click **Save**.

5. To see the metadata values that you added, in the **Aspects**
   section, select the **data-governance-demo** aspect.

## Clean up


To avoid incurring charges to your Google Cloud account for
the resources used on this page, follow these steps.

### Delete the project

The easiest way to stop billing is to delete the project that you created
for this quickstart.

> [!CAUTION]
> **Caution** : Deleting a project has the following effects:
>
> - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.
> - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.
>
>
> If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects
> can help you avoid exceeding project quota limits.

1. In the Google Cloud console, go to the **Manage resources** page.

   [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)
2. In the project list, select the project that you want to delete, and then click **Delete**.
3. In the dialog, type the project ID, and then click **Shut down** to delete the project.

<br />

### Delete individual resources

If you want to reuse your project, delete the resources that you created.

1. Delete the dataset:

   1. In the Google Cloud console, go to the **BigQuery Studio** page.


      [Go to BigQuery Studio](https://console.cloud.google.com/bigquery)

      <br />

   2. In the left pane, click **Explorer**:

      ![Highlighted button for the Explorer pane.](https://docs.cloud.google.com/static/bigquery/images/explorer-tab.png)
   3. In the **Explorer** pane, search for the `catalog_demo_dataset` dataset.

   4. Click
      **View actions** ,
      and then click **Delete**. Confirm when prompted.

2. Delete the aspect type:

   1. In the Google Cloud console, go to the Knowledge Catalog **Metadata types** page.


      [Go to Metadata types](https://console.cloud.google.com/dataplex/catalog)

      <br />

   2. Click the **Aspect types** tab, and then click the
      **Custom** tab.

   3. Click the `data-governance-demo` aspect type.

   4. Click **Delete**. Confirm when prompted.

## What's next

- Learn more about [metadata management](https://docs.cloud.google.com/knowledge-catalog/docs/metadata-overview.md.txt).
- Learn how to [search for resources](https://docs.cloud.google.com/knowledge-catalog/docs/search-assets.md.txt).
- Learn how to [work with aspects and aspect types](https://docs.cloud.google.com/knowledge-catalog/docs/enrich-entries-metadata.md.txt).
- Try [Knowledge Catalog use cases](https://docs.cloud.google.com/knowledge-catalog/docs/use-cases).