Questions tagged [table-structure]
59 questions
2146
votes
24 answers
PostgreSQL "DESCRIBE TABLE"
How do you perform the equivalent of Oracle's DESCRIBE TABLE in PostgreSQL with psql command?

Mr. Muskrat
- 22,772
- 3
- 20
- 21
51
votes
5 answers
MySQL Row Format: Difference between fixed and dynamic?
MySQL specifies the row format of a table as either fixed or dynamic, depending on the column data types. If a table has a variable-length column data type, such as TEXT or VARCHAR, the row format is dynamic; otherwise, it's fixed.
My question is,…

moo
- 7,619
- 9
- 42
- 40
37
votes
4 answers
How do I implement threaded comments?
I am developing a web application that can support threaded comments. I need the ability to rearrange the comments based on the number of votes received. (Identical to how threaded comments work in reddit)
I would love to hear the inputs from the SO…

Niyaz
- 53,943
- 55
- 151
- 182
27
votes
5 answers
How do I check if a column exists in SQL Server?
How do I check if a column exists in SQL Server 2000?

user31071
- 271
- 1
- 3
- 4
12
votes
6 answers
table structure for personal messages
What is the best table structure to store dialogs between users in private messages?
Each user can send personal message to many recepients.
Each message has flag for sender: is message deleted or not
Each message has flag for receiver: is message…

Lari13
- 1,850
- 10
- 28
- 55
11
votes
6 answers
Best way of storing 'website settings' data in a database table?
I am working on a marketplace, and was wondering what is the best way of handling website settings such as title, url, if its https, contact email, version, etc.
I am trying to structure the table so it is easy to update, and able to have more and…

xtrman
- 421
- 3
- 14
7
votes
3 answers
Need Pattern for dynamic search of multiple sql tables
I'm looking for a pattern for performing a dynamic search on multiple tables.
I have no control over the legacy (and poorly designed) database table structure.
Consider a scenario similar to a resume search where a user may want to perform a search…

Geoff
- 9,340
- 7
- 38
- 48
7
votes
1 answer
Impossible MySQL insert ... select foreign key constraint error‽
This has me baffled, here's hoping someone can help.
Query:
insert into `shelter_pages` (`userid`,`relid`)
select :userid, `id` from `shelter` where `stage`='egg' order by rand() limit 30
Simple, right? Take 30 random rows meeting a condition, and…

Niet the Dark Absol
- 320,036
- 81
- 464
- 592
7
votes
5 answers
MySQL - Best method to handle this hierarchical data?
This is a followup to:
MySQL - Is it possible to get all sub-items in a hierarchy?
I have an arbitrary-depth adjacency list model table (I am at the point that I can convert it into a nested set model.
I read the MySQL data on how to use a nested…

Kerry Jones
- 21,806
- 12
- 62
- 89
6
votes
1 answer
How to store family relationship information with 1 record
Lets consider that we have Person A. Person F is his father, person M is his mother, person B is his brother and person S is his son.
Each person may have many relations. Thats why, we have to create new relationship table like…

Ulphat
- 734
- 1
- 7
- 26
5
votes
3 answers
how to get table structre of a database in java?
how to get table structre of a database in java?

adnan
- 67
- 1
- 2
5
votes
9 answers
One To Many To Itself
How would one structure a table for an entity that can have a one to many relationship to itself? Specifically, I'm working on an app to track animal breeding. Each animal has an ID; it's also got a sire ID and a dame ID. So it's possible to have…

Onorio Catenacci
- 14,928
- 14
- 81
- 132
4
votes
2 answers
What changes do I need for my tables to work on AppEngine's BigTable?
Let's say I have a booking database consisting of users:
user_id
fname
lname
and their tickets
ticket_id
user_id
flight_no
and associated flights
flight_no
airline
departure_time
arrival_time
What would I need to change to move this Google…

karl
- 393
- 3
- 7
- 14
3
votes
2 answers
How to model Friendship relationships
I have been trying to figure out how to do this, and even with looking at other examples, I can't get it figured out, so maybe I can get some personalized help.
I've got two tables, users_status and friendships.
In the users_status table I have a…

vertigoelectric
- 1,307
- 4
- 17
- 37
3
votes
6 answers
How do I know if CONSTRAINT_NAME is a Primary or Foreign Key?
Using this SQL on SQL Server 2005
SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME = @TableName
AND COLUMN_NAME=@ColumnName
I get the Primary Keys AND the Foreign Keys.
How can I get only Foreign Keys?
How can I…

Marco Bettiolo
- 5,071
- 6
- 30
- 35