database-design

Empty data problem - data layer or DAL?

I designing the new App now and giving the following question a lot of thought. I consume a lot of data from the warehouse, and the entities have a lot of dictionary based values (currency, country, tax-whatever data) - dimensions. I cannot be assured though that there won't be nulls. So I am thinking: create an empty value in each of ...

Advice on database design / SQL for retrieving data with chronological order

I am creating a database that will help keep track of which employees have been on a certain training course. I would like to get some guidance on the best way to design the database. Specifically, each employee must attend the training course each year and my database needs to keep a history of all the dates on which they have attend ...

Is it worth it creating "categories" for an SO-type site, or are tags the replacement?

I have a posts table for my reddit-clone site and I'm wondering whether I should make categories per posts or just categorize by tags like SO has it. It seems like tags pretty much are a replacement for categories, but is there something I'm just overlooking? ...

Database: Storing Dates as Numeric Values

I'm considering storing some date values as ints. i.e 201003150900 Excepting the fact that I lose any timezone information, is there anything else I should be concerned about with his solution? Any queries using this column would be simple 'where after or before' type lookups. i.e Where datefield is less than 201103000000 (before March ...

How to design database tables (MySQL) for multiple users ?

i would like to know the best way to design database tables for multiple users, like any website that requires a user log in before they can start posting anything. Should my code create individual tables for every users or something different? ...

Better alternative to autonumber primary keys

I am looking for a better primary key than the autonumber data type, namely for the reason that it's limited to a long integer, when I really just need the field to reflect a number or text string that will never ever repeat, no matter HOW many records are added or deleted from the table. The problem is I am not sure how to implement so...

How do i structure my SQL Database (tables, Schemas, users, stored procedures etc.) to prepare it for an n-tier architecture ?

I think the title is self explanatory. What I'm looking for is material so I can further my knowledge. I've never developed a full application before so building one from scratch is a bit overwhelming for me. And the first bump in the road is the database. Websites, articles, books, elaborate answers, anything will do as long as they ...

Database design for heavy timed data logging

Hi, I have an application where I receive each data 40.000 rows. I have 5 million rows to handle (500 Mb MySQL 5.0 database). Actually, thoses rows are stored in the same table => slow to update, hard to backup, ... Which king of scheme is used in such application to allow long term accessibility to the datas without problems with too...

Correct model for a database with a table for each user.

Kinda stuck here... I have an application with lets say 5000 rows of data per user and was wondering if it was right or wrong to do it this way: On user account creation a new table is created (UserData_[UserID]) or should I just have 1 table for userdata and have everything in there with a column for userid? The reason I am stuck at ...

Views performance in MySQL for denormalization

I am currently writing my truly first PHP Application and i would like to know how to project/design/implement MySQL Views properly; In my particular case User data is spread across several tables (as a consequence of Database Normalization) and i was thinking to use a View to group data into one large table: CREATE VIEW `Users_Merged`...

help with tree-like structure

I've got some financial data to store and manipulate. Let's say I have 2 divisions, with offices in 2 cities, in 2 currencies, and 4 bank accounts. (It's actually more complex than that.) I want to show a list like this: Electronics Chicago Dollars Account 2 -> transactions in acct2 in $ in chicago/electronics ...

Is there a way to effect user defined data types in MySQL?

I have a database which stores (among other things), the following pieces of information: Hardware IDs BIGINTs Storage Capacities BIGINTs Hardware Names VARCHARs World Wide Port Names VARCHARs I'd like to be able to capture a more refined definition of these datatypes. For instance, the hardware IDs have no numerical significance, so...

MySQL - How to determine if my table is stored in RAM?

I'm running: MySQL v5.0.67 InnoDB engine innodb_buffer_pool_size = 70MB Question: What command can I run to ensure that my entire 50 MB database is stored entirely in RAM? ...

can we have one attribute with multiple values in an eav design?

i am doing a database design using EAV. I am facing an issue when i try to model an entity with attribute having multiple values? For example Entity id | name | description -- | ---- | ------------ 1 | configuration1 | configuration1 Attribute id | entityId | name | type -...

Store children in database preserving information about their order

I am designing database tables for a master-detail scenario. The specific requirement is that it is necessary to store information about the order of children. I see some possible solutions (like adding a column representing a position in the sequence, or a column with foreign key to the previous child) but I would like to know the best ...

Why is database view used?

Is using "view" in db design right method or we should handle it code side? What are the advantages or disadvantages? ...

Any tips of how to handle hierarchical trees in relational model?

Hello all. I have a tree structure that can be n-levels deep, without restriction. That means that each node can have another n nodes. What is the best way to retrieve a tree like that without issuing thousands of queries to the database? I looked at a few other models, like flat table model, Preorder Tree Traversal Algorithm, and so....

Advice on setting up a central db with master tables for web apps

I'm starting to write more and more web applications for work. Many of these web applications need to store the same types of data, such as location. I've been thinking that it may be better to create a central db and store these "master" tables there and have each applicaiton access them. I'm not sure how to go about this. Should I ...

How do you manage web navigation info in your application?

I’m building an application where different users will have different menu items available to them depending on what they’ve paid for. There will also be multiple levels to the menu hierarchy. What’s the best approach to this problem? I’m assuming I need a database table that represents the menu hierarchy, including the parent-child r...

Making a DateTime field in a database automatic?

I'm putting together a simple test database to learn MVC with. I want to add a DateTime field to show when the record was CREATED. ID = int Name = Char DateCreated = (dateTime, DateTime2..?) I have a feeling that this type of DateTime capture can be done automatically - but that's all I have, a feeling. Can it be done? And if so how?...