database-design

Best way to design this database scenerio?

Requirement is to store attachments for different entity types. Say we have 3 entity types Company , Department and Employee. Each can have multiple attachments (documents). Which is the best way to handle this? Solution 1: Company table CompanyId Dept table DeptId Employee table EmployeeId AttchmentType table TypeId Ty...

Design of an 'EAV' or 'Class/Concrete Table Inheritance' database for stock control

I am developing a stock control system for a construction project. The storeman is responsible for adding new stock and distributing/returning it to/from employees. The items (and hence their attributes) will be very varied; e.g. steelwork, clothing, plant/machinery, tools, etc. My question is whether to go for a Class/Concrete Table ...

Designing SQL database to represent OO class hierarchy

I'm in the process of converting a class hierarchy to be stored in an SQL database. Original pseudo code: abstract class Note { int id; string message; }; class TimeNote : public Note { time_t time; }; class TimeRangeNote : public Note { time_t begin; time_t end; }; class EventNote : public Note { int event_id; }; ...

Is Core Data more suitable than SQLite for server client database design?

I'm having a server client database design which I'm unsure is Core Data suitable? I have a server database which will maintain the master copy of the data and their relationship. Each client application will have an empty client database with only relationship. Upon the start up of the client, it will request for data from the server...

how to form a tree structure from DB2 Table(s)?

Please refer to this question database-structure-for-tree-data-structure Is this possible in DB2 Database? I know it is possible in Oracle using START WITH and CONNECT BY, i don't have any idea in DB2, Is it possible to achieve this in DB2? Thanks! ...

Design a set of attributes

Hello everyone! My boss gave me a bunch of requirements that I'm not pretty sure about how to design them in the DBMS. Basically the user has to describe an object defining its attributes in an old fashion way: "key"=>"value". The problem is that the user has "free will" on choosing both keys and values so he can wrote whatever he wants ...

What is a lookup table?

I just gave a database diagram for a DB I created to our head database person and she put a bunch of notes on it suggesting that I rename certain tables so it is clear they are lookup tables (add "lu" to the beginning of the table name). My problem is that these don't fit the definition of what I consider a look up table to be. I have ...

Looking for a good method of extending external data with an internal database table

I have an application that receives most of its data from a third party. One of these sets of data is a transaction list. I can't write to this service, but I want to add more information to that data for use in my own application. I intend to do that with a SQL table with extended info. The problem is that the third-party data does ...

Using Entity Framework as a database design tool?

One thing I like about the Entity Framework v4 is the fact you can design with a "model-first" approach. I'm also a big fan of the Visual Studio Database project for version controlling changes to the database schema. Traditionally I've been using SSMS tool to generate the schema, and then importing that into the database project. In o...

Rails - Multiple Index Key Association

There seem to be a number of ways to handle a multiple foreign key association. Each way I have approached this has their draw backs, and as I am new to Rails I am convinced others have come across a similar scenario and I am probably working on something solved long ago. My question is: What would be an efficient way of handling a mu...

Database design to support multiple clients

If you were building a database with tables Documents, Clients, Users and Firms, where in Firms you would store the companies that use the software how would you design the first three tables to support multiple Firms to store in them? So, in Documents we want to store documents for all the firms, of course, we need to tell them appart s...

What exactly is the problem with hierarchal and network models of databases?

Before E F Codd published his paper "A Relational Model of Data for Large Shared Data Banks" in 1970, hierarchal and network were the two prominent models of the database. What exactly was wrong with them that they did not prevail? ...

MySql:: if field is primary key + auto increment should he also defined as unsigned or mysql doing that by default?

Hi, MySql:: if field is primary key + auto increment should he also defined as unsigned or mysql doing that by default? Edit: I asking because integer unsigned save 2* space vs integer. I asking about INNODB. Thanks ...

MySql table structure

At the moment, I have a table in mysql that records transactions. These transactions may be updated by users - sometimes never, sometimes often. However, I need to track changes to every field in this table. So, what I have at the moment is a TINYINT(1) field in the table called 'is_deleted', and when a transaction is 'updated' by the us...

many to many relationship, bit wise comparison versus linker table

A database table, lets say burger, contains a field that stores bits as an integer value, so it has value of either 1,2,4,8,16 ... A secondary table contains the values 1 = cheese, 2 = tomato, 4=egg, 8 = lettuce, 16 = mayo Bit wise comparison then enables any burger to have any combination of fillings (for the uninitiated a burger with...

What is the fastest way to convert all PK and FK GUID Columns and relationships to int?

I'm currently developing an ASP.NET MVC application with a ton of PK-FK relationships in the database. In the beginning of development, the team I WAS working with voted against my recommendation to use INTs for all PKs... they decided to use GUIDs. Long story long... the team has split ways, and now I have control to change things... ...

MySQL: Complex data structuring and querying

I'm having a bit of trouble figuring out what would be the best approach for creating the database tables for the following (rather complex) data structure and I'm hoping that someone with more experience than me could help out. The main reason for my trouble is both normalization and trying at all costs to avoid querying inside loops. ...

A huge data storage problem

Hey guys! I'm starting to design a new application that will be used by about 50000 devices. Each device generates about 1440 registries a day, this means that will be stored over 72 million of registries per day. This registries keep coming every minute, and I must be able to query this data by a Java application (J2EE). So it need to ...

Database design problem - keeping relationships at a minimum

I have a database design that's normalized well enough, but now I need to add a new table (entity, since I'm actually using Core Data) and I'm running into some issues. Landscape has many Assessment Assessment has one AssessmentType AssessmentTree has one Assessment AssessmentTree has one each of 12 other entities, omitted for space. ...

Normalized Database Question

I should know this but I expect it to be a simple answer... This is my simple database so far for this question: Am I supposed to insert the Id from Contact and Phone into Contact_Phone when I insert a record into Contact and Phone tables - or can this be done automatically? I am using SQL Server 2008 Express. ...