relational-database

How to set cascade on SQLite database with compound primary foreign key?

荒凉一梦 提交于 2019-12-11 10:16:35
问题 I have a db that's structured with a supertype table as well as subtype tables like so: EVENT PatientId INTEGER, DateTime TEXT, EventTypeCode TEXT, PRIMARY KEY( PatientId, DateTime, EventTypeCode ) different types of events have their own tables and have the same primary key, except that it's foreign. EXERCISE PatientId INTEGER, DateTime TEXT, EventTypeCode TEXT, PRIMARY KEY( PatientId, DateTime, EventTypeCode ) ON CONFLICT IGNORE, CONSTRAINT "PrimaryKey" FOREIGN KEY ("PatientId",

Database Design: One to many of different types

大城市里の小女人 提交于 2019-12-11 08:35:37
问题 The work flow for something is as follows 1) Create a "Message of the Day" for a particular group of users (which must be approved before active) 2) Assign who can approve this by selecting single users, and/or users who are admins of the group this MOTD is going into, or any other number of groupings for users. 3) "Message of the Day" must no be approved by one of the 'approvers' selected. How can I relate a MOTD record, to one or more of "single users" and/or "groupings of users" 回答1: One

How to remove Many to Many auto generated table with Entity Framework Code First

我怕爱的太早我们不能终老 提交于 2019-12-11 07:53:37
问题 I have 3 Entities Product , Supplier & Contract , Product & Supplier each have as reference a Collection of each other which creates a ProductSupplier Table. To add an extra property on this Many to Many relation i have created a 3rd Entity ProductForSupplier wich holds 1 Product, 1 Supplier and a extra string Property ProductNumber. In addition i have created another Entity ProductSupplierForContract which holds a ProductForSupplier & a Contract. When i seed some data for test i can observe

Database table naming; name_verb_name conventions for many-to-many intersect tables

a 夏天 提交于 2019-12-11 07:39:31
问题 I've read around on SO for other questions on the subject, and I'm aware that naming conventions are an often subjective topic, however I feel this is less general ( and less inquired about ) than PascalCase versus under_scores . Given a simple commerce system, with User and Product entities; a given user can purchase items, and the transaction records are stored in a User_Product table. ( sure, Purchase is more semantic, but just follow me here ) Anyways, if I were to introduce the ability

Can one have optional fields in a 3NF / BCNF database?

限于喜欢 提交于 2019-12-11 07:32:42
问题 I have a database that I am trying to set up and I would like it to be in at least 3NF. However, some fields are not necessary in all situations, and the necessity of this field, not the value itself, depends on another. In essence, I want to keep track of jobs that are on hold for one reason or another. My main table right now includes these fields: Job No (primary Key) | Short Text | Storage Location | Coordinator I have other tables for employee list and storage locations. Now my problem

Basic Database Design - Optional Participation

微笑、不失礼 提交于 2019-12-11 06:28:08
问题 Working on basic database design homework and ERD drawing in Visio, and can't wrap my head around this problem. United Helpers is a nonprofit organization that provides aid to people after natural disasters. Based on the following brief description of operations, create the appropriate fully labeled Crow’s Foot ERD. •Individuals volunteer their time to carry out the tasks of the organization. The name, address, and telephone number for each volunteer are tracked. Each volunteer may be

MSSQL query IN statement for distinct rows

冷暖自知 提交于 2019-12-11 05:59:25
问题 Okay so the problem I'm having is selecting a distinct property on the query below. I understand the reasoning behind why I can't (rownum is unique) but I'm after a solution that will allow me to keep my SQL paging and pull though only the distinct properties from my database. I'm currently using a one to many database relationships that also holds the filtering needed for the results. What I'd be interested in hearing is if there's a better way than using "IN" for my filtering. Cheers guys

How to design a relational database for associating multiple tags with id?

社会主义新天地 提交于 2019-12-11 05:05:30
问题 I'm developing a project of Q/A website, and a questions in this website can be linked with multiple tags. For example: How can I implement quicksort in C++ ? Tags for this question can be C, C++, Algorithm My question is how can I store these tags in MySQL table ? My approach: The question above has id = 123 ------------------------- |question_id | tags | ------------------------- | 123 | C | ------------------------- | 123 | C++ | ------------------------- | 123 |Algorithm | ---------------

In a SQL database, when should a one-to-one relationship be in the same table and when in separate tables?

风格不统一 提交于 2019-12-11 04:56:49
问题 Can anyone provide some examples of when in a SQL database it's a better choice to keep one-to-one relationships on the same table, and when instead it makes more sense to have them on separate tables? 回答1: When you have several entities which all must be able to act as a foreign key to another entity, and the "several entities" have both common properties and unique properties, and you want a NOT NULL constraint on the unique properties (or less important don't want a bunch of NULL values