database-design

How to store formatted text in MySQL table?

不羁岁月 提交于 2019-12-21 09:34:11
问题 [My EDITED New Question] I am taking text input in HTML form as <textarea> . Suppose the user entered the following text: 1. Hello World 2. Hi World 3. Hola My PHP code is inserting into the table as: 1. Hello World\r\n2. Hi World\r\n\r\n3. Hola I am displaying this text into a DIV element by using the below method (assume that $text is retrieved from database): <div><?php echo $text ?></div> The output I am getting is: 1. Hello World 2. Hi World 3. Hola How to get the exact output as user

Complex Queries using GAE datastore

耗尽温柔 提交于 2019-12-21 09:17:37
问题 I am in the early stages of developing a sports statistics website (ultimate frisbee) and would like to know your opinions if Google App Engine is right for me. I am writing it in Python using Django and have been comfortable with standard RDBMS for years but this site is a long term project and I am expecting very large amounts of data so I would like the "infinite" scaling that the GAE datastore offers. A vast majority of the queries to the database will return very standard results that

SQL-Server: Define columns as mutually exclusive

江枫思渺然 提交于 2019-12-21 08:45:11
问题 joking with a collegue, I came up with an interesting scenario: Is it possible in SQL Server to define a table so that through "standard means" (constraints, etc.) I can ensure that two or more columns are mutually exclusive? By that I mean: Can I make sure that only one of the columns contains a value? 回答1: Yes you can, using a CHECK constraint: ALTER TABLE YourTable ADD CONSTRAINT ConstraintName CHECK (col1 is null or col2 is null) Per your comment, if many columns are exclusive, you could

Efficiently determine owner of a record in a hierarchy with MongoDB

你。 提交于 2019-12-21 08:14:46
问题 I am trying to achieve the following: Select all the records that I own, where ownership is objects I have created OR objects a user I manage has created, where user management can be in a hierarchy of users managing users Ownership is clearly straight forward and could be handled by a simple id corresponding to the owner. The hierarchy of user management has me a little stumped to perform without heavy lifting through large lists of IDs (you can obviously just find every user that is managed

Can I use InnoDB and MyISAM tables in ONE database?

那年仲夏 提交于 2019-12-21 08:07:06
问题 Obviously both have their benefits. MyISAM is fast but may get currupted easily, InnoDB is slow but is more stable thanks to transactions and foreign keys. So it could be good to mix both engines in one database. If that's possible? 回答1: REMEMBER! It's OK to mix table types in the same database! In fact it's recommended and frequently required. However, it is important to note that if you are having performance issues when joining the two types, try converting one to the other and see if that

SQL Server: varbinary or int to store a bit mask?

偶尔善良 提交于 2019-12-21 07:55:32
问题 Is there any advantage of using int vs varbinary for storing bit masks in terms of performance or flexibility. For my purposes, I will always be doing reads on these bit masks (no writes or updates). 回答1: You should definitely use an INT (if you need 32 flags) or BIGINT (for 64 flags). If you need more flags you could use BINARY (but you should probably also ask yourself why you need so many flags in your application). Besides, if you use an integral type, you can use standard bitwise

GUID: varchar(36) versus uniqueidentifier

房东的猫 提交于 2019-12-21 07:04:09
问题 I'm working with a legacy database that stores GUID values as a varchar(36) data type: CREATE TABLE T_Rows ( RowID VARCHAR(36) NOT NULL PRIMARY KEY, RowValue INT NOT NULL ) INSERT T_Rows (RowID, RowValue) VALUES (NEWID(), 1) I would assume that storing a GUID as a uniqueidentifier would be preferable since it's only 16 bytes in size as opposed to 36. Are there any advantages to storing a GUID as a varchar? 回答1: Perhaps only the fact that you can 'read' them from a SELECT statement (although I

Store spreadsheet kind of data in SQL Database

假如想象 提交于 2019-12-21 06:51:56
问题 I want to store the spreadsheet data in database, so right now i am using key/value pattern to store the same but its taking too much time to retrieve it from data base, if the data is huge. Do anyone has the best way to do the same. How Google saves their spreadsheet data? Usually I have to show 30 to 40 columns and 10,000 rows on the web page with page size 500 or 1000 for pagination. Data is for line item with pricing. My current database structure is as below. Column Table Column_Id int

Sql Server: What is the benefit of using “Enforce foreign key constraint” when it's set to “NO”?

Deadly 提交于 2019-12-21 06:49:04
问题 I know the purpose of "Enforce foreign key constraint" in RDBMS. But is there any benefit when it's set to "NO" ? 回答1: In normal production, this setting should never be set to NO . But: when you're developing, or restructuring a database, or when you do e.g. a large bulk load of data that you'll need to "sanitize" (clean up), then it can make sense to turn off foreign key constraints to allow "non-valid" data to be loaded into a table. Of course, as I said - you shouldn't keep that setting

DB Schema for Appointment Booking App: What is the correct relationship between Doctors, Appointments, TimeSlots, Patients?

依然范特西╮ 提交于 2019-12-21 06:31:05
问题 [ UPDATED SCHEMA: http://i.imgur.com/fX9CGNh.png ] I'm tasked with developing an appointment booking system that is designed for a small medical office. It is a Rails 3.2 app. I'm having difficulty designing a database schema that makes sense to me. Question: Given the following information, what is the correct relationship between doctors, patients, appointments, chairs and time_slots? Patients need to make appointments with a doctor's office. Depending on the type of appointment, each