附录
stores_demo 数据库
stores_demo 数据库包含描述虚构业务的一组表,且 GBase 8s 文档中的许多示例基于此数据库。
stores_demo 数据库使用缺省(美国英语)语言环境并且不符合 ANSI 标准。
有关如何创建和填充 stores_demo 数据库的信息,请参阅《GBase 8s DB-Access 用户指南》。
您可以在 OpenAdmin Tool (OAT) 的模式浏览器中查看表的结构以及它们的数据。
stores_demo 数据库映射
stores_demo 数据库中的一些表之间存在关系。
下图显示 stores_demo 数据库中客户、目录顺序和客户电话之间的连接。将一个表中的列与另一个表中同名列连接的阴影指示表之间的关系或连接。
图: 客户和目录顺序之间的连接
下图显示 stores_demo 数据库中客户、电表数据和位置之间的连接。Customer_ts_data、ts_data 和 ts_data_location 表包含时间系列数据。您可以阻止在创建演示数据库时创建这些时间系列表。
图: 客户、用电数据和位置之间的连接
superstores_demo 数据库
superstores_demo 数据库举例说明了对象关系模式。
随 DB-Access 提供的 SQL 文件和用户定义的例程 (UDR) 允许您派生 superstores_demo 对象关系数据库。
superstores_demo 数据库使用缺省语言环境,但并不符合 ANSI 标准。
有关如何创建和填充演示数据库的信息(包括相关 SQL 文件),请参阅《GBase 8s DB-Access 用户指南》。
superstores_demo 表的结构
尽管 superstores_demo 数据库中许多表具有与 stores_demo 表相同的名称,但它们并不相同。
superstores_demo 数据库包括下列表。这些表是按字母顺序(而不是按创建它们的先后顺序)列示的。
- call_type
- catalog
- cust_calls
- customer
- retail_customer
- whlsale_customer
- items
- location
- location_non_us
- location_us
- manufact
- orders
- region
- sales_rep
- state
- stock
- stock_discount
- units
您可以在 OpenAdmin Tool (OAT) 的模式浏览器中查看表的结构以及它们的数据。
用户定义的例程和扩展数据类型
superstores_demo 数据库使用用户定义的例程 (UDR) 和扩展数据类型。
UDR 是由您定义的例程,可在 SQL 语句或其他 UDR 中进行调用。UDR 可返回值,也可不返回值。
GBase 8s 的数据类型系统是可扩展和灵活的系统,支持创建下列各种数据类型:
- 通过重新定义数据库服务器提供的数据类型的某些行为来扩展现有数据类型。
- 由用户定制的数据类型的定义
如下所示,superstores_demo 数据库在 UDR 中创建单值数据类型 percent:
CREATE DISTINCT TYPE percent AS DECIMAL(5,5);
DROP CAST (DECIMAL(5,5) AS percent);
CREATE IMPLICIT CAST (DECIMAL(5,5) AS percent);superstores_demo
数据库创建下列命名行类型:
- location 层次结构:
- location_t
- loc_us_t
- loc_non_us_t
- customer 层次结构:
- name_t
- customer_t
- retail_t
- whlsale_t
- orders 表
- ship_t
location_t 定义
location_id SERIALloc_type CHAR(2) company VARCHAR(20)
street_addr LIST(VARCHAR(25) NOT NULL)
city VARCHAR(25) country VARCHAR(25)
loc_us_t 定义
state_code CHAR(2) zipROW(code INTEGER, suffix SMALLINT)
phone CHAR(18)
loc_non_us_t 定义
province_code CHAR(2) zipcode CHAR(9) phone CHAR(15)
name_t 定义
first VARCHAR(15) last VARCHAR(15)
customer_t 定义
customer_num SERIALcustomer_type CHAR(1)
customer_name name_tcustomer_loc INTEGER
contact_dates LIST(DATETIME YEAR TO DAY NOT NULL)
cust_discount percentcredit_status CHAR(1)
retail_t 定义
credit_num CHAR(19) expiration DATE
whlsale_t 定义
resale_license CHAR(15) terms_net SMALLINT
ship_t 定义
date DATE weight DECIMAL(8,2)
charge MONEY(6,2) instruct VARCHAR(40)
表层次结构
下图显示如何关联 superstores_demo 数据库的分层表。两个表之间的外键和主键关系由从 customer.custnum 和 customer.loc 列指向 location.location_id 列的阴影箭头指示。
图: superstores_demo 表的层次结构