relational

Adding a sub query to an already giant query

只愿长相守 提交于 2019-12-11 19:16:45
问题 This question is kind of a follow up to this question I asked a month ago. Here are my three tables. Fighters fighter_id | name ----------------------- 1 | John 2 | Steve 3 | Bill 4 | Bobby Events event_id | event_name | event_date ------------------------------------------- 1 | MMA | 01/01/2010 2 | Cool | 02/20/2010 3 | Yeaa! | 04/15/2010 Fights fight_id | fighter_a | fighter_b | winner | method | event ----------------------------------------------------------------------- 1 | 1 | 2 | 1 |

How would I find the highest/largest of something with relation algebra, domain relational calculus and tuple relational calculus

帅比萌擦擦* 提交于 2019-12-11 18:37:25
问题 This is part of a homework assignment. I've got several questions asking find the eid of the employee with the highest salary, or 2nd highest salary. Find the pilot that is certified for the most aircrafts. I don't have any idea on how to do it. There aren't any examples in the chapter, and google is proving less that helpful. If someone could show me how to do just one of these, it'll help a lot. here are the tables: Aircraft( aid : integer, aname : string, cruisingrange : integer )

How to wire a middle tier of Objects to a data tier consisting of a DataSet?

喜你入骨 提交于 2019-12-11 12:15:32
问题 I have a middle tier containing several related objects and a data tier that is using a DataSet with several DataTables and relationships. I want to call a Save method on one of my objects (a parent object) and have its private variable data transformed into a DataRow and added to a DataTable. Some of the private variable data are actually other objects (child object) that each need to have their own Save method called and their own variable data persisted. How do I "lace" this together? What

Relational Database emergency person + contact number?

帅比萌擦擦* 提交于 2019-12-11 11:05:10
问题 I'm trying to design a normalized relational database where a patient has a * contact person * (person who is contacted in case of emergency). I also have a table called contact_num which takes patient_id as a foreign key. But how can I implement having a emergency contact person (who has a phone number) who may/may not be another patient? Should I implement emergency_contact_num table? Or some kind of unary relationship? egs would be helpful 回答1: I think you could have a contacts book, all

mysql query normal relationship table vs concatenated realtionship table

梦想的初衷 提交于 2019-12-11 09:49:41
问题 I have a question about relationships between two tables. Let's say we have a table users, and links. users +++++++++ id name 1 name1 2 name2 3 name3 +++++++++ links +++++++++ id link 1 link1 2 link1 3 link1 +++++++++ Now the normal way to link these two is with a name_links table. For example: name_links ++++++++++++ uid lid 1 1 1 3 2 3 2 1 2 2 3 2 ++++++++++++ Now i was wondering if it is a good idea to make a table like this name_links ++++++++++++ uid lid 1 1,3 2 1,2,3 3 2 ++++++++++++

How do I represent object classification hierarchy in a RDBMS

萝らか妹 提交于 2019-12-11 07:47:33
问题 My data, IF it would be represented by objects, it would look like: abstract class A{ int a; int b; string c; } class B inherits A{ string D; } class C inherits A{ int e; int f; } My question: Do I create a separate table for entities B and C, Or do I create one main table, and for each entity type I do different joins to fetch the data. In the real world, I will have around 15 similar fields for all entities, and about 1-3 unique field for each entity. I expect a max of 100K records. Any

Convert categorical data in data frame to weighted adjacency matrix

醉酒当歌 提交于 2019-12-11 06:53:02
问题 I have the following data frame, call it DF, which is a data frame consisting in three vectors: "Chunk" "Name," and "Frequency." I need to turn it into a NameXName adjacency matrix where Names are considered adjacent when they reside in the same chunk. So for example, in the first lines, Gretel and Friedrich are adjacent because they are both in Chunk2. And the weight of the relationship should be based on "Frequency," precisely the number of times they are co-present in the same chunk, so

insert php array into mySql

痞子三分冷 提交于 2019-12-11 04:40:02
问题 I am looking for some guidance. I have a data form field which I am inserting into a table and am looking to association the data with the id's of other relevant data. I was wondering if there was recommended way to insert an array of relevant Id's in relation to the information I am referring too. Below is what Im thinking... Eg. php reads <?php $name = $_POST['name']; $info = $_POST['information']; $id = $_POST['id']; $family = array(); ?> <?php $select = "SELECT * FROM `names_family` WHERE

Graph Edges Rails

女生的网名这么多〃 提交于 2019-12-11 01:16:34
问题 I found this recently when trying to do bidirectional relationships in rails (http://www.dweebd.com/sql/modeling-bidirectional-graph-edges-in-rails/) class Befriending < ActiveRecord::Base belongs_to :initiator, :class_name => :User belongs_to :recipient, :class_name => :User after_create do |b| BefriendingEdge.create!(:user => b.initiator, :befriending => b) BefriendingEdge.create!(:user => b.recipient, :befriending => b) end end class BefriendingEdge < ActiveRecord::Base belongs_to :user

Relational Algebra - Cartesian Product vs Natural Join?

↘锁芯ラ 提交于 2019-12-09 11:24:49
问题 I am studying for exams and am failing to find a solid criteria by which I can determine if the Cartesian Product x is to be used or if Natural Join |X| is to be used. I had come up with a rough guide that: "If you need to project an attribute that has the same name as an attribute in the table to be joined you must use x and state the table names to be projected: tableA.colname1 = tableB.colname1 " This however doesn't follow some of the solutions in my notes and my lecturer seems to use x