Category (strong entity) - Category ID (single value, simple numeric), pk - Category Name (single value, simple string) Isa_Category (Category Has Category) Roles: Category fulfills the subclass role and Supercategory fulfills the superclass role. Cardinality: n:1, a super category can have many subcategories Participation: Supercategory is total, there must be a supercatory for each subcategory, but supcategory is partial, not every supercategory must have a subcategory to exist.怎样转化为关系模型
时间: 2024-02-01 14:22:31 浏览: 144
可以将上述实体及其关系转化为以下关系模式:
Category(CategoryID, CategoryName)
- CategoryID: 单值、简单数值,作为主键
- CategoryName: 单值、简单字符串,表示类别名称
Isa_Category(SubcategoryID, SuperCategoryID)
- SubcategoryID: 表示子类别ID,参照Category表的CategoryID字段
- SuperCategoryID: 表示父类别ID,参照Category表的CategoryID字段
其中,Category表表示类别实体,Isa_Category表示类别间的继承关系。在Isa_Category表中,SubcategoryID和SuperCategoryID均参照Category表的CategoryID字段,表示子类别和父类别的关系。在Isa_Category表中,一个父类别可以对应多个子类别,但一个子类别只能有一个父类别。同时,Category表中的CategoryID字段作为主键,保证了每个类别在实体层面的唯一性。
相关问题
使用映射算法将 ER 架构映射到关系数据库架构。使用以下表示法表示生成的关系数据库架构:PK 表示主键,AK 表示备用键,FK 表示外键,并带有指向相应表(主键)的箭头 Book Entity (Strong) - Title (single valued, simple string) - ISBN (single valued, simple alphanumeric string), pk - Edition (single valued, simple numeric) - Date of Publication (single valued, composite concatenation of characters and numbers) - Price (single valued, simple floating point number) - Book Description (single valued, simple string) Author Entity (Strong) - Author Name - Author_id, pk Publisher Entity (Strong) - Publisher id (single value, simple numeric), pk - Publisher Name (single valued, simple string) - Address (single valued, simple string) - together the publisher name and address could make an alternate key because no to publishers can have the same name and address Customer Entity (strong) - Customer_id (single valued, simple string), pk - Name (composite one value for first, middle and last name, simple string) - Mailing Address (single valued, simple string) - Credit Card Number and Expiration Date (single value, simple numeric sequence), alternate key - Phone Number (single value, simple alphanumeric string) - Email Address (single valued, simple alphanumeric string) Shipment (strong) - Date of Shipment ( single valued, composite of strings and numbers) - Tracking Number (single valued, simple alphanumeric string), pk - Date of Expected Delivery ( single valued, compoite of strings and numbers) Order (Strong) - Order Number (single valued, simple number), pk - Mailing Address (single value, simple string) - Method of Shipment (single value, simple string) - Date and Time of Order (when the order was placed) - Total Price of the Order (multivalue, composite) Promotion (strong entity type ) - Promotion id number, pk - Percentage Discount Points (single value, simple float) - Duration of Promotion (start date and end date) ( composite attributes like the dates above) Line Item(weak entity type) - Total price for each book that is ordered (single value, two place precision float) - Quantity of each item ordered Category (strong entity) - Category ID (single value, simple numeric), pk - Category Name (single value, simple string),
将ER架构映射到关系数据库架构,生成的关系数据库架构如下:
Book 表:
- ISBN (主键)
- Title
- Edition
- Date of Publication
- Price
- Book Description
Author 表:
- Author_id (主键)
- Author Name
Publisher 表:
- Publisher id (主键)
- Publisher Name
- Address
- AK: Publisher Name + Address
Customer 表:
- Customer_id (主键)
- Name
- Mailing Address
- Phone Number
- Email Address
- AK: Credit Card Number and Expiration Date
Shipment 表:
- Tracking Number (主键)
- Date of Shipment
- Date of Expected Delivery
Order 表:
- Order Number (主键)
- Mailing Address
- Method of Shipment
- Date and Time of Order
- Total Price of the Order
Promotion 表:
- Promotion id number (主键)
- Percentage Discount Points
- Duration of Promotion (start date and end date)
Line Item 表:
- Book ISBN (外键指向 Book 表)
- Order Number (外键指向 Order 表)
- Total price for each book that is ordered
- Quantity of each item ordered
Category 表:
- Category ID (主键)
- Category Name
需要注意的是,Line Item 表是一个弱实体类型,需要使用两个外键来指向 Book 表和 Order 表。另外,Promotion 表中的 Duration of Promotion 属性是一个复合属性,可以拆分成两个单独的属性来存储。
struct PK_TOPOL_range_vector_o_s { int o_t_version; --- version number of option --- structure PK_LOGICAL_t have_tolerance; --- (PK_LOGICAL_false) double tolerance; --- tolerance PK_range_bound_t bound; --- bounds on min separation PK_range_guess_t guess; --- guess for end on 'topol' [PF] PK_range_opt_t opt_level; --- the level of analysis --- (PK_range_opt_performance_c) PK_range_param_entity_t param_entity; --- option to return a vector and --- parameter on the sub-entity --- (if applicable). Also controls --- whether a fin can be returned --- as the sub_entity. --- (PK_range_param_entity_topol_c) };
这段代码定义了一个名为 `PK_TOPOL_range_vector_o_s` 的结构体,它包含了一些选项,用于控制在寻找拓扑实体和位置向量的全局最小分离距离时的行为。
结构体中包含的字段及其含义如下:
- `o_t_version`:选项结构体的版本号。
- `have_tolerance`:是否使用一个容差值。
- `tolerance`:容差值。
- `bound`:最小分离距离的范围限制。
- `guess`:在拓扑实体上寻找最小分离距离时的猜测值(仅限于面几何计算)。
- `opt_level`:分析的级别,影响算法的性能和精度。
- `param_entity`:控制返回子实体的向量和参数,以及是否使用一条射线返回子实体的信息。
阅读全文