relation

Recurrence Relation: Finding Big O

亡梦爱人 提交于 2020-01-03 02:31:12
问题 I am trying to find the big O bound for the following recurrence relation: T(n) = T(n-1) + n^c, where c >= 1 is a constant So I've decided to solve this by using iteration: T(n) = T(n-1) + n^c T(n-1) = T(n-2) + (n-1)^c T(n) = T(n-2) + n^c + (n-1)^c T(n-2) = T(n-3) + (n-2)^c T(n) = T(n-3) + n^c + (n-1)^c + (n-2)^c T(n) = T(n-k) + n^c + (n-1)^c + .... + (n-k+1)^c Suppose k = n-1, then: T(n) = T(1) + n^c + (n-1)^c + (n-n+1+1)^c T(n) = n^c + (n-1)^c + 2^c + 1 I'm not sure if this is correct

How to obtain a minimal key from functional dependencies?

白昼怎懂夜的黑 提交于 2020-01-01 10:57:11
问题 I need some help and guidelines. I have the following relation: R = {A, B, C, D, E, F} and the set of functional dependencies F = { {AB -> C}; {A -> D}; {D -> AE}; {E -> F}; } What is the primary key for R ? If i apply inference rules i get these additional Function dependencies: D -> A D -> E D -> F D -> AEF A -> E A -> F A -> DEF How do I continue? 回答1: There is a well known algorithm to do this. I don't remember it, but the excercise seems to be simple enough not to use it. I think this is

MySQL A or B but NOT both

若如初见. 提交于 2019-12-31 05:09:12
问题 This seems like an easy query but I cannot seem to get it or relate it to other posts on stack overflow. Would anyone be able to explain... This is what I have so far, it is returning records for all bars where one or both people go. TBL frequents Schema - drinker VARCHAR(50) PK, bar VARCHAR(50) PK Bars which are frequented by John or Rebecca but not by both of them SELECT DISTINCT bar FROM frequents WHERE drinker = 'John' XOR drinker = 'Rebecca' AND bar NOT IN ( SELECT f1.bar FROM frequents

Laravel Eloquent Sum of relation's column

冷暖自知 提交于 2019-12-28 05:01:07
问题 I've been working on a shoppingcart application and now I've come to the following issue.. There is a User, a Product and a Cart object. - The Cart table only contains the following columns: "id", "user_id", "product_id" and timestamps. - The UserModel "hasMany" Carts (because a user can store multiple products). - The CartModel "belongsTo" a User and CartModel "hasMany" Products. Now to calculate the total products I can just call: Auth::user()->cart()->count() . My question is: How can I

Laravel 5 eloquent with whereHas more than 3. How to?

我怕爱的太早我们不能终老 提交于 2019-12-25 17:04:10
问题 it seems that it does not work, when I'm using "with" and function inside it and later trying to use "has" function. Here's the code, it should be easier to understand: $users = Users::where("active","=", "1")->with(['photos' => function($q){ $q->where('type','!=', 2); }])->has('photos', '>', 3)->paginate(8); } It seems, that it should return user ONLY if he has 3 photos which are NOT of type 2. But it doesn't care about "where" clause and return it without checking to the type. How can I

Laravel 5 eloquent with whereHas more than 3. How to?

谁说我不能喝 提交于 2019-12-25 17:03:48
问题 it seems that it does not work, when I'm using "with" and function inside it and later trying to use "has" function. Here's the code, it should be easier to understand: $users = Users::where("active","=", "1")->with(['photos' => function($q){ $q->where('type','!=', 2); }])->has('photos', '>', 3)->paginate(8); } It seems, that it should return user ONLY if he has 3 photos which are NOT of type 2. But it doesn't care about "where" clause and return it without checking to the type. How can I

Realm relation field always null [duplicate]

假如想象 提交于 2019-12-25 06:39:14
问题 This question already has answers here : Cannot retrieve field values from realm object, values are null in debugger (3 answers) Closed 2 years ago . There are my models: public class RChat extends RealmObject { @PrimaryKey private String Id; private RMyTest Test; public RChat() {} } and public class RMyTest extends RealmObject { @PrimaryKey private String myName; public RMyTest() { } } And I'm using like this: mRealm = Realm.getInstance(this); mRealm.beginTransaction(); final RChat chat =

Octobercms validation relation user

感情迁移 提交于 2019-12-24 21:17:17
问题 I have the following relation with the user model public $belongsTo = [ 'user' => [ 'Rainlab\User\Models\User', 'key' => 'user_id', 'order' => 'name asc' ] ]; config_relation.yaml user: label: Usuários view: form: $/rainlab/user/models/user/fields.yaml toolbarButtons: create|link manage: showSearch: true showCheckBoxes: true recordsPerPage: 10 list: $/rainlab/user/models/user/columns.yaml form: $/rainlab/user/models/user/fields.yaml I am doing the validation on the user field, but it is not

Get object only when relation result is exist [laravel]

大兔子大兔子 提交于 2019-12-24 18:54:12
问题 I have a problem with get data only when relation query count is more than 0. This is my model of customer with relation class Customer extends Model { protected $table = 'customers'; public function contracts() { return $this->hasMany('App\Contract'); } This is my model of contracts class Contract extends Model { public function customer() { return $this->belongsTo('App\Customer'); } } On the end i need only customers who they contracts beetwen some date $customers = Customer::with([

how to get list of users who are not under belongsToMany relation under a table in laravel?

谁说胖子不能爱 提交于 2019-12-24 03:46:09
问题 Consider the following case. we have the Users table and Tasks table. they are in relation with belongsToMany with table task_user . How to get the list of all users who are not under any task? i.e. their user_id is not at all under that given task or even in the task_user table. why I need this is because like this we can only provide a list of users who are yet to be assigned a task. the task will be assigned to users and not a single user at a time. Editing_____________ also how to filter