relational-database

PonyORM: What is the most efficient way to add new items to a pony database without knowing which items already exist?

家住魔仙堡 提交于 2019-12-07 03:55:48
问题 Forgive me if this is an obvious question but I'm new to pony and databases in general and didn't find the right part of the documentation that answers this question. I'm trying to create a database with companies and the locations where those companies have offices. This is a many-to-many relationship since each company is in multiple locations and each location can be host to multiple companies. I'm defining my entities as such: from pony import orm class Company(db.Entity): '''A company

SQL Server database design users, groups, roles, memebers

萝らか妹 提交于 2019-12-06 21:19:26
I have the following SQL Server db with one table so far. ---------------- |Users | ---------------- | UserId PK | | | | Other fields | ---------------- I need to add few more tables to it which is not a problem but this is the goal: ---------------- ---------------- ---------------- ---------------- |Users | |Roles | | Teams | | Groups | ---------------- ---------------- ---------------- ---------------- | UserId PK | | RoleId PK | | TeamId PK | | GroupId PK | | | | | | | | | | Other fields | | Other fields | | Other fields | | Other fields | ---------------- ---------------- ----------------

DB design: one large DB for all customers or many small DBs

给你一囗甜甜゛ 提交于 2019-12-06 15:34:20
Looking for any suggestions or advise or even best practices. I have developed an online database using php and mysql. It allows companies to log complaints and resolutions etc. There is a user database for login and a cip database for logging the main data. 2 companies are trialing and testing the database. At the moment each company is using separate databases and separate html pages. I am wondering what the best way to add more companies. Ideas that I have are: 1. To have one large database for users and one large database for cip and use a company id or similar to identify individual

Relational division in mysql without aggregrate functions?

六月ゝ 毕业季﹏ 提交于 2019-12-06 15:29:40
问题 I want to implement a simple relational division in mysql with where exists or where not exists.I don't want to use any of the aggregrate functions and also don't want to use where in or where not in clauses.I am trying to write relational algebra and relational calculus queries for the same so it would be easy if I do it this way. For example: GID PID TEAM 101 1 X 201 2 X 301 3 X 101 4 Y 201 5 Y 101 6 Z The answer is GID,TEAM/GID which gives X as the answer.I want to know how to implement

How to find records, whose has_many through objects include all objects of some list?

守給你的承諾、 提交于 2019-12-06 13:53:25
问题 I got a typical tag and whatever-object relation: say class Tag < ActiveRecord::Base attr_accessible :name has_many :tagazations has_many :projects, :through => :tagazations end class Tagazation < ActiveRecord::Base belongs_to :project belongs_to :tag validates :tag_id, :uniqueness => { :scope => :project_id } end class Project < ActiveRecord::Base has_many :tagazations has_many :tags, :through => :tagazations end nothing special here: each project is tagged by one or multiple tags. The app

Comment system design

五迷三道 提交于 2019-12-06 13:20:13
问题 Here is my current comment system design: I'm developing it for a website that has lots of areas, blogs, tutorials, manuals etc etc. As supposed to developing a separate comment table for each ( tblBlogComments , tblTutorialComments ) etc etc, I'm trying to go for a one structure fits all approach. This way, I can turn the comment system into a web control, and just drop it on any page that I want comments for. It means I only have one set of rules, one set of code files to maintain. The only

CakePHP defining additional fields in HABTM/ManyToMany relationship?

◇◆丶佛笑我妖孽 提交于 2019-12-06 12:33:56
Basically I would like to recreate this in CakePHP: Many to many relationships with additional data on the relationship or in other words, my intermediary table to have extra fields defining the type of relationship. How do I set this up in CakePHP? You can use as example: model company: id name person_id model person: id name model company_person: company_id person_id position thanx if you want to have additional data in HABTM, use 2 hasMany relationships instead. So if A HABTM B, then set it up as: A hasMany A_B, B hasMany A_B, A_B belongsTo A, A_B belongsTo B. AFAIK, Cake support for HABTM

can the natural-join be seen as a subset of the equi-join and theta-join?

空扰寡人 提交于 2019-12-06 11:39:23
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 6 years ago . I have a question regarding relational algebra and how the theta-join, equi-join, and natural-join can be classified in relation to each other. In a comment on stackoverflow.com sqlvogel quotes E.F. Codd, the computer scientist who invented the relational model for database management, "[the] Natural[-join] is a subset of Equi[-join] which is a subset of Theta[-join]." *

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

Audit logging for products data?

匆匆过客 提交于 2019-12-06 09:51:15
When the staff change the information of product name, option name or prices. It should insert the data into history log and who done it. items table: item_id (PK) item_name item_description Note: item prices are in the item_options table item_options table: option_id (PK) item_id (FK) option_name option_price A item can have 1 or more options. If I want to change the name items.item_name , It should copy the current record to the history table, delete current record from items table and then insert a new record with the new information in the items table? What about the item_options , how