database-design

Proper Table naming convention for a many-to-many intersect table.

I have a many to many relation for: Client and Broker tables (just an example). Obviously, each client can have multiple brokers and each broker can have multiple clients. What is considered the proper naming convention for the intersect table.... is it ClientBroker...? ...

Help with designing models for a Django 'Project' app with 1 or more urls in it (variable), with editing at once in admin interface

Hello, i'm building a simple app for Django and I'm facing some problems with my models design, and the use of 'inlines' in the administration interface. The app is to manage projects. A project consists of a name, a description, other fields (e.g. tags...) and of multiple urls (like project url, source code repository url) but the num...

Is this how a modern news site would handle it's sql/business logic?

Basically, the below image represents the components on the homepage of a site I'm working on, which will have news components all over the place. The sql snippets envision how I think they should work, I would really appreciate some business logic advice from people who've worked with news sites before though. Here's how I envision it: ...

Many-to-many database design question

Say you have the following many-to-many table relation: user ----- id first_name last_name user_prefs ---------------- id preference_name user2user_prefs ------------- id user_id user_pref_id But say you have the user preference of "homepage" and need somewhere to store the actual homepage url. Where would that go? I can't put a va...

How to create a multi-tenant database with shared table structures?

Our software currently runs on MySQL. The data of all tenants is stored in the same schema. Since we are using Ruby on Rails we can easily determine which data belongs to which tenant. However there are some companies of course who fear that their data might be compromised, so we are evaluating other solutions. So far I have seen three ...

Project management web app: relational or document oriented DB?

There're quite a few posts discussing relations vs document databases, however they are all quite generic. I'd like to understand their differences in a specific example. Let's imagine we're building another scrum-oriented project management web app. While we'd like to experiment with a new technology, we don't want to sacrifice desig...

What do I need to know about databases?

In general, I think I do alright when it comes to coding in programming languages, but I think I'm missing something huge when it comes to databases. I see job ads requesting knowledge of MySQL, MSSQL, Oracle, etc. but I'm at a loss to determine what the differences would be. You see, like so many new programmers, I tend to treat my da...

Delivering activity feed items in a moderately scalable way

The application I'm working on has an activity feed where each user can see their friends' activity (much like Facebook). I'm looking for a moderately scalable way to show a given users' activity stream on the fly. I say 'moderately' because I'm looking to do this with just a database (Postgresql) and maybe memcached. For instance, I wan...

How far can I take this database design?

I am interested in knowing the pros and cons of creating a custom system supported by a database like the one described below: It has 6 tables that support it. Entity: Lets say, anything "physical" that can exist and have detail stored against it (Hilton Hotel, Tony Taxi, One Bar) Entity Type: A grouping/type of entity (Bar, Hotel, Re...

What is the convention for designating the primary relationship in a one-to-many relation between tables?

I understand how to design a database schema that has simple one-to-many relationships between its tables. I would like to know what the convention or best practice is for designating one particular relationship in that set as the primary one. For instance, one Person has many CreditCards. I know how to model that. How would I designate ...

Newb SQL question: Is there a "foreign key" equivalent for referencing columns, or is it logical to store column names as strings in another table?

Disclaimer: I'm an SQL newb, just discovering the great possibilities of sqlite embedded in applications. I'm designing a small database for an application that primarily handles data storage for plotting. Say I have several instrument data tables (one for each type of instrument) with a column for each data field, such as pressure, ...

MySql DB Design question

Assuming I have an application where I expect no more than 50,000 users. I have 7 tables in my DB schema. Is it a good idea to replicate all the tables for every user? So, in my case, number of tables will roughly be 50,000 * 7 = 350,000. Is it in anyway better than 7 monolithic tables? ...

Trying to design a column that should sum values from another table

Hi everyone, sorry if the title is not very clear. I will try to explain now: I have two tables: table A and table B. The relation between them is one (for A table) to many (for B table). So, it's something like master-detail situation. I have a column 'Amount' in table B that is obviously decimal and a column 'TotalAmount' in table A....

Best approach to relating databases or tables?

What I have: A MySQL database running on Ubuntu that maintains a large table of articles (similar to wordpress). Need to relate a given article to another set of data. This set of data will be fairly large. There maybe various sets of data that will be related. The query: Is it better to contain these various large sets of data w...

Database EAV Pros/Cons and Alternatives

I have been looking for a database solution to allow user defined fields and values (allowing an unlimited number). At first glance, EAV seemed like the right fit, but after some reading I am not sure anymore. What are the pros and cons of EAV? Is there an alternative database method to allow user defined attributes/fields and values?...

How to set up a new SQL Server database to allow for possible replication in the future?

I'm building a system which has the potential to require support for 500+ concurrent users, each making dozens of queries (selects, inserts AND updates) each minute. Based on these requirements and tables with many millions of rows I suspect that there will be the need to use database replication in the future to reduce some of the quer...

Which is a better method for storing images - folder or SQL Server as binary?

Hello, I am planning the development of a photo gallery application for a client. I am developing the app in asp.net 3.5 and would like to develop it so that I can re-use the application across multiple platforms using various front-ends. Basically, I am wondering what are the dis-advantages and advantages of storing images in the datab...

Need to change my SQL structure for deletion

Ok. I've tried the trigger, but it didn't work. I have Cascades from A to Linker and from B to Linker, Cascade from Users to A, No Action from Users to B. My trigger is on Users and is as follows: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER TRIGGER [trig_delUser] ON [dbo].[aspnet_Users] FOR DELETE AS SET NOCOUNT ON; D...

Database design to store notifications to users

I'm working on a literature community website. (screenshot) And I'm trying to figure out how to notify users when someone comments on something they posted to the site, when someone they are watching submissions a new literature peice, etc. I'm trying to figure out how to structure the database to store this information. I've come up w...

The best way to manage database changes

What is the best way to manage database changes? I need to have a solutions regardless the database client's language. Also I'd like to be able to use specific database features in those changes such as stored procedures, triggers and so on. ...