relational-database

Any good relational database tutorials? [closed]

这一生的挚爱 提交于 2019-11-30 01:48:41
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am looking for how to build a relational mysql database, and I would like to follow a tutorial. I need one that shows how to make

Rails — How to setup model that can belong to either of 3 different models

╄→гoц情女王★ 提交于 2019-11-30 00:22:21
问题 I'm trying to make an app that does testing similiar to what you would experience in school. I have a model Question, which can belong to either an Exam, Quiz, or Assignment. Should I create fields for ":exam_id, :integer, :null => false; :quiz_id, :integer, :null => false; :assignment_id, :integer, :null => false;"? The question will belong to either one or a few or all of them ( so i can reuse the same question in diff models). Should I remove the :null=>false so it could belong to either

What are the reasons *not* to use a GUID for a primary key?

自闭症网瘾萝莉.ら 提交于 2019-11-29 22:22:04
Whenever I design a database I automatically start with an auto-generating GUID primary key for each of my tables (excepting look-up tables) I know I'll never lose sleep over duplicate keys, merging tables, etc. To me it just makes sense philosophically that any given record should be unique across all domains, and that that uniqueness should be represented in a consistent way from table to table. I realize it will never be the most performant option, but putting performance aside, I'd like to know if there are philosophical arguments against this practice? Based on the responses let me

(Database Design - products attributes): What is better option for product attribute database design?

落花浮王杯 提交于 2019-11-29 20:12:40
I new in database design. What is better option for product attribute database design for cms?(Please suggest other options also). option 1: 1 table products{ id product_name color price attribute_name1 attribute_value1 attribute_name2 attribute_value2 attribute_name3 attribute_value3 } option 2: 3 tables products{ id product_name color price } attribute{ id name value } products_attribute{ products_id attribute_id } Bill Karwin You're making a common mistake of database design, storing name in one column and value in another column. This is not a relational database design. Each attribute

How to understand the 5th Normal Form?

社会主义新天地 提交于 2019-11-29 20:01:51
I'm using two online sources for gaining an understanding of the 5NF, without any rigor of Math and proofs. A Simple Guide to Five Normal Forms in Relational Database Theory (by Kent. This one seems to have been reviewed and endorsed in one of his writings by none other than CJ Date himself) Fifth Normal Form (Wikipedia article) However, I'm unable to understand either of these references! Let's first examine Reference #1 (Kent's). It says: "But suppose that a certain rule was in effect: if an agent sells a certain product, and he represents a company making that product, then he sells that

Difference between one-to-many and many-to-one relationship

假如想象 提交于 2019-11-29 18:55:59
What is the real difference between one-to-many and many-to-one relationship? It is only reversed, kind of? I can't find any 'good-and-easy-to-understand' tutorial about this topic other than this one: SQL for Beginners: Part 3 - Database Relationships Devendra D. Chavan Yes, it a vice versa. It depends on which side of the relationship the entity is present on. For example, if one department can employ for several employees then, department to employee is a one to many relationship (1 department employs many employees), while employee to department relationship is many to one (many employees

The three schema of the database

佐手、 提交于 2019-11-29 18:10:39
I have created a database in Access and right know i have to write a report. I know that the databasesystem has three forms of schemas: physical, conceptual and external. Does the following ER diagram (by using the method normalization ) belongs to the conceptual level?: Or does this belong to the conceptual level?(incl. ref integrity): As for the phisical schema, does this include the integrity rules? The Three-level ANSI-SPARC Architecture aka three schema approach : An external schema is the database (with metadata including constraints) as seen by some user, a view of the conceptual schema

Select all rows that have at least a list of features

微笑、不失礼 提交于 2019-11-29 17:08:18
I have EXPERIMENTAL_RUNS (runId), each of which have any number of SENSORS (sensorId) associated with them. With that in mind, I have an RS table to join the two: ========== RS ========== runId, sensorId Thus if the run with runId=1 had sensors with sensorId=1, sensorId=6, sensorId=8 in it, there would be 3 entries in the RS table: (runId=1, sensorId=1) (runId=1, sensorId=6) (runId=1, sensorId=8) Is this really how I would return all EXPERIMENTAL_RUNS that have sensors {11,13,15}? From what I've read, what I seem to want is a nested hash join... Is this what's going to happen? SELECT a.runId

How to apply complex constraints to a database table in MySQL?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 17:03:59
As I am in the final stages of setting up a database for one of my projects, I have thought of an additional constraint that would need to be added to the Task table (see image below), but I am not sure how this can be implemented in MySQL. Original Database Schema (without markups): Click here. Database Schema with Markups: For each job ( job ), a WBS Code List ( wbscodelist ) is assigned. Each of these lists contain a number of WBS Codes ( wbscodeitem ) that apply to that job. An example would be: Job A uses WBS Code List #1 Job B uses WBS Code List #2 Job C uses WBS Code List #1 etc. WBS

What is the performance difference in MySQL relational division (IN AND instead of IN OR) implementations?

♀尐吖头ヾ 提交于 2019-11-29 16:51:06
Because MySQL does not have a built in relational division operator, programmers must implement their own. There are two leading examples of implementations which can be found in this answer here. For posterity I'll list them below: Using GROUP BY/HAVING SELECT t.documentid FROM TABLE t WHERE t.termid IN (1,2,3) GROUP BY t.documentid HAVING COUNT(DISINCT t.termid) = 3 The caveat is that you have to use HAVING COUNT(DISTINCT because duplicates of termid being 2 for the same documentid would be a false positive. And the COUNT has to equal the number of termid values in the IN clause. Using JOINs