database-design

SQL design approach for searching a table with an unlimited number of bit fields

扶醉桌前 提交于 2019-12-30 03:21:15
问题 Consider searching a table that contains Apartment Rental Information: A client using the interface selects a number of criteria that are represented as bit fields in the DB, for instance: AllowsPets HasParking HasDeck ModernKitchen etc.. We are facing a situation where each new client of our software has additional fields they want to allow their end users to search on. The number of bit fields could reach into the hundreds. I have three approaches that I'm considering and hoping for input

Rails - Multiple Index Key Association

て烟熏妆下的殇ゞ 提交于 2019-12-30 02:28:10
问题 There seem to be a number of ways to handle a multiple foreign key association. Each way I have approached this has their draw backs, and as I am new to Rails I am convinced others have come across a similar scenario and I am probably working on something solved long ago. My question is: What would be an efficient way of handling a multiple index key association, while still retaining all other Rails sql modifiers (such as :include etc)? My scenario is: I have a table association as follows

Design Relational Database - Use hierarchical datamodels or avoid them?

空扰寡人 提交于 2019-12-30 02:27:42
问题 I'm designing a Database and I have some doubts on using Hierarchical datamodels in relational databases. If I want to deal with categories, subcategories and parent categories it is possible not to use a Hierarchical datamodels in a relational database? By another words, it is possible to deal with categories, subcategories and parent categories using the relational way of doing things? By the way, I'm using PostgreSQL. Sorry for my bad english. Best Regards, 回答1: You have a couple of

How to choose optimized datatypes for columns [innodb specific]?

梦想的初衷 提交于 2019-12-30 00:07:50
问题 I'm learning about the usage of datatypes for databases. For example: Which is better for email? varchar[100], char[100], or tinyint (joking) Which is better for username? should I use int, bigint, or varchar? Explain. Some of my friends say that if we use int, bigint, or another numeric datatype it will be better (facebook does it). Like u=123400023 refers to user 123400023, rather then user=thenameoftheuser. Since numbers take less time to fetch. Which is better for phone numbers? Posts

Best table design for application configuration or application option settings?

冷暖自知 提交于 2019-12-29 19:05:35
问题 I need to store a series of configuration values in a database. A couple ways I thought of to store them are: a table with 2 colums(name,value) and a row for each pair, or a table with a column for each config parameter and 1 row? With the first I only need to add another row to add a config value, with the second I need to add a column to the table. Are there any issues with either I should take in to consideration? Is one more efficient than the other? 回答1: For config data, I'd use the key

Database with “Open Schema” - Good or Bad Idea?

青春壹個敷衍的年華 提交于 2019-12-29 17:46:47
问题 The co-founder of Reddit gave a presentation on issues they had while scaling to millions of users. A summary is available here. What surprised me is point 3: Instead, they keep a Thing Table and a Data Table. Everything in Reddit is a Thing: users, links, comments, subreddits, awards, etc. Things keep common attribute like up/down votes, a type, and creation date. The Data table has three columns: thing id, key, value. There’s a row for every attribute. There’s a row for title, url, author,

Data Modeling: Logical Modeling Exercise

我只是一个虾纸丫 提交于 2019-12-29 11:41:28
问题 In trying to learn the art of data storage I have been trying to take in as much solid information as possible. PerformanceDBA posted some really helpful tutorials/examples in the following posts among others: is my data normalized? and Relational table naming convention. I already asked a subset question of this model here. So to make sure I understood the concepts he presented and I have seen elsewhere I wanted to take things a step or two further and see if I am grasping the concepts.

delete where id in list

不打扰是莪最后的温柔 提交于 2019-12-29 11:40:13
问题 if i have a list of Ids (1, 4,6,7) and a db table that i want to delete all records where id is in this list, what is the fastest way of doing this? 回答1: Your question almost spells the SQL for this: DELETE FROM table WHERE id IN (1, 4, 6, 7) 回答2: delete from t where id in (1, 4, 6, 7) 回答3: The correct answer is that speed depends on the characteristics of the particular implementation/engine that you are using, and that you should beware of any quack who pretends to be able to give a

What is purpose of database schema? [closed]

你。 提交于 2019-12-29 10:04:36
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . What is the purpose of database schema? Where can I find more information about this? It's not table, it's not database, what is it? 回答1: From the quackit.com tutorial – SQL Server - Database Schemas: A database schema is a way to logically group objects such as tables, views,

How to apply complex constraints to a database table in MySQL?

前提是你 提交于 2019-12-29 09:25:28
问题 As I am in the final stages of setting up a database for one of my projects, I have thought of an additional constraint that would need to be added to the Task table (see image below), but I am not sure how this can be implemented in MySQL. Original Database Schema (without markups): Click here. Database Schema with Markups: For each job ( job ), a WBS Code List ( wbscodelist ) is assigned. Each of these lists contain a number of WBS Codes ( wbscodeitem ) that apply to that job. An example