database-design

Best way to track challenges/goals completed by a member?

This is to be an application-agnostic question, but one I'd like to get a better answer on. What is the best set-up to track users completing a challenge or goal? Think similar to Stack Overflow, where if you hit a certain target you're awarded a badge. Currently, I'm the developer of a website and attached Facebook application. I want...

need some advice on my database design

Hi all, I am using cakePHP 1.26. I am going to build a very simple forum on localhost. Here is the conceptual design for the Database: Tables: User {user_id, name, date} Topic {post_id, title, content, date} Reply {post_id, content, date} Quote {quote_post_id, post_type, post_id} A User may have many Topic A User may have many Reply A...

Storing/serializing list of objects

I oftem run into this case of what is the correct way to store a list of objects as a property in a class and how to properly serialize them into XML. For instance, we have a TabGroup class which will contain zero or multiple Tabs. Is it better to a have a list of Tabs property or a list of references to Tabs? Provided that Tabs are id...

DB Design: best practices to hierarchical structure.

I'll try to expose as clear as possible ;) Well, i need to store some data that can be linket to themselves as the parent > child relationship, with no-limit deep. My first try was: entry_id | parent_id | value 1 | NULL | Foo //foo is the grand parent 2 | 1 | Bar //bar is child of Foo 3 | 1 ...

Best Practices for MySQL Encryption?

I'm looking for guidance on encrypting fields (and/or tables if possible) for MySQL. I will settle for a decent tutorial but I'd really like specific tips on managing the transition from an unencrypted schema to one utilizing encrypted fields. Thanks! ...

Design Database Architecture: DB for use with a couple different languages

I have a web site that should have translation of the same content on different languages. So it should have the databases entries with different translations of same strings. It is not just a small website, so there is a lot of different complicated data structures. I have one idea how to realize this. But I don't really like it. I t...

Creating a flattened table/view of a hierarchically-defined set of data

I have a table containing hierarchical data. There are currently ~8 levels in this hierarchy. I really like the way the data is structured, but performance is dismal when I need to know if a record at level 8 is a child of a record at level 1. I have PL/SQL stored functions which do these lookups for me, each having a select * from tb...

architecthure for a large data driven website

I know how to create small data driven websites but want to get an idea on how to convert them to handle large data flow. The questions are based on a site that would act mostly like stack overflow, craigslist etc where people could post stuff and others reply and would have basic search capabilities based on tags. Are regular relatio...

Computing column access statistics in MySQL and / or Oracle

We're currently questioning our company's data model (database schemes), which has grown wildly and distributedly over the years and now suffers from redundancy and lacks clarity. Different databanks (Oracle and MySQL) are queried by different tools, developed by separate teams for different purposes (billing, reporting, business, etc). ...

Are there any advantages to use varchar over decimal for Price and Value

I was arguing with my friend against his suggestion to store price, value and other similar informations in varchar. My point of view are on the basis of Calculations will become difficult as we need to cast back and forth. Integrity of the data will be lost. Poor performance of Indexes Sorting and aggregate functions will also need c...

How do I handle multiple types of users?

In my application users can be one of three types: teens, individuals, or members of an organization. In my users table, I have a boolean field teen (not null) and a foreign key organization_id (null). If teen is true and organization_id is null, the user is a teen. Teens can't belong to an organization. If teen is false and organizat...

Multi-company web application database security

My question is very similar to this question but a bit more specific. My application has multiple companies and multiple users per company. It makes the most sense to me (at this point) for each company to have a "private" set of tables. This makes security extremely simple as I don't have to worry about JOIN-ing up my structure tree to...

How to build a scalable statistical system?

Let's say I have a table named products and I want to know how many times the products were searched, viewed and purchased. I want also to know when the products were searched, viewed and purchased. My first approach was to make a table with the product_id, a field indicating if the item was 0=searched, 1=viewed and 2=purchased and anot...

Storing different parameter types in a single table

I have a Java class representing an event that contains some data, and also a list of 'parameters' of varying types, for lack of a better word. I want to persist this into a database, and I'm confused as to the best approach. edited to try to clarify my ramblings: Depending on the type of 'event', it could have parameters like hostnam...

Why do DAOs have separate create and update methods?

I'm looking at a couple of designs for DAO interfaces. One has a single update() method, while the other has separate create() and update() methods. Assuming that it's possible to do something along the lines of 'insert otherwise update', what's the benefit of a separate create() method? Is there something to do with concurrency lurking...

Decoupling using stored procedures at what cost?

I was taught to decouple code implementation from database implementation through the use of stored procedures. I'm wondering how much true benefit there is sometimes. I know it differs from case to case, so, for instance: Decoupled DAO Methods (C#) User FindByName(string value); User FindByLogin(string value); User FindByEmail(strin...

How strict should I be with creating a separate association table?

Let's say I have a table that has a report_type column and I have only 2 report types. Is it worth it to create a report_types table with them, and then reference it with a foreign key to this table? Or is it acceptable to store the report type as a string in that column? ...

Are PostgreSQL VIEWS created newly each time they are queried against?

I am creating a web app which has some complex underlying associations. In order to solve several issues I was having I created a UNION View. There are probably a lot of other ways this could be solved. But I am now considering the efficiency of my design, and I wanted to know if a VIEW is newly created each time it is queried, or is it...

Basic Database design question - 1 attribute three Entities

Hello. Please can someone clarify something which I should really know by now? If I have Three Entitys Organisation, Director and Company secretary and each have the attribute primary address. If I were modelling a conceptual ERD should I have the attribute ‘primary address’ separately in each entity or should I model a fourth enti...

Single Bridge Table or is there a better way?

I've been trying to find an answer for this and I don't know the best way to describe it. Basically, I have 3 source tables each with uniqueidentifier keys. We'll call these tables Skill1, Duty2, Custom3. They are not linked (easily) in any way with each other other than the fact that they are attributes of a particular job. I want t...