relational-model

Relational design scenario: restrict children relations

穿精又带淫゛_ 提交于 2019-12-13 14:27:39
问题 please consider the following scenario. An pet owner may have multiple cats, and may also have multiple dogs. Some of the dogs are related (ie they fight :-) ) with some of the cats of the same owner . The following relational design does not impose this restriction, as Cats and Dogs of different owners may be related. Is there a way to impose this restriction by relational design? 回答1: You'd need to use identifying relationships to migrate the owner's PK down both "sides" and to the "bottom"

Relational data modeling for sub types

六月ゝ 毕业季﹏ 提交于 2019-12-09 07:06:59
问题 I am learning the Relational Model and data modeling. And I have some confusion in my mind regarding sub types. I know that data modeling is an iterative process and there are many different ways to model things. But I don't know how to choose between different options. Example Suppose we want to model the particles (molecule, atom, proton, neutron, electron, ...). Let's ignore Quark and other particles for simplicity. Since all particles of the same type behave the same, we are not going to

What is Relational Integrity [closed]

我是研究僧i 提交于 2019-12-07 16:31:01
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 10 months ago . In the question How to Set Up Primary Keys in a Relation, PerformanceDBA talked about Relational Integrity and pointed out that it is different from Referential Integrity . I have heard of Referential Integrity , which is related to Foreign Keys . But Relational Integrity seems

Procedurally transform subquery into join

喜欢而已 提交于 2019-12-04 09:06:21
问题 Is there a generalized procedure or algorithm for transforming a SQL subquery into a join, or vice versa? That is, is there a set of typographic operations that can be applied to a syntactically correct SQL query statement containing a subquery that results in a functionally equivalent statement without a subquery? If so, what are they (i.e., what's the algorithm), and in what cases do they not apply? 回答1: Converting a subquery into a JOIN can be pretty straightforward: IN clause FROM TABLE_X

Procedurally transform subquery into join

做~自己de王妃 提交于 2019-12-03 01:54:28
Is there a generalized procedure or algorithm for transforming a SQL subquery into a join, or vice versa? That is, is there a set of typographic operations that can be applied to a syntactically correct SQL query statement containing a subquery that results in a functionally equivalent statement without a subquery? If so, what are they (i.e., what's the algorithm), and in what cases do they not apply? Converting a subquery into a JOIN can be pretty straightforward: IN clause FROM TABLE_X x WHERE x.col IN (SELECT y.col FROM TABLE_Y y) ...can be converted to: FROM TABLE_X x JOIN TABLE_Y y ON y

How to design table with primary key and multivalued attribute?

浪子不回头ぞ 提交于 2019-12-02 22:01:51
问题 I'm interested in database design and now reading the corresponding literature. Through the book, i have faced a strange example that makes me feel uncertain. There is a relation In this table we have a composite primary key (StudentID, Activity). But ActivityFee is partially dependent on the key of the table (Activity -> ActivityFee), so the author suggests to divide this relation into two other relations: Now if we take a look at the STUDENT_ACTIVITY, Activity becomes a foreign key and

How to design table with primary key and multivalued attribute?

荒凉一梦 提交于 2019-12-02 11:15:43
I'm interested in database design and now reading the corresponding literature. Through the book, i have faced a strange example that makes me feel uncertain. There is a relation In this table we have a composite primary key (StudentID, Activity). But ActivityFee is partially dependent on the key of the table (Activity -> ActivityFee), so the author suggests to divide this relation into two other relations: Now if we take a look at the STUDENT_ACTIVITY, Activity becomes a foreign key and relation still has a composite primary key. We've got the table in which the whole columns defines a

Unique key with NULLs

淺唱寂寞╮ 提交于 2019-11-28 07:11:05
This question requires some hypothetical background. Let's consider an employee table that has columns name , date_of_birth , title , salary , using MySQL as the RDBMS. Since if any given person has the same name and birth date as another person, they are, by definition, the same person (barring amazing coincidences where we have two people named Abraham Lincoln born on February 12, 1809), we'll put a unique key on name and date_of_birth that means "don't store the same person twice." Now consider this data: id name date_of_birth title salary 1 John Smith 1960-10-02 President 500,000 2 Jane

Unique key with NULLs

依然范特西╮ 提交于 2019-11-27 01:45:29
问题 This question requires some hypothetical background. Let's consider an employee table that has columns name , date_of_birth , title , salary , using MySQL as the RDBMS. Since if any given person has the same name and birth date as another person, they are, by definition, the same person (barring amazing coincidences where we have two people named Abraham Lincoln born on February 12, 1809), we'll put a unique key on name and date_of_birth that means "don't store the same person twice." Now