relational-database

What kind of relationship do these 2 tables require?

送分小仙女□ 提交于 2019-12-08 13:53:00
问题 I have 2 tables and was wondering what the best relationship between them was. I know there is a relationship between them but I get so confused with one to many, many to one, many to many, unidirectional, bidirectional, multidirectional etc. So this is the basic, displayed, structure: Traveler Table: +------------------------------------------+ | Name | Family Name | National ID No. | +------------------------------------------+ | Dianne | Herbert | 579643 | | Francine | Jackson | 183432 | |

Functional dependencies after normalization

三世轮回 提交于 2019-12-08 13:39:29
问题 I'm struggling to understand one aspect of the normalization process, I don't quite understand what to do with functional dependencies after I normalize a relation to 2NF (or 3NF). Let me describe it using an example. The exercise from my school book asks to normalize the relation to 2NF and then to 3NF. We are given a relation R=(ABCDEF) , F={AD->FE, BC->E, FEA->D, AC->DE, F->E, BD->A, F->C, ABC->AEF, B->F} Following the book, I minimized the Functional Dependencies to F = {AD->F, AC->D, BD-

Enforcing common foreign key in many-to-many relationship

巧了我就是萌 提交于 2019-12-08 13:23:29
I have the following interesting data modeling problem. I am going to use the example of restaurants to illustrate it: Consider the following three entities: Restaurant , Location and Offer . A restaurant can have many locations and a restaurant can have many offers . Those relationships are easy to represent: A Restaurant table; a Location table with a FK from the Restaurant table; and a Offer table with a FK from the Restaurant table. The interesting problem comes now: An offer can only be valid on certain locations of a restaurant . The modeling of that restriction seems easy at the

How do I use struct arrays or similar data structures in Android/SQLite?

非 Y 不嫁゛ 提交于 2019-12-08 11:24:07
问题 I am developing an events storing app where each event has its guest list. I am new to android and also sqlite so any help would be greatly appreciated. e.g in C language it would be struct event{ int ID; String eventName; String place,date,comments,venue; // guest[] myGuestList; (i can not achieve this goal) } struct guest{ String guestName; String guestContact; String guestEmail; } this is somewhat my requirement in the Android app im developing. So far I have achieved creating a SQLite

How to select from table A one row and table B multi rows?

不打扰是莪最后的温柔 提交于 2019-12-08 11:17:25
问题 I have two tables. Pages +-----------+----------+------------+ | ID | title | URL | +-----------+----------+------------+ | 1 | test | test.html | | 2 | test2 | test2.html | +-----------+----------+------------+ Files +-----------+----------+------------+ | ID | page_id | name | +-----------+----------+------------+ | 10 | 1 | a.jpg | | 11 | 1 | b.jpg | | 12 | 2 | c.jpg | +-----------+----------+------------+ How to select from PAGES one row and FILES multi rows?? My query as: select * from

Relational Algebra rule for column transformation

爷,独闯天下 提交于 2019-12-08 10:54:12
问题 What is the rule for the transformation of a column in Relational Algebra ? For example, I want to divide all values of a column with the average of that column. I can get average using aggregate rule. But cannot find the rule for column manipulation. P.S: I am interested in the rule (like \Pi is used for projection). 回答1: There's no standard approach to this. Also there's no single relational algebra, so you should give a reference to yours. Suppose you supply the division operator on values

Compound primary key table with subtypes

跟風遠走 提交于 2019-12-08 10:43:08
问题 Me and a database architect were having argument over if a table with a compound primary key with subtypes made sense relationally and if it was a good practice. Say we have two tables Employee and Project. We create a composite table Employee_Project with a composite primary key back to Employee and Project. Is there a valid way for Employee_Project to have subtypes? Or can you think of any scenario where a composite key table can have subtypes? To me a composite key relationship is a 'Is A'

What is a good approach in creating a non-NoSQL, relational multi-schema database?

╄→гoц情女王★ 提交于 2019-12-08 09:09:48
问题 Consider a situation where the schema of a database table may change, that is, the fields, number of fields, and types of those fields may vary based on, say a client ID. Take, for example a Users table. Typically we would represent this in a horizontal table with the following fields: FirstName LastName Age However, as I mentioned, each client may have different requirements. I was thinking that to represent a multi-schema approach to Users in a relational database like SQL Server, this

Enforcing common foreign key in many-to-many relationship

南笙酒味 提交于 2019-12-08 08:55:59
问题 I have the following interesting data modeling problem. I am going to use the example of restaurants to illustrate it: Consider the following three entities: Restaurant , Location and Offer . A restaurant can have many locations and a restaurant can have many offers . Those relationships are easy to represent: A Restaurant table; a Location table with a FK from the Restaurant table; and a Offer table with a FK from the Restaurant table. The interesting problem comes now: An offer can only be

Need some advice and feedback on coding a many:many relationship in MySQL

血红的双手。 提交于 2019-12-08 08:09:58
问题 I am having some difficulty in coding a many:many relationship, as shown in the image below: I am wanting these tables and relationships set up so that: A parent can have more than one child (the child here is the "Player"), and a child can have one or more parents (a maximum of two). A "family" can consist of one or more parents (maximum of two), and also one or more children (unlimited). I am not sure how to accommodate parents that have different surnames than their "children" and vice