database-design

modeling many to many unary relationship and 1:M unary relationship

喜你入骨 提交于 2020-03-05 00:56:08
问题 Im getting back into database design and i realize that I have huge gaps in my knowledge. I have a table that contains categories. Each category can have many subcategories and each subcategory can belong to many super-categories. I want to create a folder with a category name which will contain all the subcategories folders. (visual object like windows folders) So i need to preform quick searches of the subcategories. I wonder what are the benefits of using 1:M or M:N relationship in this

Select from multiple tables - One to Many relation

狂风中的少年 提交于 2020-03-01 01:57:50
问题 I have such tables: Table Product [ Id | Name ] Table Images [ Product_Id | Url | Ordernumber] Table Prices [ Product_Id | Combination | Currency | Price] Table Quantites [ Product_Id | Combination | Quantity] Table Product is in relation one-to-many with other tables. I need to query the table and result something like this (pseudo-array): [ ProductId: 1, Name: 'Sample product', Images: [ [url, 1], [url, 2] ], Prices: [ [aaa, USD, 50.00], [aaa, EUR, 50.00], [bbb, USD, 59.00], [bbb, EUR, 59

Advise on database design for a project lifecycle

此生再无相见时 提交于 2020-02-25 13:32:36
问题 In our company, a project begins it's life as a business development which has it's own 3-stage lifecycle. Once the business development ends its lifecycle it may become a full fledged project, which then begins a entirely new 3-stage lifecycle. However sometimes business developments never mature beyond their initial phase into projects. Considering all this, I decided to have a table for Business Developments (BD) and a seperate table for Projects (treating them as seperate entities), each

Dynamic table design (common lookup table), need a nice query to get the values

和自甴很熟 提交于 2020-02-25 04:18:11
问题 sql2005 This is my simplified example: (in reality there are 40+ tables in here, I only showed 2) I got a table called tb_modules, with 3 columns (id, description, tablename as varchar): 1, UserType, tb_usertype 2, Religion, tb_religion (Last column is actually the name of a different table) I got an other table that looks like this: tb_value (columns:id, tb_modules_ID, usertype_OR_religion_ID) values: 1111, 1, 45 1112, 1, 55 1113, 2, 123 1114, 2, 234 so, I mean 45, 55, 123, 234 are usertype

Determining Super Key

喜欢而已 提交于 2020-02-25 03:45:22
问题 According to Wikipedia Today's Court Bookings Each row in the table represents a court booking at a tennis club that has one hard court (Court 1) and one grass court (Court 2) A booking is defined by its Court and the period for which the Court is reserved Additionally, each booking has a Rate Type associated with it. There are four distinct rate types: SAVER, for Court 1 bookings made by members STANDARD, for Court 1 bookings made by non-members PREMIUM-A, for Court 2 bookings made by

what is the correct way to design a 'table to row' relationship?

丶灬走出姿态 提交于 2020-02-06 15:42:33
问题 I am trying to model the following in a postgres db. I have N number of 'datasets'. These datasets are things like survey results, national statistics, aggregated data etc. They each have a name a source insitution a method etc. This is the meta data of a dataset and I have tables created for this and tables for codifying the research methods etc. The 'root' meta-data table is called 'Datasets'. Each row represents one dataset. I then need to store and access the actual data associated with

How to store social network's actions in NEO4J?

喜夏-厌秋 提交于 2020-02-06 05:06:26
问题 We are going to use NEO4J for our social network database and we have common social networks actions such as following, link, comment, posts and so on... . Now I want to know is this correct, we are doing: Comment: user_comment is a node and has a relation with post node, relation name is comment Like: Like is a relation, the relation name is like and a post has a relation with a user, the relation name is like Location: Each post can have a location, then post node has a where relation with

Create a composite attribute in My sql ER diagram?

时光总嘲笑我的痴心妄想 提交于 2020-02-04 05:52:05
问题 I am currently working on a project in mySQL and I was wondering if mySQL makes it possible to create a set of composite attributes for an attribute of an entity. The attribute is not the primary key, it is an address so the composite attributes are supposed to be, street, town, state ECT... A) is this possible? if so which type would I use/ how would I go about doing it. B) is this practical I have about 10 entities and I feel like a couple of them will need composite attributes that was

PostgreSQL inner queries with prepared statements

只谈情不闲聊 提交于 2020-02-04 00:59:07
问题 I have a table to store contacts. I want to grab the max value of a column where adding user_id is {some number} and set that as the same column value for the current inserting record. I'm using prepared statements: pg_prepare($db, "add", 'INSERT INTO '.CONTACTS.' (c_user_serial,c_name,c_company,c_email) VALUES ($1, $2, $3, $4)'); $insert_co = pg_execute($db, "add", array({(MAX OF c_user_serial where c_user_id = 1234) + 1 increment },$name,$company,$email)); c_user_id is the ID of the user

What is the most correct way to store a “list” in a SQL Database?

核能气质少年 提交于 2020-02-03 08:13:09
问题 So, I've read a lot about how stashing multiple values into one column is a bad idea and violates the first rule of data normalisation (which, surprisingly, is not "Do Not Talk About Data Normalisation") so I need some help. At the moment I'm designing an ASP .NET webpage for the place I work for. I want to display data on a web page depending on what Active Directory groups the person belongs to. The first way of doing this that comes to mind is to have a table with, essentially, a column