database-design

Drawback of large LIMIT of VAR-types

Is there any drawback (except allowing the value or array to grow too large) to setting the max integer size of a VARCHAR or VARRAY to a value significantly larger than actually necessary (or setting it to the max size allowed)? ...

Single Autonumber Instead of Multiple Key

Is there a reason to use a single incrementing field for a primary key instead of multiple fields that actually represent the unique record? I'm working on an existing php application, and the tables all seem to have a single 'id' key instead of using the 2 or more fields that are actually unique to the record (like user, auction, bid)...

database design with many type of users

I am pretty new to database design. I am building a small asp.net mvc web application in which there are are various type of users who can login to the website. So the table structure is, Users table userid(PK), username , password , email , role, etc Employees table: Eid(PK), userid(FK), firstname, joining date, etc Clients table: ...

User defined data objects - what is the best data storage strategy?

I am building a system that allows front-end users to define their own business objects. Defining a business object involves creating data fields for that business object and then relating it to other business objects in the system - fairly straight forward stuff. My question is, what is the most efficient storage strategy? The requirem...

Sequence database field and query for updating sort order

I would like to enable users of my application to define a number of (say) email addresses. Then I would like to give them the ability to rearrange these addresses, so the primary address is on top, secondary next, etc. Let's suppose I have a UserEmailAddresses table in a database that links a user (UserId) and an email address (Email...

Max length for client ip address

What would you recommend as the maximum size for a database column storing client ip addresses? I have it set to 16 right now, but could I get an ip address that is longer than that with IPv6, etc? ...

Writing your own storage-system: where to start?

Hi, reading about NoSQL (http://nosql.eventbrite.com/), a movement aimed at encouraging the dropping of traditional relational databases in favor of custom, application-suited storage systems. Intrigued by the idea of trying to write a small personal storage system (for the .net framework) as a learning pet project, what are you suggest...

App engine datastore: How to implement Posts and Tags without joins?

I'm building an application in Google App Engine (Java), where users can make posts and I'm thinking in adding tags to these posts, so I will have something like this: in entity Post: public List<Key> tags; in entity Tag: public List<Key> posts; It would be easy to query, for example, all posts with a certain tag, but how could I ...

C#, SQL: Storing arbitrary user data in a database as serialized binary

Would you consider it bad practice to store various user data in a database as serialized binary? Is it a good, bad or really ugly idea? I'm talking about pretty much arbitrary things, like the last splitter distance on a form, the last value in a search text box, prevously selected checkbox indexes, et cetera. Things that should be rem...

Could this circular data reference be designed better?

I have data about colors. Some of those colors consist of a number of colors combined. One of those combinations can theoretically be another combined color. In the case of a combined color, I need to define a few attributes about the "child" colors. I currently have my database defined like so: COLOR !Id +MultiColorGroupId MULTICOL...

handling history/change tracking in the DB and consequences on the BL

hi in the current application im working on the client requested that we will save history of every action that happended in the system and provide the ability to backtrack to the previous state of the information. for example: lets say that my app need to handle a storage-room and each user can add/update/delete/read (all CRUD) the inv...

Importing Contacts from GMail - Design Question

So, I am using Google Contacts API to let users import their contacts from GMail. I want the users to be able to select the contacts they want to import in my app, So currently I - GET a XML feed of all the contacts a user has. Parse it, and for each contact create a record in the imported_contacts table. Display the list to the user,...

Help with designing a schema for a lyrics database

I'd like to work on a project, but it's a little odd. I want to create a site that shows lyrics and their translations, but they are shown simultaneously side-by-side (so this isn't just a normal i18n of the site). I have normalized the tables like this (formatted to show hierarchy). artists artistNames albums albumNames ...

DB Schema Quesion: Maintaining Item Order

Greetings! I have a database containing two tables; List and ListItem. These tables have a one-to-many relationship. But a requirement is to allow the ListItems related to a given List to be sorted. Aside from having a "sort order" field in the ListItem table, what would be a good approach to this? ...

Optimally querying a database of ratings?

I have a table of ratings that stores a user ID, object ID, and a score (+1 or -1). Now, when I want to display a list of objects with their total scores, the number of +1 votes, and the number of -1 votes. How can I do this efficiently without having to do SELECT COUNT(*) FROM rating WHERE (score = +/-1 AND object_id = ..)? That's two ...

Best way to store lots of boolean columns in table.

I'm not sure if this kind of question has been asked before but I searched and could find anything. I am working on a database at the moment that has records that have lots of boolean based values stored with them, so the table structure looks something like this: ===Table=== ID <- int Name <- string Bool1 <- bool Bool2 <- bool Bool3...

DB design : members table separate or all in one table ?

I want to create a table of friends with personal information and log on details. What better to separate the members table to 2 tables , one contain minimal details , second with Other details. or remain in one table ? i have a lot of tables that contain the foreign key of the member. ...

Storing ASP.net membership and openid users in a new user table

In order to store user information from people who login with OpenId I plan on creating a user table. My problem is that this new user table will contain new fields that I want the asp.net membership users to be able to fill in too (profile data). My plan is when a user wants a username and password, they register and the information i...

Persisting large text fields

At the risk of sounding foolish, in a scenario where large data fields need to be persisted (such as with blog posts), is database storage always the best solution? I'm guessing bloating the database is probably not too high a risk, as thats kind of what databases are meant to be good at, right? Also databases can be good for text index...

How do I best store a list of numbers in a relational database?

I want to store a list of numbers (essentially, a set in mathematical terms) in a relational database, specifically SQL Server 2005. Ideally, I'd like it to be a single column on a given table, but I'm willing to hear any sort of solution. The data I need to store is, like I said, a set of numbers. It isn't required to be sequential ...