database-schema

How to store arrays in MySQL?

筅森魡賤 提交于 2019-11-26 09:05:20
问题 I have two tables in MySQL. Table Person has the following columns: id | name | fruits The fruits column may hold null or an array of strings like (\'apple\', \'orange\', \'banana\'), or (\'strawberry\'), etc. The second table is Table Fruit and has the following three columns: ____________________________ fruit_name | color | price ____________________________ apple | red | 2 ____________________________ orange | orange | 3 ____________________________ ...,... So how should I design the

Why use a 1-to-1 relationship in database design?

淺唱寂寞╮ 提交于 2019-11-26 08:19:04
问题 I am having a hard time trying to figure out when to use a 1-to-1 relationship in db design or if it is ever necessary. If you can select only the columns you need in a query is there ever a point to break up a table into 1-to-1 relationships. I guess updating a large table has more impact on performance than a smaller table and I\'m sure it depends on how heavily the table is used for certain operations (read/ writes) So when designing a database schema how do you factor in 1-to-1

How to get all columns' names for all the tables in MySQL?

那年仲夏 提交于 2019-11-26 07:54:16
问题 Is there a fast way of getting all column names from all tables in MySQL , without having to list all the tables? 回答1: select * from information_schema.columns where table_schema = 'your_db' order by table_name,ordinal_position 回答2: To list all the fields from a table in MySQL: select * from information_schema.columns where table_schema = 'your_DB_name' and table_name = 'Your_tablename' 回答3: SELECT * FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal

How can I initialize a MySQL database with schema in a Docker container?

只愿长相守 提交于 2019-11-26 06:57:41
问题 I am trying to create a container with a MySQL database and add a schema to these database. My current Dockerfile is: FROM mysql MAINTAINER (me) <email> # Copy the database schema to the /data directory COPY files/epcis_schema.sql /data/epcis_schema.sql # Change the working directory WORKDIR data CMD mysql -u $MYSQL_USER -p $MYSQL_PASSWORD $MYSQL_DATABASE < epcis_schema.sql In order to create the container I am following the documentation provided on Docker and executing this command: docker

How to rollback a specific migration?

☆樱花仙子☆ 提交于 2019-11-26 06:50:17
问题 I have the following migration file db\\migrate\\20100905201547_create_blocks.rb How can I specifically rollback that migration file? 回答1: rake db:rollback STEP=1 Is a way to do this, if the migration you want to rollback is the last one applied. You can substitute 1 for however many migrations you want to go back. For example: rake db:rollback STEP=5 Will also rollback all the migration that happened later (4, 3, 2 and also 1). To roll back all migrations back to (and including) a target

Is shortening MongoDB property names worthwhile?

◇◆丶佛笑我妖孽 提交于 2019-11-26 06:43:51
问题 In Blog rolling with mongoDB, express and Node.js the author mentions it\'s a good idea to shorten property names: ....oft-reported issue with mongoDB is the size of the data on the disk... each and every record stores all the field-names .... This means that it can often be more space-efficient to have properties such as \'t\', or \'b\' rather than \'title\' or \'body\', however for fear of confusion I would avoid this unless truly required! I am aware of solutions of how to do it. I am more

How to fix Error: “Could not find schema information for the attribute/element” by creating schema

半世苍凉 提交于 2019-11-26 06:12:43
问题 I have a windows forms application written in VS2010 with C# and get the following errors in the app.config file: Message 4 Could not find schema information for the attribute \'name\' Message 8 Could not find schema information for the attribute \'name\' Message 12 Could not find schema information for the attribute \'name\' Message 5 Could not find schema information for the attribute \'serializeAs\' Message 15 Could not find schema information for the element \'CCP_Utility.Settings1\'

Difference Between Schema / Database in MySQL

笑着哭i 提交于 2019-11-26 04:32:18
问题 Is there a difference between a schema and a database in MySQL? In SQL Server, a database is a higher level container in relation to a schema. I read that Create Schema and Create Database do essentially the same thing in MySQL, which leads me to believe that schemas and databases are different words for the same objects. 回答1: As defined in the MySQL Glossary: In MySQL, physically, a schema is synonymous with a database . You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL

How to see indexes for a database or table in MySQL?

百般思念 提交于 2019-11-26 04:29:33
问题 How do I see if my database has any indexes on it? How about for a specific table? 回答1: To see the index for a specific table use SHOW INDEX: SHOW INDEX FROM yourtable; To see indexes for all tables within a specific schema you can use the STATISTICS table from INFORMATION_SCHEMA: SELECT DISTINCT TABLE_NAME, INDEX_NAME FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = 'your_schema'; Removing the where clause will show you all indexes in all schemas. 回答2: If you want to see all indexes

Is it possible to specify the schema when connecting to postgres with JDBC?

試著忘記壹切 提交于 2019-11-26 03:28:05
问题 Is it possible? Can i specify it on the connection URL? How to do that? 回答1: I know this was answered already, but I just ran into the same issue trying to specify the schema to use for the liquibase command line. Update As of JDBC v9.4 you can specify the url with the new currentSchema parameter like so: jdbc:postgresql://localhost:5432/mydatabase?currentSchema=myschema Appears based on an earlier patch: http://web.archive.org/web/20141025044151/http://postgresql.1045698.n5.nabble.com/Patch