A dataset is an organized collection of records and attributes assembled for a particular purpose. In an IT asset management system, it supplies realistic rows for database experimentation. section 5.1
A useful dataset task specifies:
- The target table, columns, data types, row count, ordering, and valid values. section 5.1
- Relationships such as funding details and depreciation strategies that connect asset records. section 5.1
- A generation method suited to the task, such as SQL series and random values or Python with Faker, pandas, and NumPy. section 5.1
1,000 asset records
A generated asset dataset can contain sequential identifiers, names, statuses, categories, costs, useful lives, salvage values, purchase dates, and funding-detail identifiers. SQL can insert 1,000 rows directly into PostgreSQL; a Python script can generate comparable data with Faker and data-science libraries. section 5.1
Listing 5.8 Creating a dataset for the assets table
-- Generate a dataset of assets for an ITAM system. The dataset should include the following columns: id (int), name (varchar), status (varchar), category (varchar), cost (float), useful_life (int), salvage_value (float), purchase_date (date), funding_details_id (int). The dataset should have 1000 rows, sorted by id. Each row should have the following characteristics: -- - id should be a unique integer and sequential starting at 1. -- - name should be a random string of characters between 1 and 50 characters long. -- - status should be a random selection from the following valid asset statuses: in use, in storage, disposed of, in repair, in transit, other. -- - category should be a random selection from the following valid categories: hardware, software, other. -- - cost should be a random float between 0 and 100000. -- - useful_life should be a random int between 1 and 10. -- - salvage_value should be a random float greater than 0 but less than the cost of the asset. -- - purchase_date should be a random date between 1/1/2019 and 12/31/2022. -- - funding_details_id should be a random integer either 1 or 2. -- The dataset should be saved as a CSV file named assets.csv in the data directory. The file should have a header row and the columns should have the following data types: id (int), name (varchar), status (varchar), category (varchar), cost (float), useful_life (float), salvage_value (float), funding_details_id (int)
Inspect the prompt pattern for defining asset columns, valid values, row count, identifiers, and ordering before generating records. section 5.1























