database-design

Database for web app with multiple clients

一世执手 提交于 2019-12-22 11:26:13
问题 In a real-world web app, how does one go about storing data for multiple clients/companies/customers? Lets assume we have the following collections for one client: - users - tasks How would I extent this system to a second client? Is there a standard approach? Note: I am using Firestore (no-sql). 回答1: We use a separate set of collections for each client. Our data structure works really well for us and looks like this... /clients/{clientId}/reportingData /clients/{clientId}/billingData

One lookup table or many lookup tables?

◇◆丶佛笑我妖孽 提交于 2019-12-22 11:05:16
问题 I need to save basic member's data with additional attributes such as gender, education, profession, marital_status, height, residency_status etc. I have around 15-18 lookup tables all having (id, name, value), all attributes have string values. Shall I create member's table tbl_members and separate 15-18 lookup tables for each of the above attributes: tbl_members : mem_Id mem_email mem_password Gender_Id education_Id profession_id marital_status_Id height_Id residency_status_Id or shall I

How BIG do you make your Nvarchar()

核能气质少年 提交于 2019-12-22 10:53:59
问题 When designing a database, what decisions do you consider when deciding how big your nvarchar should be. If i was to make an address table my gut reaction would be for address line 1 to be nvarchar(255) like an old access database. I have found using this has got me in bother with the old 'The string would be truncated'. I know that this can be prevented by limiting the input box but if a user really has a address line one that is over 255 this should be allowed. How big should I make my

Database in android studio [closed]

放肆的年华 提交于 2019-12-22 10:46:55
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I'm a windows phone developer and newly I started developing android apps using android studio. I need to create a database and store in it values and retrieve the updated values on screen, so I need help in: Creating the database. How to show values from the database on screen?

Database design: circular references

懵懂的女人 提交于 2019-12-22 09:59:54
问题 I have three database tables: users emails invitations Emails are linked to users by a user_id field. Invitations are also linked to users by a user_id field Emails can be created without an invitation, but every invitation must have an email. I would like to link the emails and invitations tables so it is possible to find the email for a particular invitation. However this creates a circular reference, both an invitation and an email record hold the id for the same user. Is this bad design

Database Design: how to support multi-lingual site?

假如想象 提交于 2019-12-22 09:35:56
问题 Suppose I have the table: TABLE: product ================================================================= | product_id | name | description | ================================================================= | 1 | Widget 1 | Really nice widget. Buy it now! | ----------------------------------------------------------------- If I want to provide multi-lingual support, what's the best approach to do that? Possible solutions: Add a "language" column to the above table; that'll indicate the

Multiple Foreign keys to a single table and single key pointing to more than one table

梦想与她 提交于 2019-12-22 09:25:33
问题 I need some suggestions from the database design experts here. I have around six foreign keys into a single table (defect) which all point to primary key in user table. It is like: defect (.....,assigned_to,created_by,updated_by,closed_by...) If I want to get information about the defect I can make six joins. Do we have any better way to do it? Another one is I have a states table which can store one of the user-defined set of values. I have defect table and task table and I want both of

How to design a database with a table that needs to reference itself?

孤街浪徒 提交于 2019-12-22 08:51:03
问题 I'm building a database and have run into a problem that I can't seem to wrap my mind around. The database is much more complex than what is pictured, but the problem can be distilled into the table structure below. The issue is that every employee has a manager and every manager is an employee. It would seem that these tables have to reference eachother. However, this doesn't seem to work correctly when I set this up. I'm using cakephp. What is the name of this relationship type? Is this the

How to create a Postgres table with unique combined primary key?

只愿长相守 提交于 2019-12-22 08:32:51
问题 I have two tables named players & matches in a Postgres DB as follows: CREATE TABLE players ( name text NOT NULL, id serial PRIMARY KEY ); CREATE TABLE matches ( winner int REFERENCES players (id), loser int REFERENCES players (id), -- to prevent rematch btw players CONSTRAINT unique_matches PRIMARY KEY (winner, loser) ); How can I ensure that only a unique combination of either (winner, loser) or (loser, winner) is used for matches primary key so that the matches table won't allow the

Database Design :: Normalization in 2 Participant Event :: Join Table or 2 Column?

冷暖自知 提交于 2019-12-22 08:23:13
问题 Edit : updating generalized question to reflect actual domain: sport of hockey. The actual event then is a games schedule, and the participants are teams. Teams are the ultimate "owners" (i.e. when team deleted so should any related scheduled games, results, players, and player stats). The problem discussed so far in this thread covers the decision to combine an event into a single row with 2 columns (team1, team2) or to break out into a join table. The consensus so far is: stay with 2 column