database-design

Data access layer design pattern

hi, I need to build a data access layer and I am looking for the right design pattern. what I need is: object mapping: it shouldn't be too complicated and not generic. i have a lot of lookup tables and i need to a good way to load them. I don't care about starting time (when the program starts up), what I care is to minimizing the n...

Are 'Primary Keys' obligatory in SQL Server Design?

Observe the following table model: CREATE TABLE [site].[Permissions] ( [ID] INT REFERENCES [site].[Accounts]( [ID] ) NOT NULL, [Type] SMALLINT NOT NULL, [Value] INT NULL ); The site.Accounts->site.Permissions is a one-to-many relationship so 'ID' cannot be made a primary key due to the uniqueness that a PK imposes....

Best way to store tags in a database?

I have a database that contains two tables: entries tags The entries table contains posts that each have one or more tags. The problem is, each post can have any number of tags. In other words, I can't have a 'tag1', 'tag2', etc. column and do a LEFT JOIN. How should I set up entries so that each post can have any number of tags? ...

Normalizing a database with "chained" entries

I'm new to database design, and I haven't found a definitive way to structure my vocabulary database. Irrelevant fields aside, the data I want to store is conceptually something like this: Word 1 Meaning 1 (1-n of these) Example 1 (0-n of these) Example 2 ... Meaning 2 ... Word 2 ... Now, a Word is identified by three attributes:...

Should referential integrity be enforced?

One of the reasons why referential integrity should not be enforced is performance. Because Db has to validate all updates against relationships, it just makes things slower but what are the other pros and cons of enforcing and not enforcing? Because relationships are maintained in the business logic layer anyway, it just makes them red...

how to represent symmetric many to many relationship

suppose i have a entity called USER and a relationship FRIENDSHIP exist between two USERs SO for that i have a table 'USER' and a relationship table 'FRIENDSHIP' USER id firstName LastName 1 taher chhabrawala 2 john Dsouza 3 rahul singh 4 deepak patel Friendship id id 1 2 1 3 1 4 4 ...

What's the best programming design for localizing an application?

i.e. Multi-language messages, screen captions, currency/date formats, etc. ...

Parent-child relationship: multiple tables vs. self-join

I'm working on a database for stat keeping for a sports club where I help administrate some events. I think I've got the parts for keeping track of the competitor names, classifications, categories, etc. figured out using a main table, several lookup tables and a couple bridge tables to cover the many-to-many relationships involved. I ...

Database Design and how Foreign keys work?

If two tables have foreign keys to the same primary key of another table, does that mean that two indexes are created for those foreign keys or do they use the same index (the primary key index?) ...

SQL to retrieve tree structure nicely

Given the simple data structure: ID | Category_Name | Parent_ID Example: 1 Cars 0 2 Boxes 0 3 Lamborghinis 1 4 VW Camper Vans 1 5 Big Boxes 2 6 Small Boxes 2 7 Cereal Boxes ...

Can ORM skinned over bad database design reduce its effect to application?

I'm working in mid-size .NET application which has a very very bad if not worst database design, almost of tables don't do normalization and complex table design. E.g. I have one table to keep track of stock movement and every times I modify this table I need to update current stock table. In my opinion this is a bad design, because I c...

MySql table design : Use lots of rows or store the information formatted in one text field per row?

I am trying to discover the best way to design my database to organize information related to events. I have an events table which contains all the information about the event such as, a unique id, title of the event, venue etc. Now each event can have multiple ticket types and the number and type of tickets will change with each event...

Database Value And Unit as Two Separate Columns?

I want to store a computer's processor speed in a database. Should I use one column as a varchar and store the number and unit together e.g. "1.3 ghz" or should I create two separate columns, one as a decimal for "1.3" and a second column for the units as a varchar "ghz"? ...

Existing Database for Nutrition Facts?

I'm developing an ecommerce store using MVC and it will feature various health food products. We would like to display the Nutrition Facts label for each product, and am wondering if there is an existing way to do this dynamically without images and if there is a database out there with all the facts we can pull from, to minimize data en...

Can i use Natural joins in place of primary key and foreign key?

If i use Natural joins than what is the use of primary key and foreign key? ...

Disadvantages of consolidating databases?

In an organization that has two applications each with its own Oracle database instance, what are the disadvantages of consolidating the two databases into one database with two schemas? Backups and replicating the database are bigger and slower, probably. What else? Some background: The two databases are the "gold source" for their ...

How can I map a different parent class in different projects to the same shared child class?

Summary: I have two projects using the same database relation. I would like to map the relation differently in each project, using the same child class but different parent classes. Detail: I have two projects, ADMIN and SERVICE. ADMIN allows the persisted object Promo to be configured. SERVICE will read Promo. We're using Spring...

Joining columns to rows.

Here's a scenario with a product we purchased. THe product allows us to create custom fields, but these fields are stored as ROWS in a CUSTOM table. I want to write a query that will connect to more than one custom field and fetch a single row. Let me give you an example. 1) PERSON TABLE (ID int, NAME varchar2(30)); 2) CUSTOMFIELDS TA...

Structure of the DB

I am trying to structure a database for optimal use. But I have no idea how to make that happen. Here is what i will have A category which will have many products and a count for each on of those products For example Restaurants will be the category and the products will be the computer system, cash register and each one of these pro...

How do I use a standard active record for some models when i am using the datafabric gem?

I am using the data-fabric gem, sharding between 2 machines. However, I would like to use the standard activerecord functions for some tables. Anyone has a similar experience achieving this? ...