Meaning of "id" in yesod persistent field attributes - yesod

What is the meaning of "id=name" in the definition of the User entity?
Any resources about the persist field attributes?
User
name Text Asc id=name

The id=... attribute sets the column name for the tables primary key.
For Example:
Product id=product_id
name Text
quantityInStock Int
... will create a table with an integer primary key called "product_id"

Related

Get data based on sort index AWS dynamoDB

I have a DynamoDB table like this:
I want to list all posts irrespective of users, i-e by getting all data whose sort key is "post". How can I achieve this?
I have heard about Global Secondary Index, but couldn't figure out how to use them.
You create a global secondary index with a Key Schema like this:
Partition Key: SK attribute of the base table
Sort Key: PK attribute of the base table
It's called an inverted index. Then you can Query the Global Secondary Index by specifying the IndexName in the Query and search for all items that have "post" as the value for SK.

User ID vs ID for primary key dynamoDB

I have a table in which has a "userId" column (set as a partition key) and a "createdAt" column (set as the sort key) so they form up a composite primary key.
I also need to find the exact row in case I don't have the User ID available, so I made another column "id" and made it as a global secondary index.
In my case, should I make the "id" column the primary key and remove the "userId" as the partition key or will this remove the feature of what "Partitioning" actually does by the DynamoDB?
Similarly, If I need to delete a row from the table, should I send "createdAt" field from the front end to be able to find out the exact row? Does this make sense? Sending the "id" of the row seems more good to me to be able to delete the row.
You probably don't want to put a timestamp in your user primary keys. Why? You'd need to know the exact time the user was created to fetch a user, which is probably not what you want.
Consider using a partition key of USER#<user_id> and a sort key of something predictable, like A or METADATA or USER#<user_id>. This allows you to fetch/delete a user by their ID.
If you have access patterns around fetching users in order of account creation, you can create a GSI with the sort key set to the createdAt attribute.

Django migration id char column to existing table

I am trying to create an ID charfield column and set it as primary key to an existing table. So because it is an existing table when i generate Migrations django asks me to provide a default value. What can i enter as primary key default for existing rows? If i enter a single string e.x 'abcd' i will get error for existing rows on migrate because of duplicate value
Apologies.
I didn't read correctly.

How to rename column name in database using Zend Framework 2 doctrine?

I have a table named Products in which there is a column id. It has foreign key relationship with prtyID column in ProductTypes Table. I just want to change the column id of Products table to prtyID. How is it possible? Is there any doctrine command is available for that? Please help me to fix this..
I'm not sure what you are trying to do here... id should be the primary id of Products, not a foreign key for another table. Please add your code if you ask a question.
Usually, Doctrine will use the property name to create the table column. So changing the property name to $prtyId would change your table column as well.
You can give every column the attribute "name" in the annotation of your entity, which will change the column name in your database:
/**
* #ORM\Column(type="integer", name="prtyID")
**/
protected $id;
Or, because you don't define the foreign keys yourself in Doctrine but the association, you can define the association like this:
/**
* #ORM\ManyToOne(targetEntity="ProductTypes")
* #ORM\JoinColumn(name="prtyID", referencedColumnName="id")
*/
protected $type;
This will create the column "prtyID" in your products table which is defined as the foreign key to productTypes primary colum "id"

How to get names of the table attributes?

I am working Sql Server 2005
My table name is Customer, the attributes are
Orderid
Customerid
Customeraddress
Wherein Customerid is the primary key and Orderid is the foreign key.
I want to know the
primary key name,
foreign key name and
the table name where the foreign key exists as a primary key
Is there any query to retrieve those names using a table name?
Kindly please provide me the queries...Thanks in advance
--list all columns in BLAH table
select c.name
from sys.columns c, sys.tables t
where c.object_id=t.object_id
and t.name='BLAH'