relational-database

Should User and Address be in separate tables?

痴心易碎 提交于 2019-12-22 04:19:05
问题 Currently my users table has the below fields Username Password Name Surname City Address Country Region TelNo MobNo Email MembershipExpiry NoOfMembers DOB Gender Blocked UserAttempts BlockTime Disabled I'm not sure if I should put the address fields in another table. I have heard that I will be breaking 3NF if I don't although I can't understand why. Can someone please explain? 回答1: There are several points that are definitely not 3NF; and some questionable ones in addition: Could there

Are all modern RDBMS row oriented? Why? [closed]

末鹿安然 提交于 2019-12-22 04:18:23
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 9 years ago . If one of relational databases paradigms is to be tuple oriented we have the biggest limitation here. If one could design column oriented db, that would improve performance a lot. Vector operations would perform

SELECT COUNT across one-to-many relationship

霸气de小男生 提交于 2019-12-22 04:17:13
问题 For two tables player and team With a 1-∞ relationship (player to team): how would you count how many players belong to each team? Failed attempt: SELECT team.teamid, (SELECT COUNT(player.team) FROM player) FROM team LEFT JOIN player ON player.team = team.teamid 回答1: Try SELECT t.teamid, COUNT(p.team) player_count FROM team t LEFT JOIN player p ON p.team = t.teamid GROUP BY t.teamid SQLFiddle It will give correct result event if some teams don't have players assigned. See sqlfiddle for that

BCNF Decomposition

纵饮孤独 提交于 2019-12-22 03:51:00
问题 I am trying to figure out the correct steps in performing a BCNF decomposition. I found this example, but I do not understand how to perform the correct steps. Schema = (A,B,C,D,E,F,G,H) FD's + {A -> CGH, AD->C, DE->F, G->G} Could someone show the correct steps? 回答1: Determine a minimal cover using your FD's: {A -> C, A -> G, A -> H, B -> nothing, C -> nothing, D -> nothing, E -> nothing, F -> nothing G -> nothing H -> nothing DE -> F} Note AD -> C drops out because A alone determines C which

Mysql join query on three tables with multiple columns

依然范特西╮ 提交于 2019-12-22 03:43:26
问题 I have three tables like this: Specialisation sid | s_name -------------- 1 | test 1 2 | test 2 Person pid | name | sid ------------------ 1 | ABC | 1 2 | XYZ | 2 Timing tid | time_from | time_to | pid ---------------------------------- 1 | 08:00:00 | 10:00:00 | 1 2 | 20:00:00 | 22:00:00 | 1 3 | 09:00:00 | 14:00:00 | 2 4 | 19:00:00 | 20:00:00 | 2 **I want to get result something like this* pid | name | s_name | time_from | time_to -------------------------------------------- 1 | ABC | test 1

Converting large XML file to relational database

半城伤御伤魂 提交于 2019-12-22 03:41:15
问题 I'm trying to figure out the best way to accomplish the following: Download a large XML (1GB) file on daily basis from a third-party website Convert that XML file to relational database on my server Add functionality to search the database For the first part, is this something that would need to be done manually, or could it be accomplished with a cron? Most of the questions and answers related to XML and relational databases refer to Python or PHP. Could this be done with javascript/nodejs

How to properly design this part of a database (circular reference?)

两盒软妹~` 提交于 2019-12-22 00:06:48
问题 Situation: A company has many projects A project has many tags A project belongs to only 1 company A tag can belong to multiple projects A company must have access to its own tags Example 1: In the first image, all tags for the company are available through the projects/project_tag. But if all projects are removed, then the tags for the company will not be accessible anymore, because the link between project_tag and projects is gone. The tags should be somehow always be linked to the company,

How to properly relate items to pricing data, taking price change history into account

久未见 提交于 2019-12-21 17:49:04
问题 Virtually all POS systems record the price of an item directly to the transactions table at the time of the sale since that price may change at a later date, but the price it sold at should remain the same. I'm wondering how you would setup pricing table(s) that keep a history of price changes, so that you can relate the transactions to that table based on the item and the time it was sold in order to get the correct price? I think anyone who's ever worked with POS systems will understand

Rails has_many through for has_many with multiple models

核能气质少年 提交于 2019-12-21 05:51:22
问题 What would be the best way to model the following situation: Word belongs_to :wordable, :polymorphic => true Phrase has_many :words, :as => :workable belongs_to :story Line has_many :words, :as => :wordable belongs_to :story Story has_many :lines has_many :phrases has_many :words, :through => :phrases has_many :words, :through => :lines I want to be able to do @story.words to get list of all words that are linked to a story either via lines or via phrases... Is that possible? 回答1: Try this:

What database do online games like Farmville use? [closed]

徘徊边缘 提交于 2019-12-21 05:24:11
问题 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 7 years ago . Apart from graphical features, online games should have a simple Relational Database structure. I am curious what database do online