database-design

DB design for importing data from multiple providers?

Hi, I have to build a news database that will potentially take news from many different providers and display them on our site. Right now I am thinking that I should just come up with how it will look on our site, the fields we would display, and then when a new provider comes along, right a script that will parse their data into our fo...

Automating table normalization

I have a table with this structure (simplified): artID: 1 artName: TNT ArtBrand: ACME ... And I want to normalize it making a separate table for the brand (it will have additional data about every brand) So I want to end up with this article table: artID: 1 artName: TNT brandID: 1 ... brand table brandID: 1 brandName: ACME brandI...

Proper term for ie: creating an order_status lookup table with attributes to avoid coding against specific status values?

Is there a proper term in data modeling to describe the following? Given table [order] table with an [order_status] column, which when first conceived has 5 acceptable values, obviously having 5 different meanings and at least > 1 behavior (but not necessarily 5 different behaviors) from an application perspective. One would typically ...

Extensible Database Schema

We are revamping our product which gets highly customized for each client. Currently we have to maintain separate database for each client which heavily affects persistence layer. Our major goal for new database schema is extensibility. I am not an expert database designer thus require input from experts :). I am thinking about extensi...

Creating a feed wall

I have a table of users and a table of questions. The questions table will have records that represent "Questions", "Answers" and "Comments" to questions or answers. I'd like to create a dashboard for each user in which its possible to see activities related to questions and answers. For example if user A creates a question and user B re...

Should a database table that contains two columns that are foreign keys have a third column which is the primary key?

I am guessing no, since the foreign keys are the primary keys in their own tables, so they will be unique. More info I am using MySQL and the following three tables are using the InnoDB engine. ======================= ======================= | galleries | | images | |---------------------| |------------...

Can you review my simple SQL database and perhaps provide some feedback on things I may have overlooked? (7 Tables)

Here is the SQL script: create table Employee( Carnet nvarchar(15) primary key, Name nvarchar(500), LastName nvarchar(500) ) create table Document( ID nvarchar(20) primary key, Employee nvarchar(15) foreign key references Employee(Carnet), Project nvarchar(20) foreign key references Project(ID) ) create table DocumentsArea( DocumentID...

Superkey vs. Candidate key

What difference between Super and Candidate key in ERDB? Thanks. ...

How to compare values within the same table in TSQL elegantly

I've got a settings table constructed with 'category' determining different products, 'varname' being the variable name, and 'info' being the value of the setting. so, for instance, select top 6 category, varname, info from settings_table where NODE_NAME='HTT-COMM-A' and section='Module Settings' and category in ('ProductA',...

Designing an append-only data access layer with LINQ to SQL

I have an application in mind which dicates database tables be append-only; that is, I can only insert data into the database but never update or delete it. I would like to use LINQ to SQL to build this. Since tables are append-only but I still need to be able to "delete" data, my thought is that each table Foo needs to have a correspo...

Customer and Business database relationships

I am trying to create a database design and need some help. Diagram is displayed below. The database is for an address book attached to a e commerce site. Its coded in php and uses a mysql database. See my diagram below - I think I have solved my problem but I want to know is this a good way to do it? This is what I would like to do: ...

Best way to store and handle usage 'profiling' information?

I'm sure there's an easy answer here and i'm just over-complicating things, but i am in the process of writing a Django module responsible for storing and tracking user usage statistics which can then be displayed to users on certain pages. Simplest example of this might be tracking which products a user has purchased and looked at so t...

Which is quicker when indexed. INT (10) or Timestamp in MySQL

I was just wondering which field type would be the best solution for storing a timestamp in a MySQL database. Currently I store timestamps in an INT (10) field and insert the time by doing UNIX_TIMESTAMP(). If I was to use a timestamp field would it be slower or quicker when indexed? I know both fields use 4 bytes. ...

Session table fields for Social networking website

Looking into requirements for the User Session table for a social site. Currently I am designing it to store: • UserID - links to user's who owns the session • Session ID - unique to the user • Session start – Time, Day, Date, Time zone • Session end – Time, Day, Date, Time zone • Session length • MAC address • Computer name • IP addr...

Implementing order in a PHP/MySQL CMS & dealing with concurrency.

I have the following tables: ======================= ======================= | galleries | | images | |---------------------| |---------------------| | PK | gallery_id |<--\ | PK | image_id | | | name | \ | | title | | | description ...

Auto increment over multiple identity columns in MS SQL 2005 or 2008

Hi, I want to have two different tables in MS SQL, for example users and groups, both with identity column. It is possible to create auto increment over two identity columns? I want to have third table with common informations to these two tables and I want to identify unique record. In Oracle is SEQUENCE. It is possible to do it? Tha...

How to handle "Type" field in DB and app?

It is necessary to implement a logging, messages are planned to store in DB in a "log" table. Among other fields each message will have a "status" field: 0 - successful, 1 - wrong data, 2 - wrong user, 3 - whatever, 4 - etc... The straightforward idea is to store the "Status" field as "int" column in the same table... To push data in ta...

Django Model/Database design for subclasses

Hi. Ok, i'm shit at describing. Here's a relationship diag. In Django i've made my models like: from django.db import models from datetime import datetime class Survey(models.Model): name = models.CharField(max_length=100) pub_date = models.DateTimeField('date published',default=datetime.now) def __unicode__(self): ...

What is Facebook's database schema for messages like?

How does Facebook structure their data for messages. I have heard they use Cassandra for inbox search, but is this the only technology they use? ...

Using NULLs in matchup table

I am working on the accounting portion of a reservation system (think limo company). In the system there are multiple objects that can either be paid or submit a payment. I am tracking all of these "transactions" in three tables called: tx, tx_cc, and tx_ch. tx generates a new tx_id (for transaction ID) and keeps the information about ...