database-design

what is the best database design for this table when you have two types of records

元气小坏坏 提交于 2019-12-22 18:49:27
问题 i am tracking exercises. i have a workout table with id exercise_id (foreign key into exercise table) now, some exercises like weight training would have the fields: weight, reps (i just lifted 10 times @ 100 lbs.) and other exercises like running would have the fields: time, distance (i just ran 5 miles and it took 1 hours) should i store these all in the same table and just have some records have 2 fields filled in and the other fields blank or should this be broken down into multiple

Why is a specific cardinality not allowed in the ERD?

元气小坏坏 提交于 2019-12-22 18:30:49
问题 In every tutorial on entity relationship diagrams, I read that specifying a fixed cardinality for a relationship is not allowed. Only an informal comment on the ERD may clarify that the number of pilots is exactly 2 . So, for example, a relationship between flights and pilots where each flight has exactly 2 pilots present, would have to be represented as: <flight> 0..N <------> 1..N <pilot> rather than <flight> 0..N <------> 2 <pilot> My notation is 0..N = optional, many; 1..N = mandatory,

Any suggestions for a db schema for storing related keywords?

妖精的绣舞 提交于 2019-12-22 14:02:11
问题 I have to store a set of related keywords inside a database. As of now, I am thinking of using the following: To store the keywords themselves: CREATE TABLE keywords( id int(11) AUTO_INCREMENT PRIMARY KEY, word VARCHAR(255) ); To store the relations (stores the ids of the related keywords): CREATE TABLE relatedkeywords( id int(11) AUTO_INCREMENT PRIMARY KEY, keyword1 int(11), keyword2 int(11), FOREIGN KEY (keyword1) REFERENCES keywords(id), FOREIGN KEY (keyword2) REFERENCES keywords(id) ); Is

Nulls in dimension table for numeric attributes

淺唱寂寞╮ 提交于 2019-12-22 13:58:58
问题 What is the best way to handle missing values in a dimension table? In the case of a textual column, it is easy to write "NA: Missing," but what should be done for numeric columns where it is important to retain the specific values . Note: I do not want a solution that uses banded values (e.g., textual columns for "0-50", "50-100", "NA: Missing"). For instance, a customer dimension may have a year-of-birth. How should missing years of birth be handled? Leave it null? Add in an arbitrary

Create ERD for Advantage Database Server 10

房东的猫 提交于 2019-12-22 13:56:01
问题 I need to create an ERD for an ADS 10 database. Reverese Engineering would be nice, since the database already exists. Unfortunately, I didn't found a ERD-Tool which supports this database. Does anybody knows a tool which supports this features? 回答1: You can use the Advantage Data Architect to get a model of a database. As far as I know this only works on data dictionaries, but you can easily add free tables to a dictionary if necessary. I don't know of any other ADS compatible modelling

Do I need to create surrogate key for my relationship table?

时光怂恿深爱的人放手 提交于 2019-12-22 12:52:52
问题 I've a relationship table for my many-to-many entities. author_id | book_id Do I need to add relation_id? I should be able to identify using both id. Thank you 回答1: Since you're using Doctrine, try not to think too much on the RDBMS level (at least, not most of the time). If you have two Entities with a ManyToMany relationship, you should forget about the surrogate key. In fact, you should pretty much ignore the fact that the relationship table exists. You simply have two related entity types

Parent child design to easily identify child type

两盒软妹~` 提交于 2019-12-22 12:50:17
问题 In our database design we have a couple of tables that describe different objects but which are of the same basic type. As describing the actual tables and what each column is doing would take a long time I'm going to try to simplify it by using a similar structured example based on a job database. So say we have following tables: These tables have no connections between each other but share identical columns. So the first step was to unify the identical columns and introduce a unique

Marking deleted records in DB tables

泄露秘密 提交于 2019-12-22 11:35:36
问题 Sometimes you want to mark a DB table record as deleted instead of deleting it permanently, right? How do you do that? So far I've been using a boolean "deleted" field but I'm not sure if it's a good apprach. 回答1: That's about it - a boolean field to indicate that the record is deleted. The few times I used that, I called that field IsDeleted . This is often referred to as Logical Delete . It's up to you to respect that field in your reports - which means excluding all the records with

Most watched videos this week

狂风中的少年 提交于 2019-12-22 11:35:36
问题 I have a Youtube like web-page where users upload&watch videos. I would like to add a "most watched videos this week" list of videos to my page. But this list should not contain just the videos that ware uploaded in the previous week, but all videos. I'm currently recording views in a column, so I have no information on when a video was watched. So now I'm searching for a solution to how to record this data. The first is the most obvious (and the correct one, as far as I know): have a

SQL Server - Clustered index design for dictionary

爷,独闯天下 提交于 2019-12-22 11:32:56
问题 Would like some advice from this. I got a table where I want to keep track of an object and a list of keys related to the object. Example: OBJECTID ITEMTYPE ITEMKEY -------- -------- ------- 1 1 THE 1 1 BROWN 1 2 APPLE 1 3 ORANGE 2 2 WINDOW Both OBJECTID and ITEMKEY have high selectivity (i.e. the OBJECTID and ITEMKEY are very varied). My access are two ways: By OBJECTID: Each time an object changes, the list of key changes so a key is needed based on OBJECTID. Changes happen frequently. By