I have two tables. One table with the letters of different countries and a second table with a mapping of these letters to each other. I need to make a query to get the mapped letters of the two languages. Can you tell me how this can be done optimally? The letter table id letter language 1 A en 2
Tag: database-design
How to add a column default?
I created a Postgres DB which contains 5 tables. Then I realized that the column student.student_id lacks a column default to generate an UUID: Knowing that some tables are linked to the student table, how can I add to the function as column default for student_id so that the result will be: Answer Use ALTER TABLE: Column defaults do not
Is creating a new table for each `list` the best way to speed up database queries here?
My postgres database has a lists and list_items table. There is an index on the list_id column. To list all items in a list, I have been searching through list_items for where the list_id equals id from the lists table. lists: id title 0 “foo” 1 “bar” list_items: id content list_id 0 “hello” 0 1 “world” 1 2 “foobar” 0
Create database scripts where tables have prepopulated data across environment
I have a table named, ‘[UserTypes]’ where Primary id is [uniqueidentifier]. and I have a reference in another table called ‘[Users]’. Users table has UserTypeId as foreignKey. This ’80D1EEE7-0BCC-48A7-A741-29A1D8B6E580′ is the userTypeId of ‘ADMI’ from the userType Table. My problem is, Suppose, I need to run this script in a new DB, then my ID for ‘ADMI’ will be different
Data Model for multiple checkboxes
I currently have a supplier table and now I want to store the regions served by each supplier. As a first thought, I made my supplier model like this : Does this seem to be a good pattern? Especially for queries to filter suppliers by region served etc. Is this solution still reliable if in the future I want to
Is there a (key:value) pair datatype that can be used as a column in SQL – Specifically Google Cloud Spanner?
Given the scenario that I would like to store sales of a store in a table in a database in Google Cloud Spanner. That table would (in addition to the sale ID as the primary key) have to store a list of product IDs sold, along with the quantity of each product sold. Ideally, this would be in the form
Include one table’s values in multiple other tables and allow FK references
I’m still a relative novice when it comes to designing SQL databases, so apologies if this is something obvious that I’m missing. I have a few tables of controlled vocabularies for certain values that I’m representing as FKs referencing the controlled vocab tables (there are few distinct vocabularies I’m trying to represent). My schema specification allows each of these vocabularies
How to structure my database model for a simple web application and organize my SQL data model
I am working on a web app. I have a question about the SQL parts. I am currently creating a food rating interface. The user should be able to login and then rate the food. Currently I use a custom database (users) for the login page. I also use a separate database (review) for the reviews. my current database structure
How to use constraints to force two child items be from the same parent?
I have a Jobs table that holds jobs. I have a Tasks table that holds tasks that belong to a job (1:many). I have a Task_Relationships table that holds the data about which tasks depend on other tasks within a job. I have 2 jobs, each job has 3 tasks and within the jobs the tasks are related as in
How is this cardinality being calculated in Explain plan?
I am analyzing the “explanation plan” about the following instruction and Oracle SQL Developer tells me that it has a cardinality of 1513 and cost of 1302. How are these calculations performed? Could be reproduced with an instruction (calculate with a select and obtain de same value)? Answer The cardinality generated by an explain plan can be based on many