* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Importing Data into a Relational Database using Append Queries
Microsoft SQL Server wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Ingres (database) wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Clusterpoint wikipedia , lookup
Object-relational impedance mismatch wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
GCE Applied ICT Unit 2 Importing Data into a Relational Database using Append Queries. Data can be imported into a database from a text file using append queries. This method is a good way of finding any invalid data (rejected records) and is also used when a primary key is missing in the text file. Create the database tables required and set any validation rules. Create the relationships between the tables. The following example uses the Bike database: Import the Bike Data text file into a new table which is a temporary table created by the import wizard. Select Next to the next two screens and do not select a primary key: Continue to the last screen, name your table Bike Sales 2005_temp and select Finish. 841003419 Page 1 GCE Applied ICT Unit 2 Creating an Append Query An Append Query needs to be created to add the Bike data from the Bike Sales 2005_temp table into the Bikes table. Create a query in design view; select the temporary table – Bike Sales 2005_temp. Select Append Query from the Query menu. Enter the name of the table to append the data to, e.g. Bikes. Select the fields required for the Bikes table: Save and close the query giving it a suitable name, e.g. Append Bikes. Run the query by double-clicking. Check the all of the records and the fields have been added to the Bikes table. Customers Table An Append Query needs to be created to add the Customer data from the Bike Sales 2005_temp table into the Customers table. The Customer ID (primary key) is not found on the Bike Sales 2005_temp table but it will be created when the data is appended because the Customer ID field has been set as an Autonumber. Run the query and check the records and fields on the Customers table. 841003419 Page 2 GCE Applied ICT Unit 2 Creating an Update Query Before any data can be added to the Orders table a Customer ID has to be added to the temporary table with the correct generated Customer ID from the Customers table. Open the temporary table in design view and add a Customer ID field to the design – set the data type to Number. Create a query using the Customers table and the Bike Sales 2005_temp table. The tables should show a link between them on Customer ID. This link will not work because there the records will not match on this field. Remove this link and re-link the two tables by dragging and dropping the Title, First Name, Last Name, Address Line 1, Town, County, Post Code fields. Convert the query to an Update Query by selecting Query – Update Query. Drag the Customer ID field from the Bike Sales 2005_temp table onto the layout (into the Field position) and add the code to update this field to the Customer ID from the Customers table: [Customers].[Customer ID] Save the query as Update Customer ID and run the query. Check the Customers table to make sure that the correct Customer ID has been added to the records in the Bike Sales 2005_temp table. 841003419 Page 3 GCE Applied ICT Unit 2 Create an Append query to add the orders from the temporary table – you should have all of the fields that you need now on the Bike Sales 2005_temp table. Check the Orders table to make sure that the correct data has been added. Finished 841003419 Page 4