

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

# 示例数据库
<a name="c_sampledb"></a>

本节介绍 TICKIT，这是 Amazon Redshift 文档示例使用的示例数据库。

这个小型数据库包含七个表：两个事实表和五个维度。您可以按照《Amazon Redshift 入门指南》中的[步骤 4：从 Amazon S3 将数据加载到 Amazon Redshift](https://docs.amazonaws.cn/redshift/latest/gsg/rs-gsg-create-sample-db.html) 中的步骤加载 TICKIT 数据集。

![\[TICKIT 示例数据库中的七个表及其相互关系。\]](http://docs.amazonaws.cn/redshift/latest/dg/images/tickitdb.png)


此示例数据库应用程序帮助分析人员跟踪虚构的 TICKIT 网站的销售活动，用户可以在该网站上在线购买和销售体育赛事、演出和音乐会的门票。具体而言，分析人员可以识别一段时间内门票的变化、卖方的成功率以及最畅销的活动、场馆和季节。分析人员可以使用这些信息向经常访问该站点的买方和卖方提供奖励，吸引新用户，以及推动广告和促销活动。

例如，下面的查询根据 2008 年销售的门票数，查找圣地亚哥排名前五的卖方：

```
select sellerid, username, (firstname ||' '|| lastname) as name,
city, sum(qtysold)
from sales, date, users
where sales.sellerid = users.userid
and sales.dateid = date.dateid
and year = 2008
and city = 'San Diego'
group by sellerid, username, name, city
order by 5 desc
limit 5;

sellerid | username |       name        |   city    | sum
----------+----------+-------------------+-----------+-----
49977 | JJK84WTE | Julie Hanson      | San Diego |  22
19750 | AAS23BDR | Charity Zimmerman | San Diego |  21
29069 | SVL81MEQ | Axel Grant        | San Diego |  17
43632 | VAG08HKW | Griffin Dodson    | San Diego |  16
36712 | RXT40MKU | Hiram Turner      | San Diego |  14
(5 rows)
```

用于本指南中示例的数据库包含一个小的数据集，其中包含两个事实表，每个表包含的行数不超过 200000，维度范围从 CATEGORY 表中的 11 行到 USERS 表中的大约 50000 行。

具体而言，本指南中的数据库示例演示 Amazon Redshift 表设计的主要功能：
+ 数据分布
+ 数据排序
+ 列式压缩

有关 TICKIT 数据库中表架构的信息，请选择以下选项卡：

------
#### [ CATEGORY table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------
#### [ DATE table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------
#### [ EVENT table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------
#### [ VENUE table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------
#### [ USERS table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------
#### [ LISTING table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------
#### [ SALES table ]

[\[See the AWS documentation website for more details\]](http://docs.amazonaws.cn/redshift/latest/dg/c_sampledb.html)

------