relational

Efficient persistent data structures for relational database

喜你入骨 提交于 2019-11-29 03:16:36
问题 I'm looking for material on persistent data structures that can be used to implement a relational model. Persistence in the meaning of immutable data structures. Anyone know of some good resources, books, papers and such? (I already have the book Purely Functional Data Structures, which is a good example of what I'm looking for.) 回答1: It is straightforward to modify the ubiquitous B-tree to be persistent. Simply always alloctate a new node whenever a node is modified, and return the new node

Using Tuples in Ruby?

被刻印的时光 ゝ 提交于 2019-11-28 21:58:18
问题 Does anyone use tuples in Ruby? If so, how may one implement a tuple? Ruby hashes are nice and work almost as well, but I'd really like to see something like the Tuple class in Python, where you can use . notation to find the value for which you are looking. I'm wanting this so that I can create an implementation of D, similar to Dee for Python. 回答1: OpenStruct? Brief example: require 'ostruct' person = OpenStruct.new person.name = "John Smith" person.age = 70 person.pension = 300 puts person

Database - Designing an “Events” Table

烂漫一生 提交于 2019-11-28 16:24:21
After reading the tips from this great Nettuts+ article I've come up with a table schema that would separate highly volatile data from other tables subjected to heavy reads and at the same time lower the number of tables needed in the whole database schema, however I'm not sure if this is a good idea since it doesn't follow the rules of normalization and I would like to hear your advice, here is the general idea: I've four types of users modeled in a Class Table Inheritance structure, in the main "user" table I store data common to all the users ( id , username , password , several flags , ...

Should I delete or disable a row in a relational database?

邮差的信 提交于 2019-11-28 16:19:06
问题 In a brand new program where space isn't really that big a deal, is it better to delete a row or to disable a row by let's say a boolean "Disabled" and have the program just ignore it? For example, if I wanted to remove a user from a program. 回答1: Not deleting will create a new class of bugs for all future queries. Don't forget that query writing is often done by power users (i.e. non-IT professionals), and junior developers. So now every table that has invalid data marked only by a BIT

mySQL - Insert into three tables

喜夏-厌秋 提交于 2019-11-28 12:57:43
I recently asked this question. I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after. Is it possible with a single query to query an id in the first table which gives all results from the third table that relate to it? My chosen solution was: select * from table1 t1 join table2 t2 on t1.t2ref = t2.id join table3 t3 on t2.t3ref = t3.id Add a where clause to search for certain rows in table1 where t1.field = 'value' My new question is: I have realised that I

SQL selecting rows where one column's value is common across another criteria column

旧街凉风 提交于 2019-11-28 08:28:36
I have a cross reference table that looks like this: id document_id subject_id 1 8 21 2 5 17 3 5 76 4 7 88 5 9 17 6 9 76 7 2 76 It matches documents to subjects. Documents can be members of more than one subject. I want to return rows from this table where a given document matches all the subjects in a given set. For example, given the set of subjects: (17,76) I want to return only rows for documents which match all the subjects in that set (at least) somewhere in the cross reference table. The desired output set given the above set would be: id document_id subject_id 2 5 17 3 5 76 5 9 17 6 9

How do you document your database structure? [closed]

主宰稳场 提交于 2019-11-28 06:19:59
Many database systems don't allow comments or descriptions of tables and fields, so how do you go about documenting the purpose of a table/field apart from the obvious of having good naming conventions? (Let's assume for now that "excellent" table and field names are not enough to document the full meaning of every table, field and relationship in the database.) I know many people use UML diagrams to visualize the database, but I have rarely—if ever—seen a UML diagram including field comments. However, I have good experience with using comments inside .sql files. The downside to this approach

Database schema-related problem

不问归期 提交于 2019-11-27 19:33:39
I have a kind of theoretical question about databases. To make it more concrete I have thought up an example case. Suppose I have a store with products. I have lots of different products. Not every product has the same applicable properties. For instance, I could define the size of a harddisk in gigabytes, but cannot use that same property on a CPU, simply because it does not apply. What I want is a database where I can add properties to products dynamically. The only thing I can come up with is the following: One product table with an ID, a Name and a Description. One properties table with an

Database - Designing an “Events” Table

▼魔方 西西 提交于 2019-11-27 09:52:23
问题 After reading the tips from this great Nettuts+ article I've come up with a table schema that would separate highly volatile data from other tables subjected to heavy reads and at the same time lower the number of tables needed in the whole database schema, however I'm not sure if this is a good idea since it doesn't follow the rules of normalization and I would like to hear your advice, here is the general idea: I've four types of users modeled in a Class Table Inheritance structure, in the

mySQL - Insert into three tables

£可爱£侵袭症+ 提交于 2019-11-27 07:18:45
问题 I recently asked this question. I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after. Is it possible with a single query to query an id in the first table which gives all results from the third table that relate to it? My chosen solution was: select * from table1 t1 join table2 t2 on t1.t2ref = t2.id join table3 t3 on t2.t3ref = t3.id Add a where clause