relational

Can a relation have Candidate Keys with different lengths?

▼魔方 西西 提交于 2020-07-11 05:58:36
问题 We can have more than one candidate key in a relation. But can we have two candidate keys in a relation different in length? Suppose I have a relation R(A,B,C,D,E) and we have only two sets of attributes which uniquely identify a tuple in the relation: {A,B,C} and {D,E}. So can we say both {A,B,C} and {D,E} are candidate keys? 回答1: But can we have two candidate keys in a relation different in length? Yes. A CK (candidate key) is a superkey (unique column set) that doesn't contain a smaller

Choosing a database type [closed]

瘦欲@ 提交于 2020-01-11 06:07:09
问题 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 5 months ago . When would you use a bigtabe/simpledb database vs a Relational database? 回答1: Relational databases give you a lot more layout and query flexibility, and are easier to use, but you also end up with more pain if you later need to partition your data if it won't fit on a single

Ruby On Rails Relationships - One to Many

我的梦境 提交于 2020-01-06 04:50:10
问题 I'm a beginning to ROR, but here's what I'm trying to achieve. I have two items I want to associate: matters and people. Each matter can have many people. That is, I want to create people and matters separately and later be able to link them. For example, I may create: Bill Clinton Barack Obama I may create the matters: Global warming War on terror I want to be able to associate the users Bill Clinton AND Barack Obama to BOTH matters. Can someone point me to a tutorial that can show me how to

Complex IF statement with 3 tables

馋奶兔 提交于 2019-12-30 11:09:14
问题 This is a continuation of this question from yesterday. Here are my three tables: Fighters Table fighter_id | name ----------------------- 1 | John 2 | Steve 3 | Bill 4 | Bobby Events Table event_id | event_name | event_date ------------------------------------------- 1 | MMA | 01/01/2010 2 | Cool | 02/20/2010 3 | Yeaa! | 04/15/2010 Fights Table fight_id | fighter_a | fighter_b | winner | method | event ----------------------------------------------------------------------- 1 | 1 | 2 | 1 |

Reasonable Export of Relational to Non-Relational Data

Deadly 提交于 2019-12-29 08:25:08
问题 We have different products that rely on relational databases for various reasons, basically the transactional nature of the operations (atomicity, consistency, etc.). This is not going to change any time soon. Given this scenario, are there any possible justifications to export the data to a NoSQL solution? Maybe Datawarehousing, Analytics, etc. Any comments are welcome. 回答1: "Data" is just a vague generality without a data structure. "Relational" means the data structure is relations/tables

Database Design NBA

僤鯓⒐⒋嵵緔 提交于 2019-12-24 07:07:45
问题 I am new to database design so sorry if this is obvious beginner question. I use python and sqlalchemy though I don't think that is relevant (the sample code below is psuedo code), though may be wrong. I have looked through some previous questions and didn't see this addressed. Anyway, on to the question. The goal here is to develop a database of NBA information which will have info on all games played and also box scores for every each player, for each game. There are a couple ways this DB

good way to store tags in relational database when there are variable numbers of tags associated with each piece of information

冷暖自知 提交于 2019-12-24 03:15:05
问题 I want to store sentences that can be tagged with variable numbers of tags in an SQL relational database. So, I may have a sentence such as 'As the sun sets slowly in the west, we bid you a fine farewell.' tagged with the following tags: 'farewell', 'goodbye', 'amiable' The number of tags for a sentence can vary. In the example given here, there are three tags. What would be a sensible way to organise this type of information in a relational database? What tables etc. would be reasonable?

Get Common Rows Within The Same Table

杀马特。学长 韩版系。学妹 提交于 2019-12-23 17:24:59
问题 I've had a bit of a search, but didn't find anything quite like what I'm trying to achieve. Basically, I'm trying to find a similarity between two users' voting habits. I have a table storing each individual vote made, which stores: voteID itemID (the item the vote is attached to) userID (the user who voted) direction (whether the user voted the post up, or down) I'm aiming to calculate the similarity between, say, users A and B, by finding out two things: The number of votes they have in

How to use Relation fields in parse.com

旧城冷巷雨未停 提交于 2019-12-23 04:53:21
问题 I'm using parse.com , and I just want to know how to set and get relational data in a ParseObject Subclass, for example like this. Can you please give an example of field of type Relation and show me how to set and get it in the subclass? Thanks so much in advance ! 回答1: I'm not sure about what you are really asking. Relation fields are sets of pointers to other ParseObject . You don't have to add convenience methods in the subclass if you don't need to. The super class ParseObject has all

What is the best way to represent a many-to-many relationship between records in a single SQL table?

风流意气都作罢 提交于 2019-12-21 04:54:07
问题 I have a SQL table like so: Update: I'm changing the example table as the existing hierarchical nature of the original data (State, Cities, Schools) is overshadowing the fact that a simple relationship is needed between the items. entities id name 1 Apple 2 Orange 3 Banana 4 Carrot 5 Mushroom I want to define two-way relationships between these entities so a user viewing one entity can see a list of all related entities. The relationships are defined by an end user. What is the best way to