database-schema

How to query table data by Object Id and Column Id?

牧云@^-^@ 提交于 2019-12-07 09:40:13
问题 Having the table Clients . PK LastName Name Address 1 Vidal Arturo St.... 2 Lavezzi Ezequiel St.... 3 Cuadrado Guillermo St.... I want to get: With the following query gives me the first four columns but how can I link this with the table data? SELECT TAB.object_id OBEJCTID, TAB.name TABLENAME, COL.column_id COLUMNID, COL.name FROM sys.tables TAB JOIN SYS.columns COL ON TAB.object_id = COL.object_id WHERE TAB.object_id = 25659888; 回答1: You need to unpivot the data. Try something like this

should this database table be normalized?

允我心安 提交于 2019-12-07 08:02:30
问题 i have taken over a database that stores fitness information and we were having a debate about a certain table and whether it should stay as one table or get broken up into three tables. Today, there is one table called: workouts that has the following fields id, exercise_id, reps, weight, date, person_id So if i did 2 sets of 3 different exercises on one day, i would have 6 records in that table for that day. for example: id, exercise_id, reps, weight, date, person_id 1, 1, 10, 100, 1/1/2010

2 relationships between 2 entities in ER diagram

爷,独闯天下 提交于 2019-12-07 01:43:16
问题 I'm trying to draw an ER diagram describing the following: -"Department" employs "Employees" -Some "Employees" are "Special" and have more attributes -Some of the "Employees" ("Special" and non special) are "Managers" -"Managers" manage "Departments" So, to convey this I have: Department ------(employs)------- Employee-----<--------Special | | |-----------(manages)---------- From my understanding, I cannot have 2 relationships between 2 entities. How do I deal with this situation then? 回答1:

How can I create a MetadataWorkspace using metadata loading delegates?

半腔热情 提交于 2019-12-06 15:37:14
问题 I followed this example Changing schema name on runtime - Entity Framework where I can create a new EntityConnection from a MetaDataWorkspace that I then use to construct a DbContext with a different schema, but I get compiler warnings saying that RegisterItemCollection method is obsolete and to "Construct MetadataWorkspace using constructor that accepts metadata loading delegates." How do I do that? Here is the code that is working but gives the 3 warnings for the RegsiterItemCollection

How to insert relational data (many to many) in SQL Alchemy by means of API queries in Python

限于喜欢 提交于 2019-12-06 11:36:28
EDIT: I have made a short question because I think this one is too long, sorry First of all, I am a newcomer to databases, programming languages and so on... so sorry if this question is not so proper nor specific, any help or guidance would be much appreciated... The context I am working with is the following: I am querying an existing database by means of its APIs in order to retrieve certain information to design my own database. The point to create this database is for example to let the user introduce a gene to know where in the organism it is over (UP) or under (DOWN) expressed, and in

Elegant schema to log users' actions

瘦欲@ 提交于 2019-12-06 11:21:41
I have a database schema to log operations users perform in my webapp: Log --- Id Log_Type_Id Performed_by_Person_Id Performed_to_Person_Id Comment_Id Story_Id Photo_Id etc_Id Person_Log ---------- Person_Id Log_Id This way I can notify users of entries in their log with details about what exactly happened. The problem is the Log table has to contain every possible type of user operation (they modified a story or comment, created a story or comment or photo, updated a profile, etc). And almost all of those fields will necessarily be null for each entry. Ideally I have individual Log tables

Identifying relationship - many to many

拟墨画扇 提交于 2019-12-06 09:58:29
I have made a small database for a daycare centre. I have been reading up on identifying and non-identifying relationships and am still a bit confused about the whole thing. I have been using MySQL Workbench to design the database. Now, the criterias for parents and children are that a Parent can have one or more Children and vice versa - ergo, the relationship between Parents and Children is a many-to-many. The best praktice to solve this (as I understand) is to make a third table - Parets_Children and use that as a "connection" between the other two: Parents - 1:n - Parents_Children n:1 -

User Defined Fields PHP Mysql

不问归期 提交于 2019-12-06 09:30:20
问题 I am currently building a small crm application. I need each user to be able to define their own custom fields. I am currently building this crm using php and mysql. Example: I have a "customer" table which has the standard fields: name, phone, address, email, etc. But i want to allow the user (unique session) to add fields that are custom to his/her business which are only accessible to him (not other users). I then want these custom fields to function just like all the other fields in the

Why is a specific cardinality not allowed in the ERD?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 07:53:06
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, many, 1 = mandatory, one. Is this restriction universal? What's the reason behind it? EDIT: clarified my

One table vs multiple tables

荒凉一梦 提交于 2019-12-06 07:40:33
问题 I have the following tables: - posts - files - events - documents Every post, file, event, document can have comments. What is the better database scheme for this, and why ? First solution comments table (comment_id, author_id, comment) 4 tables to create relations (posts_comments(post_id, comment_id), files_comments(file_id, comment_id), events_comments(event_id, comment_id), documents_comments(document_id, comment_id)) Second solution comments table (comment_id, author_id, comment) items