Make a replicated database a regular database (MDB)
Note The information in this topic applies only to a Microsoft Access database (.mdb).
After you've converted a database into a Design Master, you can't convert it back to its former status as a regular database. However, if you no longer want to use replication and want to decrease the size of a replicated database, you can create a new, regular database that contains all of the objects and data in your replicated database without the additional system fields, tables, and properties associated with replication.
Note For each table in the new database, create the same index used in the replica table. If the s_GUID is a primary key (and foreign keys in other tables refer to it), you'll want the s_GUID field in the new table. If the s_GUID field is not used as a primary key, there is no reason to preserve it in the new table. Don't copy the s_Lineage and s_Generation fields to the new table.
- Create a blank database and open it.
- On the File menu, point to Get External Data, and then click Import.
- Click the replica that contains the database objects that you want in the regular database, and then click Import.
- Click the database objects
— except tables — that you want to import into the new database. - Click OK to import these objects.
- In the old database, for each table in the replica, create a Make Table Query that takes all the data in the old table and creates a table in the new database with the same data.
- Create a query, selecting the tables or queries that contain the records you want to put in the new table.
- In the Database window, click Queries under Objects, and then click New on the Database window toolbar.
- In the New Query dialog box, click Design View, and then click OK.
- In the Show Table dialog box, click the tab that lists the tables or queries whose data you want to work with.
- Double-click the name of each object you want to add to the query, and then click Close.
- Add fields to the Field row in the design grid, and if you want, specify criteria and a sort order.
- To view the query's results, click View on the toolbar.
- In query Design view, click the arrow next to Query Type on the toolbar, and then click Make Table. The Make Table dialog box appears.
- In the Table Name box, enter the name of the table you want to create or replace.
- Do one of the following:
Click Current Database.
Click Another Database, and then either type the path of the database where you want to put the new table or click Browse to locate the database.
- Click OK.
- Drag from the field list to the query design grid the fields you want in the new table.
- In the Criteria cell for the fields that you've dragged to the grid, type the criteria.
- To preview the new table before you create it, click View on the toolbar. To return to query Design view and make changes or run the query, click View on the toolbar again.
- To create the new table, click Run on the toolbar.
Note The data in the new table you create does not inherit the field properties or the primary key setting from the original table.
- Create a query, selecting the tables or queries that contain the records you want to put in the new table.
- For each table in the new database, create the same index used in the replica's table.
- Open a table in Design view.
- In the upper portion of the window, click the field that you want to create an index for.
- In the lower portion of the window, click in the Indexed property box, and then click Yes (Duplicates OK) or Yes (No Duplicates).
- For each table in the new database, create the relationships that existed for the replica's table.
When you create a relationship between tables, the related fields don't have to have the same names. However, related fields must have the same data type unless the primary key field is an AutoNumber field. You can match an AutoNumber field with a Number field only if the FieldSize property of both of the matching fields is the same. For example, you can match an AutoNumber field and a Number field if the FieldSize property of both fields is Long Integer. Even when both matching fields are Number fields, they must have the same FieldSize property setting.
Define a one-to-many or a one-to-one relationship
- Close any tables you have open. You can't create or modify relationships between open tables.
- Press F11 to switch to the Database window.
- Click Relationships on the toolbar.
- If you haven't yet defined any relationships in your database, the Show Table dialog box is automatically displayed.
If you need to add the tables you want to relate and the Show Table dialog box isn't displayed, click Show Table on the toolbar.
-
Double-click the names of the tables you want to relate, and then close the Show Table dialog box. To create a relationship between a table and itself, add that table twice.
- Drag the field that you want to relate from one table to the related field in the other table.
To drag multiple fields, press the CTRL key, click each field, and then drag them.
In most cases, you drag the primary key field (which is displayed in bold text) from one table to a similar field (often with the same name) called the foreign key in the other table.
- The Edit Relationships dialog box is displayed. Check the field names displayed in the two columns to ensure they are correct. You can change them if necessary.
Set the relationship options if necessary.
- Click the Create button to create the relationship.
- Repeat steps 5 through 8 for each pair of tables you want to relate.
When you close the Relationships window, Microsoft Access asks if you want to save the layout. Whether you save the layout or not, the relationships you create are saved in the database.
Note You can create relationships using queries as well as tables. However, referential integrity isn't enforced with queries.
Define a many-to-many relationship
- Create the two tables that will have a many-to-many relationship.
- Create a third table, called a junction table, and add to the junction table new fields with the same definitions as the primary key fields from each of the other two tables. In the junction table, the primary key fields function as foreign keys. You can add other fields to the junction table, just as you can to any other table.
- In the junction table, set the primary key to include the primary key fields from the other two tables. For example, in an Order Details junction table, the primary key would be made up of the OrderID and ProductID fields.
- Open a table in Design view.
- Select the field or fields you want to define as the primary key.
To select one field, click the row selector for the desired field.
To select multiple fields, hold down the CTRL key and then click the row selector for each field.
- Click Primary Key on the toolbar.
Note If you want the order of the fields in a multiple-field primary key to be different from the order of those fields in the table, click Indexes on the toolbar to display the Indexes window, and then reorder the field names for the index named PrimaryKey.
- Define a one-to-many relationship between each of the two primary tables and the junction table.
- Save your new database.