database-schema

How to manually set seed value as 1000 in MySQL

浪子不回头ぞ 提交于 2019-11-30 17:47:56
I am using MySQL 5. I need to set the seed value as 1000 for my auto increment field. How can I set it? To set when creating your table: CREATE TABLE xxx(...) AUTO_INCREMENT = 1000; To set after creating the table: ALTER TABLE xxx AUTO_INCREMENT = 1000; Asaph If the table already exists, you can do this: ALTER TABLE mytable AUTO_INCREMENT = 1000; But make sure the highest value in the auto_increment column is less than 1000. If you are creating a new table, you can do this: CREATE TABLE mytable (id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT) AUTO_INCREMENT = 1000; 来源: https://stackoverflow.com

Create an aspect in Alfresco Content Model

◇◆丶佛笑我妖孽 提交于 2019-11-30 17:46:32
问题 I am starting currently using Alfresco CMS. I need to create an "aspect" in my content model which must contains a number of properties as: Aspect: property 1 : String property 2 : int property 3 : int property 4 : long Moreover it must contains two more properties which are composed either of number of properties as: Format: FormatProperty1: int FormatProperty2: int FormatProperty3: int Metadata: list1: List<String> list2: List<String> MetadataProperty 3: boolean I have not yet created

Which normal form does this table violate?

怎甘沉沦 提交于 2019-11-30 17:35:29
问题 Consider this table: +-------+-------+-------+-------+ | name |hobby1 |hobby2 |hobby3 | +-------+-------+-------+-------+ | kris | ball | swim | dance | | james | eat | sing | sleep | | amy | swim | eat | watch | +-------+-------+-------+-------+ There is no priority on the types of hobbies, thus all the hobbies belong to the same domain. That is, the hobbies in the table can be moved on any hobby# column. It doesn't matter on which column, a particular hobby can be in any column. Which

Exclude function definitions when dumping a PostgreSQL database

别等时光非礼了梦想. 提交于 2019-11-30 17:29:36
问题 I have a PostgreSQL database with PostGIS functions loaded into it. I would like to dump out the schema of the database, but pg_dump -s dumps out the functions along with the table definitions. Is there a way to exclude the functions and just dump the table definitions? 回答1: For all I know, pg_dump and pg_dumpall do not support any such restriction. You could move all your functions to a dedicated schema which you could exclude from the dump like this: pg_dump mydb -N function_schema > mydump

is `date` a valid mysql column name?

断了今生、忘了曾经 提交于 2019-11-30 14:38:34
问题 I was wondering if date is actually a valid mysql column name? According to the manual MySQL permits some keywords to be used as unquoted identifiers because many people previously used them. Examples are those in the following list: ACTION BIT DATE ENUM NO TEXT TIME TIMESTAMP So, from that I gather you are allowed to use date as a column name, but it doesn't say that it is not recommended . So, are there any implications to using date as a column name? 回答1: I was able to add a column named

Handling migrations with MongoDb

六眼飞鱼酱① 提交于 2019-11-30 13:46:01
问题 Just to give a little more context to the question, I have a web application (asp mvc) which basically wraps CRUD operations to a MongoDb instance, it carries out validation and certain business logic before the model is verified and sent over to be stored, retrieved etc. Now one problem we have his is that in the new version the models have changed but the existing data has not, here is an example: (it is c# specific but the question really is language agnostic) public class Person { public

How to model a database with many m:n relations on a table

我是研究僧i 提交于 2019-11-30 13:02:40
I am currently setting up a database which has a large number of many-to-many relations. Every relationship was modeled via a link table. Example: A person has a number of jobs, jobs are fulfilled by a number of persons. A person has a number of houses, houses are occupied by a number of persons. A person has a number of restaurants he likes, restaurants have a number of persons who like the restaurant. First I designed this as follows: Tables: Person, Job, House, Restaurant, Person_Job, Person_House, Person_Restaurant. Relationships 1 - n: Person -> Person_Job, Person -> Person_House, Person

SQL Query to search schema of all tables

旧时模样 提交于 2019-11-30 12:04:23
问题 I am working on a SQL Server 2008 Db that has many tables in it (around 200). Many of these tables contain a field by the name "CreatedDate". I am trying to identify all the table schema with this particular field. Is there a SQL query to do this? 回答1: I would query the information_schema - this has views that are much more readable than the underlying tables. SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME LIKE '%create%' 回答2: You can also try doing this using one of many third

PostgreSQL: Can you create an index in the CREATE TABLE definition?

陌路散爱 提交于 2019-11-30 11:15:54
问题 I want to add indexes to some of the columns in a table on creation. Is there are way to add them to the CREATE TABLE definition or do I have to add them afterward with another query? CREATE INDEX reply_user_id ON reply USING btree (user_id); 回答1: There doesn't seem to be any way of specifying an index in the CREATE TABLE syntax. PostgreSQL does however create an index for unique constraints and primary keys by default, as described in this note: PostgreSQL automatically creates an index for

Schema for User Ratings - Key/Value DB

血红的双手。 提交于 2019-11-30 09:11:49
We're using MongoDB and I'm figuring out a schema for storing Ratings. Ratings will have values of 1-5. I want to store other values such as fromUser This is fine but the main question I have is setting it up so that recalculating the average is as efficient as possible. SOLUTION 1 - Separate Ratings Class The first thought was to create a separate Ratings class and store an array of pointers to Ratings in the User class. The reason I second guessed this is that we will have to query for all of the Ratings objects every time a new Rating comes in so that we can recalculate an average ...