database-schema

“Relation” versus “relationship” in RDBMS/SQL?

梦想的初衷 提交于 2020-01-01 03:34:10
问题 Coming from question “Relation” versus “relationship” What are definitions of "relation" vs. "relationship" in RDBMS (or database theory)? Update: I was somewhat perplexed by comment to my question: "relation is a synonym for table, and thus has a very precise meaning in terms of the schema stored in the computer" Update2: Had I answered incorrectly that question , in terms of RDBMS, having written that relation is one-side direction singular connection-dependence-link, i.e. from one table to

Want to restrict the value of a MySQL field to specific range (Decimal values)

做~自己de王妃 提交于 2020-01-01 03:33:06
问题 I want to restrict the value of a field in a row of a table to a specific range. Is it possible to restrict my relationship_level field to [0.00 to 1.00] ? At the moment I am using DECIMAL(2,2), it wouldn't allow DECIMAL(1,2) as M must be >= D. I assume a data type of DECIMAL(2,2) will actually allow values from 00.00 up to 99.99? CREATE TABLE relationships ( from_user_id MEDIUMINT UNSIGNED NOT NULL, to_user_id MEDIUMINT UNSIGNED NOT NULL, relationship_level DECIMAL(2,2) UNSIGNED NOT NULL,

Poll Database Schema

匆匆过客 提交于 2019-12-31 08:58:09
问题 What is the best database schema for polls? Is one-to-many relationship good for this? I'm thinking about having two tables: poll_questions int id varchar body datetime created_at datetime updated_at poll_answers int id varchar body int votes default 0 int question_id (foreign key to poll_questions.id) datetime created_at datetime updated_at Then there would also be third table for tracking who voted for an answer so users are able to vote only once: poll_voting_history int id int question_id

Poll Database Schema

青春壹個敷衍的年華 提交于 2019-12-31 08:58:07
问题 What is the best database schema for polls? Is one-to-many relationship good for this? I'm thinking about having two tables: poll_questions int id varchar body datetime created_at datetime updated_at poll_answers int id varchar body int votes default 0 int question_id (foreign key to poll_questions.id) datetime created_at datetime updated_at Then there would also be third table for tracking who voted for an answer so users are able to vote only once: poll_voting_history int id int question_id

SQL Group by Date Range

半城伤御伤魂 提交于 2019-12-31 01:58:12
问题 I have the following data: Date Code 2014-08-01 A 2014-08-02 A 2014-08-03 A 2014-08-04 A 2014-08-05 A 2014-08-06 A 2014-08-07 A 2014-08-08 XXXX 2014-08-09 XXXX 2014-08-10 BB 2014-08-11 CCC 2014-08-12 CCC 2014-08-13 CCC 2014-08-14 CCC 2014-08-15 CCC 2014-08-16 CCC 2014-08-17 CCC 2014-08-18 XXXX 2014-08-19 XXXX 2014-08-20 XXXX 2014-08-21 XXXX 2014-08-22 XXXX 2014-08-23 XXXX 2014-08-24 XXXX 2014-08-25 XXXX 2014-08-26 XXXX 2014-08-27 XXXX 2014-08-28 XXXX 2014-08-29 XXXX 2014-08-30 XXXX 2014-08-31

MySQL: How can I get the timestamp of the last insertion to the database

怎甘沉沦 提交于 2019-12-31 01:50:29
问题 How can I check when was the last time (timestamp) that I wrote in the database, irrespectively of the database table that I inserted into? 回答1: Turned out to not be the answer (can't delete as accepted). See comments below this answer. I wasn't able to use information_schema.tables update_time as the column wasn't being updated but for create_time this worked. It would work for update_time (if changed) if update_time gets updated which might be true in your setup. select table_schema,table

Database with “Open Schema” - Good or Bad Idea?

青春壹個敷衍的年華 提交于 2019-12-29 17:46:47
问题 The co-founder of Reddit gave a presentation on issues they had while scaling to millions of users. A summary is available here. What surprised me is point 3: Instead, they keep a Thing Table and a Data Table. Everything in Reddit is a Thing: users, links, comments, subreddits, awards, etc. Things keep common attribute like up/down votes, a type, and creation date. The Data table has three columns: thing id, key, value. There’s a row for every attribute. There’s a row for title, url, author,

Data Modeling: Logical Modeling Exercise

我只是一个虾纸丫 提交于 2019-12-29 11:41:28
问题 In trying to learn the art of data storage I have been trying to take in as much solid information as possible. PerformanceDBA posted some really helpful tutorials/examples in the following posts among others: is my data normalized? and Relational table naming convention. I already asked a subset question of this model here. So to make sure I understood the concepts he presented and I have seen elsewhere I wanted to take things a step or two further and see if I am grasping the concepts.

RailRoad is not working. Giving me issues ie /railroad-0.5.0/lib/railroad/app_diagram.rb:54:in `disable_stdout': uninitialized constant

本秂侑毒 提交于 2019-12-29 08:33:27
问题 Here is various outputs railroad -M | dot -Tsvg > models.svg /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/railroad-0.5.0/lib/railroad/app_diagram.rb:54:in `disable_stdout': uninitialized constant AppDiagram::PLATFORM (NameError) from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/railroad-0.5.0/lib/railroad/app_diagram.rb:72:in `load_environment' from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems/railroad-0.5.0/lib/railroad/app_diagram.rb:18:in `initialize' from /Users/me/.rvm/gems/ruby-1.9.2-p290/gems

How to validate database schema programmatically in hibernate with annotations?

僤鯓⒐⒋嵵緔 提交于 2019-12-29 06:25:18
问题 It seems that org.hibernate.cfg.Configuration object can be used to perform validation programmatically, by calling the validateSchema method. However, this method needs dialect and databaseMetadata objects. I am using Spring and I can get a hold of AnnotationSessionFactoryBean object from spring context. So far I have the following code: AnnotationSessionFactoryBean factory = null; factory = (AnnotationSessionFactoryBean) context.getBean("AnnotationSessionFactory"); Configuration