Advantage Data Dictionary agenda • Creating and Managing Data Dictionaries – – – – – Tables, Indexes, Fields, and Triggers Defining Referential Integrity Defining Views Data Dictionary Links User, User Groups, and Permissions • Migrating an Existing Applications to Data Dictionaries • Upgrading Data Dictionaries architecture • Consists of three files – .ADD – Advantage Data Dictionary file – .AM - The memo file for the Advantage Data Dictionary – .AI - The index file for the Advantage Data Dictionary • Only the .ADD and .AM files should be distributed to the client site to avoid collation sequence differences – The .AI file will be created automatically when the data dictionary is first opened data dictionary properties* • Dictionary Name • Paths – Database -- where to create the .ADD, .AM, and .AI files – Default Path -- where tables are created and opened by default – Temporary Path -- where temporary SQL files are created • • • • • • Logins Required and Check User Rights Data Dictionary File Encryption Table Encryption Description Advantage Internet Access Dictionary Version tables and indexes • Data dictionaries can contain both ADTs and DBFs • Existing tables can be added one at a time or in groups • All tables created while connected to a data dictionary as the system administrator (ADSSYS) will be automatically added to the dictionary —continued— tables and indexes • ADT tables bound to a data dictionary cannot be opened as free table • DBF tables can still be opened as free tables • All indexes get opened automatically when the table is opened • Indexes created by a non-Administrative user are temporary and deleted when the users disconnects ADT table features • • • • Referential Integrity Default Field Values Record and Field Level Constraints More Secure Encryption table properties* • Auto Create • Description • Permission Level – Level 1: reading field without rights returns NULL, filtering allowed, equivalent to Paradox behavior – Level 2: reading field without rights returns NULL, filtering returns error, default Advantage permission level – Level 3: can only access via SQL, reading field without rights returns error, equivalent to MS SQL Server behavior • Encryption —continued— table properties • Record Level Constraint – Failed Validation Message – Validates changes for an entire record – Performed when a record insert or update is written/flushed to the Advantage server – Can be any valid Advantage Expression Engine expression index properties • Default Index – Works in conjunction with the TDataSet Descendant and the OLE DB Provider • Primary Index – Advantage Index files only (ADIs) – Can be used as primary key in a Referential Integrity relationship • Index Page Size – Advantage Index files only (ADIs) – Larger page sizes can improve performance when dealing with large numbers of records field properties* • Field Level Constraints – – – – Minimum Field Value Maximum Field Value Value Required (are NULL values allowed) Failed Validation Message • Default Field Value – Any valid Advantage Expression Engine expression • Field Description triggers new • Code automatically executed by the server on INSERT, UPDATE, and DELETE operations • 5 types of triggers – – – – – SQL Scripts Standard 32-bit Windows DLLs Windows COM DLLs Linux Shared Objects .NET Assemblies • Excellent for enforcing business rules and creating audit trails referential integrity • Referential Integrity (RI) is the means by which primary/foreign key relationships are enforced in a database – – – – – – Ensures that a database is logically consistent Primary Table and Primary Key Foreign Table and Foreign Key Update and Delete Rules Primary Key Violation Error Message Cascade Error Message referential integrity rules* • RI Deletion Rules are enforced when the primary key is deleted from the parent table – – – – RESTRICT CASCADE SET NULL SET DEFAULT • RI Update Rules are enforced when the primary key is modified in the parent table – – – – RESTRICT CASCADE SET NULL SET DEFAULT views • Views are virtual tables that are the result of an SQL statement – – – – – Virtual table Contains data from multiple tables or views Created by the data dictionary administrator Excellent for complex queries Is updateable if the underlying SQL cursor is updateable advantage extended procedures • Executed by the Advantage Database Server • Decreases network traffic • Supports any programming language that can create a: – – – – Standard 32-bit Windows DLL Windows COM DLL Linux Shared Object .NET Assembly • Excellent for shared business rules data dictionary links • Data dictionary links provide access to tables in other data dictionaries • SELECT statements only • Tables are read-only —continued— data dictionary links • Two types of links • Direct path links – SELECT * FROM employees a, “\\server\share\hr.add”.employees b WHERE a.employee_id = b.employee_id – Authentication to linked dictionary is done using same User ID and Password as the current dictionary • Alias links using dot notation – UPDATE customers SET address = (SELECT address FROM backup.customers b WHERE b.cust_id = customers.cust_id ) – Authentication to linked dictionary can be done with same User ID and Password or via User Name & Password specified when creating the Alias user access permissions • Control access to database resources – – – – – Tables Fields Views Stored Procedures Data Dictionary Links • Groups and Users • Set these database properties before they take effect – Logins Required – Check User Rights managing permissions* • Permissions are cumulative • Permissions granted on a field(s) imply those same permissions on the table for that field(s) • Methods to make managing users easier: – Generic users: Set up one user name shared by several people, such that each person who uses that user name has the same rights – Named users (via group): Set a different user name for each person, then set up a group that each user name would be a member of, such that each person has the same rights managing data dictionaries new • Advantage Data Architect (ARC) using the integrated Advantage Database Manager • TAdsDictionary component in Advantage TDataSet Descendant client • Advantage Client Engine AdsDD* APIs • System Tables and Procedures system tables* • Provide read-only access to dictionary object properties • Accessible through SQL – Located in the system catalog – Requires the use of dot notation • Table structures will change as new properties are added • Contents of tables varies depending on the user accessing them system procedures* • Allows modification of all dictionary properties through SQL • Most properties require Administrative Access to modify a property • Available on all Operating Systems migrating existing applications 1. 2. 3. 4. 5. 6. 7. 8. Create the Data Dictionary Add or Create Tables Define Referential Integrity Rules Create Views Add Advantage Extended Procedures Add Data Dictionary Links Create Users and Groups Set Permissions data dictionary deployment • AdsDDDeployDatabase • Deploy dictionaries to existing sites • Adds all of your tables, constraints, RI rules, etc. upgrading data dictionaries • Performed using SQL scripts containing: – SQL data definitions statements – system procedures • SQL scripts are generated using the Dictionary Differentiator in Advantage Data Architect • Generating scripts requires two versions of the data dictionary Dictionary Differentiator* • Provides graphical view of the difference between two dictionaries • Generates SQL upgrade scripts for an entire dictionary or a just single object summary • Advantage Data Dictionaries provide a wealth of features unavailable to free tables • Advantage Data Architect is a useful tool to create, manage, and upgrade Advantage Data Dictionaries Advantage Database Server: The Official Guide (ISBN 0-07223084-3) is a new book, written by Cary Jensen and Loy Anderson and published by McGraw-Hill/Osborne Media Group, that systematically guides a developer through key functionality of Advantage and includes a Companion CD with code samples and a single-user license of Advantage Database Server version 7.0. www.AdvantageDatabase.com/go/ads/book