relational-database

displaying Cgridview in yii

这一生的挚爱 提交于 2019-12-11 14:39:21
问题 how can i display a record in Cgridview? tbl_book: id title author tbl_in_out: id book_id date_out date_in I have created a relationship that the book_id in tbl_in_out belongs to id in tbl_book. what i want to do is to query a record in the tbl_in_out with the corresponding data in tbl_book and display it in the CGridview(sorry for the bad english). Please help! 回答1: Basic grid view: // the following code goes in your view $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>

Echo nested JSON array from related database tables with a single query?

拜拜、爱过 提交于 2019-12-11 14:24:29
问题 I have two database tables that contain information about land contracts. They are related with land_contract_annual_price.land_contract_id -> land_contract.land_contract_id . Table 'land_contract' Table 'land_contract_annual_price' If a land contract has the value "Rörligt pris" in the field land_contract_price_type, there are related values in the table land_contract_annual_price . At the moment I'm doing two queries, one to each table. I then merge the results and present the land contract

Storing and referencing an immutable ordered list in a relational database

允我心安 提交于 2019-12-11 13:55:50
问题 Background: I have a database containing parents and children's names (this is a simplification of the actual data, but the analogy is close enough). Task: The database has to store an ordered list of children's names for each parent . Assumptions: The database will contain millions of parents, possibly more. Parents typically have no more than to 4 or 5 children, but rare (and even extreme) cases have to be supported as well. Children's names (as well as the ordering) tends to repeat a lot.

Relational Database and Normalization for Relational Tables

点点圈 提交于 2019-12-11 12:29:44
问题 Im trying to figure out what the appropriate way to setup a database would be given this scenario: I am creating a Movie / TV database. A movie may have multiple genres and a tv show may have multiple genres. Essentially what I am wondering is if you have a Movie table, TV table... should you: have a MovieHasGenre table consisting of a foreign key to the Movie table and a regular field for the genre value or have a MovieHasGenre table AND a Genre table where the MovieHasGenre has two foreign

Inserting From a single Table into multiple tables while Normalizing the database

五迷三道 提交于 2019-12-11 12:19:43
问题 Ok so i have a table with the following columns col1 col2 col3 a a 1 a a 2 a b 3 a b 4 a b 5 so i have to split the above mentioned table into multiple tables while keeping col1 and col2 in a separate table and a primary key to foreign key relation with col3 in another table. This is how it looks. table1 Id col1 col2 table2 id col3 table1fk I was able to split the table into two tables but it created the duplicate rows in the table1 and mapped them to single row in table2. What i wanted to

How to add new relations and making weight dependent in MySQL database?

非 Y 不嫁゛ 提交于 2019-12-11 12:12:56
问题 I am working on a health app and I'm designing a database (MySQL), which should store symptoms and diseases and bodyparts. The app will work as follows: User chooses gender, age and bodypart (front/back) App shows all (common/less common) symptoms of chosen bodypart User chooses symptom App shows all (common/less common) diseases of chosen symptom. User chooses disease App shows disease information I got some help so far, but I still need some help finding a solution: Making weight in symptom

BCNF Decomposition?

北慕城南 提交于 2019-12-11 11:18:30
问题 Given relation R(A,B,C,D,E) and FDs = {A->BC, CD->E, B->D, E->A} While converting R into BCNF: ABCDE -> BD & ABCE will be first decomposition BD is in BCNF Regarding ABCE: Opinion 1: ABCE has FDs: A->BCE, E->ABC, BC->AE Therefore its already in BCNF Opinion 2 ABCE has FDs: A->BC, E->ABC Therefore needs to be decomposed into ABC & AE I believe that first one should be correct because in second we are assuming that A->E and BC->E are not possible because D is not one of the attributes of the

Enforce Uniqueness of Related Entities

拜拜、爱过 提交于 2019-12-11 11:01:42
问题 In a relational database (SQL), I have a parent entity that can have 0..n related child entities. The parent entity is uniquely identified in part by its collection of related child entities, such that I should not be able to have two similar parents with the same collection of children. So I could have Parent 1 with Child 1 and Child 2, and Parent 2 with Child 2 and Child 3, but I cannot have another parent with Child 2 and Child 3. Ideally, I would like to enforce this uniqueness using a

MySQL multiple foreign keys

谁说我不能喝 提交于 2019-12-11 10:32:59
问题 I'm new to setting up relational databases. I'm trying to create two tables in MySQL, a USER table and a COMPANY table. Both should be able to have multiple phone numbers associated with them, so I created a PHONE table and wanted to have a one-to-many relationship from both COMPANY to PHONE, and from USER to PHONE. There only seem to two options in what I am trying to do: Keep two foreign keys in PHONE, one referencing COMPANY, and one referencing USER. They would both default to NULL and

Relational Database System with dynamic columns with dynamic rows

别来无恙 提交于 2019-12-11 10:24:55
问题 ppl, I've to develop a Database like this, Here, I've a list of words. I need to keep relevancy for each other word in a database. when a new word added, I need to be able to add a row as well as a column. One of my idea for this is like this, CREATE TABLE tbl_Words ( [WordID] BIGINT NOT NULL IDENTITY(1,1), // This s Primary Key [Word] VARCHAR(250) NOT NULL, // This s Unique.. ) CREATE TABLE tbl_WordRelevancy ( [RelID] BIGINT NOT NULL IDENTITY(1,1), // Primary Key [Word1] VARCHAR(250) NOT